382 {"bitmap" : opjimg("Stop"), |
384 {"bitmap" : opjimg("Stop"), |
383 "name" : _("Stop"), |
385 "name" : _("Stop"), |
384 "shown" : False, |
386 "shown" : False, |
385 "tooltip" : _("Stop Running PLC"), |
387 "tooltip" : _("Stop Running PLC"), |
386 "method" : "_Stop"}, |
388 "method" : "_Stop"}, |
387 {"bitmap" : opjimg("Build"), |
|
388 "name" : _("Build"), |
|
389 "tooltip" : _("Build project into build folder"), |
|
390 "method" : "_build"}, |
|
391 {"bitmap" : opjimg("Transfer"), |
389 {"bitmap" : opjimg("Transfer"), |
392 "name" : _("Transfer"), |
390 "name" : _("Transfer"), |
393 "shown" : False, |
391 "shown" : False, |
394 "tooltip" : _("Transfer PLC"), |
392 "tooltip" : _("Transfer PLC"), |
395 "method" : "_Transfer"}, |
393 "method" : "_Transfer"}, |
398 def __init__(self, frame, logger): |
396 def __init__(self, frame, logger): |
399 PluginsRoot.__init__(self, frame, logger) |
397 PluginsRoot.__init__(self, frame, logger) |
400 |
398 |
401 self.PlugChildsTypes += [("LPCBus", LPCBus, "LPC bus")] |
399 self.PlugChildsTypes += [("LPCBus", LPCBus, "LPC bus")] |
402 |
400 |
403 self.OnlineMode = 0 |
401 self.OnlineMode = "OFF" |
404 self.OnlinePath = None |
402 self.LPCConnector = False |
405 |
403 |
406 self.BuildSimulation = False |
404 self.CurrentMode = None |
|
405 self.previous_mode = None |
|
406 |
407 self.SimulationBuildPath = None |
407 self.SimulationBuildPath = None |
408 |
408 |
409 self.previous_simulating = False |
409 self.AbortTransferTimer = None |
410 |
410 |
411 def GetProjectName(self): |
411 def GetProjectName(self): |
412 return self.Project.getname() |
412 return self.Project.getname() |
413 |
413 |
414 def GetDefaultTargetName(self): |
414 def GetDefaultTargetName(self): |
415 if self.BuildSimulation: |
415 if self.CurrentMode == SIMULATION_MODE: |
416 return PluginsRoot.GetDefaultTargetName(self) |
416 return PluginsRoot.GetDefaultTargetName(self) |
417 else: |
417 else: |
418 return "LPC" |
418 return "LPC" |
419 |
419 |
420 def GetTarget(self): |
420 def GetTarget(self): |
421 target = PluginsRoot.GetTarget(self) |
421 target = PluginsRoot.GetTarget(self) |
422 if not self.BuildSimulation: |
422 if self.CurrentMode != SIMULATION_MODE: |
423 target.getcontent()["value"].setBuildPath(self.BuildPath) |
423 target.getcontent()["value"].setBuildPath(self.BuildPath) |
424 return target |
424 return target |
425 |
425 |
426 def _getBuildPath(self): |
426 def _getBuildPath(self): |
427 if self.BuildSimulation: |
427 if self.CurrentMode == SIMULATION_MODE: |
428 if self.SimulationBuildPath is None: |
428 if self.SimulationBuildPath is None: |
429 self.SimulationBuildPath = os.path.join(tempfile.mkdtemp(), os.path.basename(self.ProjectPath), "build") |
429 self.SimulationBuildPath = os.path.join(tempfile.mkdtemp(), os.path.basename(self.ProjectPath), "build") |
430 return self.SimulationBuildPath |
430 return self.SimulationBuildPath |
431 else: |
431 else: |
432 return PluginsRoot._getBuildPath(self) |
432 return PluginsRoot._getBuildPath(self) |
438 |
438 |
439 def SetProjectName(self, name): |
439 def SetProjectName(self, name): |
440 return self.Project.setname(name) |
440 return self.Project.setname(name) |
441 |
441 |
442 def SetOnlineMode(self, mode, path=None): |
442 def SetOnlineMode(self, mode, path=None): |
443 if self.OnlineMode != mode: |
443 if self.OnlineMode != mode.upper(): |
444 self.OnlineMode = mode |
444 self.OnlineMode = mode.upper() |
445 self.KillDebugThread() |
445 |
446 |
446 if self.OnlineMode != "OFF": |
447 if self.OnlineMode != 0: |
447 uri = "LPC://%s" % path |
448 if self._connector is None: |
448 try: |
449 uri = "LPC://%s" % path |
449 self.LPCConnector = connectors.ConnectorFactory(uri, self) |
450 try: |
450 except Exception, msg: |
451 self._connector = connectors.ConnectorFactory(uri, self) |
451 self.logger.write_error(_("Exception while connecting %s!\n")%uri) |
452 except Exception, msg: |
452 self.logger.write_error(traceback.format_exc()) |
453 self.logger.write_error(_("Exception while connecting %s!\n")%uri) |
453 |
454 self.logger.write_error(traceback.format_exc()) |
454 # Did connection success ? |
455 |
455 if self.LPCConnector is None: |
456 # Did connection success ? |
456 # Oups. |
457 if self._connector is None: |
457 self.logger.write_error(_("Connection failed to %s!\n")%uri) |
458 # Oups. |
|
459 self.logger.write_error(_("Connection failed to %s!\n")%uri) |
|
460 |
|
461 if self._connector is not None: |
|
462 |
|
463 if self.OnlineMode == 1: |
|
464 self.CompareLocalAndRemotePLC() |
|
465 |
|
466 # Init with actual PLC status and print it |
|
467 self.UpdateMethodsFromPLCStatus() |
|
468 if self.previous_plcstate is not None: |
|
469 status = _(self.previous_plcstate) |
|
470 else: |
|
471 status = "" |
|
472 self.logger.write(_("PLC is %s\n")%status) |
|
473 |
|
474 # Start the status Timer |
|
475 self.StatusTimer.Start(milliseconds=500, oneShot=False) |
|
476 |
|
477 if self.previous_plcstate=="Started": |
|
478 if self.DebugAvailable() and self.GetIECProgramsAndVariables(): |
|
479 self.logger.write(_("Debug connect matching running PLC\n")) |
|
480 self._connect_debug() |
|
481 else: |
|
482 self.logger.write_warning(_("Debug do not match PLC - stop/transfert/start to re-enable\n")) |
|
483 |
458 |
484 else: |
459 else: |
485 self._connector = None |
460 self.LPCConnector = None |
|
461 |
|
462 self.ApplyOnlineMode() |
|
463 |
|
464 def ApplyOnlineMode(self): |
|
465 if self.CurrentMode != SIMULATION_MODE: |
|
466 self.KillDebugThread() |
|
467 |
|
468 self._connector = self.LPCConnector |
|
469 |
|
470 # Init with actual PLC status and print it |
|
471 self.UpdateMethodsFromPLCStatus() |
|
472 |
|
473 if self.LPCConnector is not None and self.OnlineMode == "APPLICATION": |
|
474 |
|
475 self.CompareLocalAndRemotePLC() |
|
476 |
|
477 if self.previous_plcstate is not None: |
|
478 status = _(self.previous_plcstate) |
|
479 else: |
|
480 status = "" |
|
481 self.logger.write(_("PLC is %s\n")%status) |
|
482 |
|
483 if not self.StatusTimer.IsRunning(): |
|
484 # Start the status Timer |
|
485 self.StatusTimer.Start(milliseconds=500, oneShot=False) |
|
486 |
|
487 if self.previous_plcstate=="Started": |
|
488 if self.DebugAvailable() and self.GetIECProgramsAndVariables(): |
|
489 self.logger.write(_("Debug connect matching running PLC\n")) |
|
490 self._connect_debug() |
|
491 else: |
|
492 self.logger.write_warning(_("Debug do not match PLC - stop/transfert/start to re-enable\n")) |
|
493 |
|
494 elif self.StatusTimer.IsRunning(): |
486 self.StatusTimer.Stop() |
495 self.StatusTimer.Stop() |
|
496 |
|
497 if self.CurrentMode == TRANSFER_MODE: |
487 |
498 |
488 self.OnlinePath = path |
499 if self.OnlineMode == "BOOTLOADER": |
489 self.UpdateMethodsFromPLCStatus() |
500 self.BeginTransfer() |
490 |
501 |
|
502 elif self.OnlineMode == "APPLICATION": |
|
503 self.CurrentMode = None |
|
504 self.AbortTransferTimer.Stop() |
|
505 self.AbortTransferTimer = None |
|
506 |
|
507 self.logger.write(_("PLC transferred successfully\n")) |
|
508 |
491 # Update a PLCOpenEditor Pou variable name |
509 # Update a PLCOpenEditor Pou variable name |
492 def UpdateProjectVariableName(self, old_name, new_name): |
510 def UpdateProjectVariableName(self, old_name, new_name): |
493 self.Project.updateElementName(old_name, new_name) |
511 self.Project.updateElementName(old_name, new_name) |
494 self.BufferProject() |
512 self.BufferProject() |
495 |
513 |
546 self.LoadChilds() |
564 self.LoadChilds() |
547 |
565 |
548 if self.PlugTestModified(): |
566 if self.PlugTestModified(): |
549 self.SaveProject() |
567 self.SaveProject() |
550 |
568 |
551 self.RefreshPluginsBlockLists() |
569 if wx.GetApp() is None: |
|
570 self.RefreshPluginsBlockLists() |
|
571 else: |
|
572 wx.CallAfter(self.RefreshPluginsBlockLists) |
552 |
573 |
553 return None |
574 return None |
554 |
575 |
555 ############# Real PLC object access ############# |
576 ############# Real PLC object access ############# |
556 def UpdateMethodsFromPLCStatus(self): |
577 def UpdateMethodsFromPLCStatus(self): |
557 # Get PLC state : Running or Stopped |
578 # Get PLC state : Running or Stopped |
558 # TODO : use explicit status instead of boolean |
579 # TODO : use explicit status instead of boolean |
559 simulating = False |
580 if self.OnlineMode == "OFF": |
560 if self.OnlineMode == 0: |
|
561 if self._connector is not None: |
|
562 simulating = self._connector.GetPLCstatus() == "Started" |
|
563 status = "Disconnected" |
581 status = "Disconnected" |
564 elif self.OnlineMode == 2: |
582 elif self.OnlineMode == "BOOTLOADER": |
565 if self._connector is not None: |
|
566 simulating = self._connector.GetPLCstatus() == "Started" |
|
567 status = "Connected" |
583 status = "Connected" |
568 else: |
584 else: |
569 if self._connector is not None: |
585 if self._connector is not None: |
570 status = self._connector.GetPLCstatus() |
586 status = self._connector.GetPLCstatus() |
571 else: |
587 else: |
572 status = "Disconnected" |
588 status = "Disconnected" |
573 if self.previous_plcstate != status or self.previous_simulating != simulating: |
589 if self.previous_plcstate != status or self.previous_mode != self.CurrentMode: |
|
590 simulating = self.CurrentMode == SIMULATION_MODE |
574 for args in { |
591 for args in { |
575 "Started" : [("_Simulate", False), |
592 "Started" : [("_Simulate", False), |
576 ("_Run", False), |
593 ("_Run", False), |
577 ("_Stop", True), |
594 ("_Stop", True), |
578 ("_build", False), |
|
579 ("_Transfer", False)], |
595 ("_Transfer", False)], |
580 "Stopped" : [("_Simulate", False), |
596 "Stopped" : [("_Simulate", True), |
581 ("_Run", True), |
597 ("_Run", True), |
582 ("_Stop", False), |
598 ("_Stop", False), |
583 ("_build", False), |
|
584 ("_Transfer", False)], |
599 ("_Transfer", False)], |
585 "Connected" : [("_Simulate", not simulating), |
600 "Connected" : [("_Simulate", not simulating), |
586 ("_Run", False), |
601 ("_Run", False), |
587 ("_Stop", simulating), |
602 ("_Stop", simulating), |
588 ("_build", False), |
|
589 ("_Transfer", True)], |
603 ("_Transfer", True)], |
590 "Disconnected" :[("_Simulate", not simulating), |
604 "Disconnected" :[("_Simulate", not simulating), |
591 ("_Run", False), |
605 ("_Run", False), |
592 ("_Stop", simulating), |
606 ("_Stop", simulating), |
593 ("_build", True), |
|
594 ("_Transfer", False)], |
607 ("_Transfer", False)], |
595 }.get(status,[]): |
608 }.get(status,[]): |
596 self.ShowMethod(*args) |
609 self.ShowMethod(*args) |
597 self.previous_plcstate = status |
610 self.previous_plcstate = status |
598 self.previous_simulating = simulating |
611 self.previous_mode = self.CurrentMode |
599 return True |
612 return True |
600 return False |
613 return False |
601 |
614 |
602 def Generate_plc_declare_locations(self): |
615 def Generate_plc_declare_locations(self): |
603 """ |
616 """ |
692 # Insert this file as first file to be compiled at root plugin |
705 # Insert this file as first file to be compiled at root plugin |
693 self.LocationCFilesAndCFLAGS[0][1].insert(0,(code_path, self.plcCFLAGS)) |
706 self.LocationCFilesAndCFLAGS[0][1].insert(0,(code_path, self.plcCFLAGS)) |
694 except Exception, exc: |
707 except Exception, exc: |
695 self.logger.write_error(name+_(" generation failed !\n")) |
708 self.logger.write_error(name+_(" generation failed !\n")) |
696 self.logger.write_error(traceback.format_exc()) |
709 self.logger.write_error(traceback.format_exc()) |
697 self.BuildSimulation = False |
710 self.StopSimulation() |
698 return False |
711 return False |
699 |
712 |
700 # Get simulation builder |
713 # Get simulation builder |
701 builder = self.GetBuilder() |
714 builder = self.GetBuilder() |
702 if builder is None: |
715 if builder is None: |
703 self.logger.write_error(_("Fatal : cannot get builder.\n")) |
716 self.logger.write_error(_("Fatal : cannot get builder.\n")) |
704 self.BuildSimulation = False |
717 self.StopSimulation() |
705 return False |
718 return False |
706 |
719 |
707 # Build |
720 # Build |
708 try: |
721 try: |
709 if not builder.build() : |
722 if not builder.build() : |
710 self.logger.write_error(_("C Build failed.\n")) |
723 self.logger.write_error(_("C Build failed.\n")) |
711 self.BuildSimulation = False |
724 self.StopSimulation() |
712 return False |
725 return False |
713 except Exception, exc: |
726 except Exception, exc: |
714 self.logger.write_error(_("C Build crashed !\n")) |
727 self.logger.write_error(_("C Build crashed !\n")) |
715 self.logger.write_error(traceback.format_exc()) |
728 self.logger.write_error(traceback.format_exc()) |
716 self.BuildSimulation = False |
729 self.StopSimulation() |
717 return False |
730 return False |
718 |
731 |
719 data = builder.GetBinaryCode() |
732 data = builder.GetBinaryCode() |
720 if data is not None : |
733 if data is not None : |
721 if self._connector.NewPLC(builder.GetBinaryCodeMD5(), data, []): |
734 if self._connector.NewPLC(builder.GetBinaryCodeMD5(), data, []): |
725 self.UnsubscribeAllDebugIECVariable() |
738 self.UnsubscribeAllDebugIECVariable() |
726 self.ProgramTransferred() |
739 self.ProgramTransferred() |
727 self.logger.write(_("Transfer completed successfully.\n")) |
740 self.logger.write(_("Transfer completed successfully.\n")) |
728 else: |
741 else: |
729 self.logger.write_error(_("Transfer failed\n")) |
742 self.logger.write_error(_("Transfer failed\n")) |
730 self.BuildSimulation = False |
743 self.StopSimulation() |
731 return False |
744 return False |
732 |
745 |
733 self._Run() |
746 self._Run() |
734 |
747 |
735 self.BuildSimulation = False |
748 if not self.StatusTimer.IsRunning(): |
736 |
749 # Start the status Timer |
737 # Start the status Timer |
750 self.StatusTimer.Start(milliseconds=500, oneShot=False) |
738 self.StatusTimer.Start(milliseconds=500, oneShot=False) |
751 |
739 |
752 def StopSimulation(self): |
|
753 self.CurrentMode = None |
|
754 self.ApplyOnlineMode() |
|
755 |
|
756 def _Stop(self): |
|
757 PluginsRoot._Stop(self) |
|
758 |
|
759 if self.CurrentMode == SIMULATION_MODE: |
|
760 self.StopSimulation() |
|
761 |
|
762 def _Transfer(self): |
|
763 if self.CurrentMode is None and self.OnlineMode != "OFF": |
|
764 self.CurrentMode = TRANSFER_MODE |
|
765 |
|
766 PluginsRoot._build(self) |
|
767 |
|
768 ID_ABORTTRANSFERTIMER = wx.NewId() |
|
769 self.AbortTransferTimer = wx.Timer(self.AppFrame, ID_ABORTTRANSFERTIMER) |
|
770 self.AppFrame.Bind(wx.EVT_TIMER, self.AbortTransfer, self.AbortTransferTimer) |
|
771 |
|
772 if self.OnlineMode == "BOOTLOADER": |
|
773 self.BeginTransfer() |
|
774 |
|
775 else: |
|
776 self.logger.write(_("Resetting PLC\n")) |
|
777 |
|
778 self.LPCConnector.ResetPLC() |
|
779 self.AbortTransferTimer.Start(milliseconds=5000, oneShot=True) |
|
780 |
|
781 def BeginTransfer(self): |
|
782 self.logger.write(_("Start PLC transfer\n")) |
|
783 |
|
784 self.AbortTransferTimer.Stop() |
|
785 PluginsRoot._Transfer(self) |
|
786 self.AbortTransferTimer.Start(milliseconds=5000, oneShot=True) |
|
787 |
|
788 def AbortTransfer(self, event): |
|
789 self.logger.write(_("Transfer failed\n")) |
|
790 |
|
791 self.CurrentMode = None |
|
792 self.AbortTransferTimer.Stop() |
|
793 self.AbortTransferTimer = None |
|
794 event.Skip() |
|
795 |
740 #------------------------------------------------------------------------------- |
796 #------------------------------------------------------------------------------- |
741 # LPCBeremiz Class |
797 # LPCBeremiz Class |
742 #------------------------------------------------------------------------------- |
798 #------------------------------------------------------------------------------- |
743 |
799 |
744 class LPCBeremiz(Beremiz): |
800 class LPCBeremiz(Beremiz): |
793 |
849 |
794 self._init_beremiz_sizers() |
850 self._init_beremiz_sizers() |
795 |
851 |
796 def OnCloseFrame(self, event): |
852 def OnCloseFrame(self, event): |
797 global frame |
853 global frame |
798 frame = None |
854 |
|
855 frame.Hide() |
|
856 |
799 self.PluginRoot.ResetAppFrame(lpcberemiz_cmd.Log) |
857 self.PluginRoot.ResetAppFrame(lpcberemiz_cmd.Log) |
800 if self.PluginRoot.OnlineMode == 0: |
858 if self.PluginRoot.OnlineMode == 0: |
801 self.PluginRoot._connector = None |
859 self.PluginRoot._connector = None |
802 |
860 |
803 self.PluginRoot.KillDebugThread() |
861 self.PluginRoot.KillDebugThread() |
804 self.KillLocalRuntime() |
862 self.KillLocalRuntime() |
805 |
863 |
806 print "Closed" |
864 print "Closed" |
807 sys.stdout.flush() |
865 sys.stdout.flush() |
808 |
866 |
809 event.Skip() |
867 event.Veto() |
810 |
868 |
811 def ShowProperties(self): |
869 def ShowProperties(self): |
812 old_values = self.Controler.GetProjectProperties() |
870 old_values = self.Controler.GetProjectProperties() |
813 dialog = ProjectDialog(self ,False) |
871 dialog = ProjectDialog(self ,False) |
814 dialog.SetValues(old_values) |
872 dialog.SetValues(old_values) |
1023 |
1076 |
1024 __builtin__.__dict__['_'] = wx.GetTranslation#unicode_translation |
1077 __builtin__.__dict__['_'] = wx.GetTranslation#unicode_translation |
1025 |
1078 |
1026 # Install a exception handle for bug reports |
1079 # Install a exception handle for bug reports |
1027 AddExceptHook(os.getcwd(),__version__) |
1080 AddExceptHook(os.getcwd(),__version__) |
1028 |
1081 |
1029 frame = LPCBeremiz(None, plugin_root=plugin_root, debug=True) |
1082 frame = LPCBeremiz(None, plugin_root=plugin_root, debug=True) |
1030 plugin_root.SetAppFrame(frame, frame.Log) |
|
1031 frame.Show() |
|
1032 frame.Raise() |
|
1033 |
1083 |
1034 app.MainLoop() |
1084 app.MainLoop() |
1035 |
1085 |
1036 frame = None |
|
1037 app = None |
|
1038 |
|
1039 class StdoutPseudoFile: |
1086 class StdoutPseudoFile: |
1040 """ Base class for file like objects to facilitate StdOut for the Shell.""" |
1087 """ Base class for file like objects to facilitate StdOut for the Shell.""" |
1041 def write(self, s, style = None): |
1088 def write(self, s, style = None): |
1042 if s != '': |
1089 if s != '': |
1043 print s |
1090 print s |
1072 result = self.PluginRoot.LoadProject(projectOpen, buildpath) |
1119 result = self.PluginRoot.LoadProject(projectOpen, buildpath) |
1073 if result: |
1120 if result: |
1074 print "Error: Invalid project directory", result |
1121 print "Error: Invalid project directory", result |
1075 else: |
1122 else: |
1076 print "Error: No such file or directory" |
1123 print "Error: No such file or directory" |
|
1124 beremiz_thread=Thread(target=MainLoopProc, args=[self.PluginRoot]) |
|
1125 beremiz_thread.start() |
1077 |
1126 |
1078 def RestartTimer(self): |
1127 def RestartTimer(self): |
1079 if self.RefreshTimer is not None: |
1128 if self.RefreshTimer is not None: |
1080 self.RefreshTimer.cancel() |
1129 self.RefreshTimer.cancel() |
1081 self.RefreshTimer = Timer(0.1, self.Refresh) |
1130 self.RefreshTimer = Timer(0.1, self.Refresh) |
1082 self.RefreshTimer.start() |
1131 self.RefreshTimer.start() |
1083 |
1132 |
1084 def Exit(self): |
1133 def Exit(self): |
|
1134 global frame, app |
1085 self.Close() |
1135 self.Close() |
|
1136 app.ExitMainLoop() |
1086 return True |
1137 return True |
1087 |
1138 |
1088 def do_EOF(self, line): |
1139 def do_EOF(self, line): |
1089 return self.Exit() |
1140 return self.Exit() |
1090 |
1141 |
1091 def Show(self): |
1142 def Show(self): |
1092 global frame |
1143 global frame |
1093 if frame is None: |
1144 if frame is not None: |
1094 beremiz_thread=Thread(target=BeremizStartProc, args=[self.PluginRoot]) |
1145 self.PluginRoot.SetAppFrame(frame, frame.Log) |
1095 beremiz_thread.start() |
1146 wx.CallAfter(frame.Show) |
1096 |
1147 |
1097 def Refresh(self): |
1148 def Refresh(self): |
1098 global frame |
1149 global frame |
1099 if frame is not None: |
1150 if frame is not None: |
1100 wx.CallAfter(frame._Refresh, TITLE, INSTANCESTREE, FILEMENU, EDITMENU) |
1151 wx.CallAfter(frame._Refresh, TITLE, INSTANCESTREE, FILEMENU, EDITMENU) |
1104 def Close(self): |
1155 def Close(self): |
1105 global frame |
1156 global frame |
1106 |
1157 |
1107 self.PluginRoot.ResetAppFrame(self.Log) |
1158 self.PluginRoot.ResetAppFrame(self.Log) |
1108 if frame is not None: |
1159 if frame is not None: |
1109 wx.CallAfter(frame.Close) |
1160 wx.CallAfter(frame.Hide) |
1110 |
1161 |
1111 def Compile(self): |
1162 def Compile(self): |
1112 if wx.GetApp() is None: |
1163 wx.CallAfter(self.PluginRoot._build) |
1113 self.PluginRoot._build() |
|
1114 else: |
|
1115 wx.CallAfter(self.PluginRoot._build) |
|
1116 |
1164 |
1117 def SetProjectProperties(self, projectname, productname, productversion, companyname): |
1165 def SetProjectProperties(self, projectname, productname, productversion, companyname): |
1118 properties = self.PluginRoot.GetProjectProperties() |
1166 properties = self.PluginRoot.GetProjectProperties() |
1119 properties["projectName"] = projectname |
1167 properties["projectName"] = projectname |
1120 properties["productName"] = productname |
1168 properties["productName"] = productname |
1122 properties["companyName"] = companyname |
1170 properties["companyName"] = companyname |
1123 self.PluginRoot.SetProjectProperties(properties=properties) |
1171 self.PluginRoot.SetProjectProperties(properties=properties) |
1124 self.RestartTimer() |
1172 self.RestartTimer() |
1125 |
1173 |
1126 def SetOnlineMode(self, mode, path=None): |
1174 def SetOnlineMode(self, mode, path=None): |
1127 self.PluginRoot.SetOnlineMode(mode, path) |
1175 wx.CallAfter(self.PluginRoot.SetOnlineMode, mode, path) |
1128 self.RestartTimer() |
1176 self.RestartTimer() |
1129 |
1177 |
1130 def AddBus(self, iec_channel, name, icon=None): |
1178 def AddBus(self, iec_channel, name, icon=None): |
1131 for child in self.PluginRoot.IterChilds(): |
1179 for child in self.PluginRoot.IterChilds(): |
1132 if child.BaseParams.getName() == name: |
1180 if child.BaseParams.getName() == name: |
1154 if bus is None: |
1202 if bus is None: |
1155 return "Error: No bus found" |
1203 return "Error: No bus found" |
1156 for child in self.PluginRoot.IterChilds(): |
1204 for child in self.PluginRoot.IterChilds(): |
1157 if child != bus and child.BaseParams.getIEC_Channel() == new_iec_channel: |
1205 if child != bus and child.BaseParams.getIEC_Channel() == new_iec_channel: |
1158 return "Error: A bus with IEC_channel %d already exists" % new_iec_channel |
1206 return "Error: A bus with IEC_channel %d already exists" % new_iec_channel |
1159 self.PluginRoot.UpdateProjectVariableLocation(str(old_iec_channel), str(new_iec_channel)) |
1207 if wx.GetApp() is None: |
|
1208 self.PluginRoot.UpdateProjectVariableLocation(str(old_iec_channel), |
|
1209 str(new_iec_channel)) |
|
1210 else: |
|
1211 wx.CallAfter(self.PluginRoot.UpdateProjectVariableLocation, |
|
1212 str(old_iec_channel), |
|
1213 str(new_iec_channel)) |
1160 bus.BaseParams.setIEC_Channel(new_iec_channel) |
1214 bus.BaseParams.setIEC_Channel(new_iec_channel) |
1161 self.RestartTimer() |
1215 self.RestartTimer() |
1162 |
1216 |
1163 def RemoveBus(self, iec_channel): |
1217 def RemoveBus(self, iec_channel): |
1164 bus = self.PluginRoot.GetChildByIECLocation((iec_channel,)) |
1218 bus = self.PluginRoot.GetChildByIECLocation((iec_channel,)) |