equal
deleted
inserted
replaced
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 |
495 |
497 |
496 if havetwisted: |
498 if havetwisted: |
497 if webport is not None: |
499 if webport is not None: |
498 try: |
500 try: |
499 import runtime.NevowServer as NS # pylint: disable=ungrouped-imports |
501 import runtime.NevowServer as NS # pylint: disable=ungrouped-imports |
500 except Exception: |
502 except Exception: |
501 LogMessageAndException(_("Nevow/Athena import failed :")) |
503 LogMessageAndException(_("Nevow/Athena import failed :")) |
502 webport = None |
504 webport = None |
503 NS.WorkingDir = WorkingDir |
505 NS.WorkingDir = WorkingDir # bug? what happens if import fails? |
504 |
506 |
|
507 # Try to add support for BACnet configuration via web server interface |
|
508 # NOTE:BACnet web config only makes sense if web server is available |
|
509 if webport is not None: |
|
510 try: |
|
511 import runtime.BACnet_config as BNconf |
|
512 haveBNconf = True |
|
513 except Exception: |
|
514 LogMessageAndException(_("BACnet configuration web interface - import failed :")) |
|
515 |
505 try: |
516 try: |
506 import runtime.WampClient as WC # pylint: disable=ungrouped-imports |
517 import runtime.WampClient as WC # pylint: disable=ungrouped-imports |
507 WC.WorkingDir = WorkingDir |
518 WC.WorkingDir = WorkingDir |
508 havewamp = True |
519 havewamp = True |
509 except Exception: |
520 except Exception: |
520 if servicename is not None and PSKpath is not None: |
531 if servicename is not None and PSKpath is not None: |
521 ensurePSK(servicename, PSKpath) |
532 ensurePSK(servicename, PSKpath) |
522 |
533 |
523 runtime.CreatePLCObjectSingleton( |
534 runtime.CreatePLCObjectSingleton( |
524 WorkingDir, argv, statuschange, evaluator, pyruntimevars) |
535 WorkingDir, argv, statuschange, evaluator, pyruntimevars) |
|
536 |
|
537 plcobj = runtime.GetPLCObjectSingleton() |
525 |
538 |
526 pyroserver = PyroServer(servicename, interface, port) |
539 pyroserver = PyroServer(servicename, interface, port) |
527 |
540 |
528 if havewx: |
541 if havewx: |
529 taskbar_instance = BeremizTaskBarIcon(pyroserver) |
542 taskbar_instance = BeremizTaskBarIcon(pyroserver) |
535 pyruntimevars["website"] = website |
548 pyruntimevars["website"] = website |
536 NS.SetServer(pyroserver) |
549 NS.SetServer(pyroserver) |
537 statuschange.append(NS.website_statuslistener_factory(website)) |
550 statuschange.append(NS.website_statuslistener_factory(website)) |
538 except Exception: |
551 except Exception: |
539 LogMessageAndException(_("Nevow Web service failed. ")) |
552 LogMessageAndException(_("Nevow Web service failed. ")) |
|
553 |
|
554 if haveBNconf: |
|
555 try: |
|
556 BNconf.init(plcobj, NS, WorkingDir) |
|
557 except Exception: |
|
558 LogMessageAndException(_("BACnet web configuration failed startup. ")) |
540 |
559 |
541 if havewamp: |
560 if havewamp: |
542 try: |
561 try: |
543 WC.SetServer(pyroserver) |
562 WC.SetServer(pyroserver) |
544 WC.RegisterWampClient(wampconf, PSKpath) |
563 WC.RegisterWampClient(wampconf, PSKpath) |
599 pass |
618 pass |
600 |
619 |
601 pyroserver.Quit() |
620 pyroserver.Quit() |
602 pyro_thread.join() |
621 pyro_thread.join() |
603 |
622 |
604 plcobj = runtime.GetPLCObjectSingleton() |
|
605 plcobj.StopPLC() |
623 plcobj.StopPLC() |
606 plcobj.UnLoadPLC() |
624 plcobj.UnLoadPLC() |
607 |
625 |
608 if havetwisted: |
626 if havetwisted: |
609 reactor.stop() |
627 reactor.stop() |