490 threading.Thread.__init__ = init |
490 threading.Thread.__init__ = init |
491 |
491 |
492 |
492 |
493 installThreadExcepthook() |
493 installThreadExcepthook() |
494 havewamp = False |
494 havewamp = False |
495 haveBNconf = False |
|
496 haveMBconf = False |
|
497 |
|
498 |
495 |
499 if havetwisted: |
496 if havetwisted: |
500 if webport is not None: |
497 if webport is not None: |
501 try: |
498 try: |
502 import runtime.NevowServer as NS # pylint: disable=ungrouped-imports |
499 import runtime.NevowServer as NS # pylint: disable=ungrouped-imports |
|
500 NS.WorkingDir = WorkingDir |
503 except Exception: |
501 except Exception: |
504 LogMessageAndException(_("Nevow/Athena import failed :")) |
502 LogMessageAndException(_("Nevow/Athena import failed :")) |
505 webport = None |
503 webport = None |
506 NS.WorkingDir = WorkingDir # bug? what happens if import fails? |
504 |
507 |
|
508 # Try to add support for BACnet configuration via web server interface |
|
509 # NOTE:BACnet web config only makes sense if web server is available |
|
510 if webport is not None: |
|
511 try: |
|
512 import runtime.BACnet_config as BNconf |
|
513 haveBNconf = True |
|
514 except Exception: |
|
515 LogMessageAndException(_("BACnet configuration web interface - import failed :")) |
|
516 |
|
517 # Try to add support for Modbus configuration via web server interface |
|
518 # NOTE:Modbus web config only makes sense if web server is available |
|
519 if webport is not None: |
|
520 try: |
|
521 import runtime.Modbus_config as MBconf |
|
522 haveMBconf = True |
|
523 except Exception: |
|
524 LogMessageAndException(_("Modbus configuration web interface - import failed :")) |
|
525 |
|
526 try: |
505 try: |
527 import runtime.WampClient as WC # pylint: disable=ungrouped-imports |
506 import runtime.WampClient as WC # pylint: disable=ungrouped-imports |
528 WC.WorkingDir = WorkingDir |
507 WC.WorkingDir = WorkingDir |
529 havewamp = True |
508 havewamp = True |
530 except Exception: |
509 except Exception: |
541 if servicename is not None and PSKpath is not None: |
520 if servicename is not None and PSKpath is not None: |
542 ensurePSK(servicename, PSKpath) |
521 ensurePSK(servicename, PSKpath) |
543 |
522 |
544 runtime.CreatePLCObjectSingleton( |
523 runtime.CreatePLCObjectSingleton( |
545 WorkingDir, argv, statuschange, evaluator, pyruntimevars) |
524 WorkingDir, argv, statuschange, evaluator, pyruntimevars) |
546 |
|
547 plcobj = runtime.GetPLCObjectSingleton() |
|
548 |
525 |
549 pyroserver = PyroServer(servicename, interface, port) |
526 pyroserver = PyroServer(servicename, interface, port) |
550 |
527 |
551 if havewx: |
528 if havewx: |
552 taskbar_instance = BeremizTaskBarIcon(pyroserver) |
529 taskbar_instance = BeremizTaskBarIcon(pyroserver) |
558 pyruntimevars["website"] = website |
535 pyruntimevars["website"] = website |
559 NS.SetServer(pyroserver) |
536 NS.SetServer(pyroserver) |
560 statuschange.append(NS.website_statuslistener_factory(website)) |
537 statuschange.append(NS.website_statuslistener_factory(website)) |
561 except Exception: |
538 except Exception: |
562 LogMessageAndException(_("Nevow Web service failed. ")) |
539 LogMessageAndException(_("Nevow Web service failed. ")) |
563 |
|
564 if haveBNconf: |
|
565 try: |
|
566 BNconf.init(plcobj, NS, WorkingDir) |
|
567 except Exception: |
|
568 LogMessageAndException(_("BACnet web configuration failed startup. ")) |
|
569 |
|
570 if haveMBconf: |
|
571 try: |
|
572 MBconf.init(plcobj, NS, WorkingDir) |
|
573 except Exception: |
|
574 LogMessageAndException(_("Modbus web configuration failed startup. ")) |
|
575 |
540 |
576 if havewamp: |
541 if havewamp: |
577 try: |
542 try: |
578 WC.SetServer(pyroserver) |
543 WC.SetServer(pyroserver) |
579 WC.RegisterWampClient(wampconf, PSKpath) |
544 WC.RegisterWampClient(wampconf, PSKpath) |