equal
deleted
inserted
replaced
473 threading.Thread.__init__ = init |
473 threading.Thread.__init__ = init |
474 |
474 |
475 |
475 |
476 installThreadExcepthook() |
476 installThreadExcepthook() |
477 havewamp = False |
477 havewamp = False |
|
478 haveBNconf = False |
|
479 |
478 |
480 |
479 if havetwisted: |
481 if havetwisted: |
480 if webport is not None: |
482 if webport is not None: |
481 try: |
483 try: |
482 import runtime.NevowServer as NS # pylint: disable=ungrouped-imports |
484 import runtime.NevowServer as NS # pylint: disable=ungrouped-imports |
483 except Exception: |
485 except Exception: |
484 LogMessageAndException(_("Nevow/Athena import failed :")) |
486 LogMessageAndException(_("Nevow/Athena import failed :")) |
485 webport = None |
487 webport = None |
486 NS.WorkingDir = WorkingDir |
488 NS.WorkingDir = WorkingDir # bug? what happens if import fails? |
487 |
489 |
|
490 # Try to add support for BACnet configuration via web server interface |
|
491 # NOTE:BACnet web config only makes sense if web server is available |
|
492 if webport is not None: |
|
493 try: |
|
494 import runtime.BACnet_config as BNconf |
|
495 haveBNconf = True |
|
496 except Exception: |
|
497 LogMessageAndException(_("BACnet configuration web interface - import failed :")) |
|
498 |
488 try: |
499 try: |
489 import runtime.WampClient as WC # pylint: disable=ungrouped-imports |
500 import runtime.WampClient as WC # pylint: disable=ungrouped-imports |
490 WC.WorkingDir = WorkingDir |
501 WC.WorkingDir = WorkingDir |
491 havewamp = True |
502 havewamp = True |
492 except Exception: |
503 except Exception: |
503 if servicename is not None and PSKpath is not None: |
514 if servicename is not None and PSKpath is not None: |
504 ensurePSK(servicename, PSKpath) |
515 ensurePSK(servicename, PSKpath) |
505 |
516 |
506 runtime.CreatePLCObjectSingleton( |
517 runtime.CreatePLCObjectSingleton( |
507 WorkingDir, argv, statuschange, evaluator, pyruntimevars) |
518 WorkingDir, argv, statuschange, evaluator, pyruntimevars) |
|
519 |
|
520 plcobj = runtime.GetPLCObjectSingleton() |
508 |
521 |
509 pyroserver = PyroServer(servicename, interface, port) |
522 pyroserver = PyroServer(servicename, interface, port) |
510 |
523 |
511 if havewx: |
524 if havewx: |
512 taskbar_instance = BeremizTaskBarIcon(pyroserver) |
525 taskbar_instance = BeremizTaskBarIcon(pyroserver) |
518 pyruntimevars["website"] = website |
531 pyruntimevars["website"] = website |
519 NS.SetServer(pyroserver) |
532 NS.SetServer(pyroserver) |
520 statuschange.append(NS.website_statuslistener_factory(website)) |
533 statuschange.append(NS.website_statuslistener_factory(website)) |
521 except Exception: |
534 except Exception: |
522 LogMessageAndException(_("Nevow Web service failed. ")) |
535 LogMessageAndException(_("Nevow Web service failed. ")) |
|
536 |
|
537 if haveBNconf: |
|
538 try: |
|
539 BNconf.init(plcobj, NS, WorkingDir) |
|
540 except Exception: |
|
541 LogMessageAndException(_("BACnet web configuration failed startup. ")) |
523 |
542 |
524 if havewamp: |
543 if havewamp: |
525 try: |
544 try: |
526 WC.SetServer(pyroserver) |
545 WC.SetServer(pyroserver) |
527 WC.RegisterWampClient(wampconf, PSKpath) |
546 WC.RegisterWampClient(wampconf, PSKpath) |
582 pass |
601 pass |
583 |
602 |
584 pyroserver.Quit() |
603 pyroserver.Quit() |
585 pyro_thread.join() |
604 pyro_thread.join() |
586 |
605 |
587 plcobj = runtime.GetPLCObjectSingleton() |
|
588 plcobj.StopPLC() |
606 plcobj.StopPLC() |
589 plcobj.UnLoadPLC() |
607 plcobj.UnLoadPLC() |
590 |
608 |
591 if havetwisted: |
609 if havetwisted: |
592 reactor.stop() |
610 reactor.stop() |