460 PlugChildsTypes = dict(zip(transpose[0],zip(transpose[1],transpose[2]))) |
460 PlugChildsTypes = dict(zip(transpose[0],zip(transpose[1],transpose[2]))) |
461 # Check that adding this plugin is allowed |
461 # Check that adding this plugin is allowed |
462 try: |
462 try: |
463 PlugClass, PlugHelp = PlugChildsTypes[PlugType] |
463 PlugClass, PlugHelp = PlugChildsTypes[PlugType] |
464 except KeyError: |
464 except KeyError: |
465 raise Exception, "Cannot create child %s of type %s "%(PlugName, PlugType) |
465 raise Exception, _("Cannot create child %s of type %s ")%(PlugName, PlugType) |
466 |
466 |
467 # if PlugClass is a class factory, call it. (prevent unneeded imports) |
467 # if PlugClass is a class factory, call it. (prevent unneeded imports) |
468 if type(PlugClass) == types.FunctionType: |
468 if type(PlugClass) == types.FunctionType: |
469 PlugClass = PlugClass() |
469 PlugClass = PlugClass() |
470 |
470 |
471 # Eventualy Initialize child instance list for this class of plugin |
471 # Eventualy Initialize child instance list for this class of plugin |
472 PluggedChildsWithSameClass = self.PluggedChilds.setdefault(PlugType, list()) |
472 PluggedChildsWithSameClass = self.PluggedChilds.setdefault(PlugType, list()) |
473 # Check count |
473 # Check count |
474 if getattr(PlugClass, "PlugMaxCount", None) and len(PluggedChildsWithSameClass) >= PlugClass.PlugMaxCount: |
474 if getattr(PlugClass, "PlugMaxCount", None) and len(PluggedChildsWithSameClass) >= PlugClass.PlugMaxCount: |
475 raise Exception, "Max count (%d) reached for this plugin of type %s "%(PlugClass.PlugMaxCount, PlugType) |
475 raise Exception, _("Max count (%d) reached for this plugin of type %s ")%(PlugClass.PlugMaxCount, PlugType) |
476 |
476 |
477 # create the final class, derived of provided plugin and template |
477 # create the final class, derived of provided plugin and template |
478 class FinalPlugClass(PlugClass, PlugTemplate): |
478 class FinalPlugClass(PlugClass, PlugTemplate): |
479 """ |
479 """ |
480 Plugin class is derivated into FinalPlugClass before being instanciated |
480 Plugin class is derivated into FinalPlugClass before being instanciated |
553 basexmlfile = open(self.PluginBaseXmlFilePath(PlugName), 'r') |
553 basexmlfile = open(self.PluginBaseXmlFilePath(PlugName), 'r') |
554 basetree = minidom.parse(basexmlfile) |
554 basetree = minidom.parse(basexmlfile) |
555 self.MandatoryParams[1].loadXMLTree(basetree.childNodes[0]) |
555 self.MandatoryParams[1].loadXMLTree(basetree.childNodes[0]) |
556 basexmlfile.close() |
556 basexmlfile.close() |
557 except Exception, exc: |
557 except Exception, exc: |
558 self.logger.write_error("Couldn't load plugin base parameters %s :\n %s" % (PlugName, str(exc))) |
558 self.logger.write_error(_("Couldn't load plugin base parameters %s :\n %s") % (PlugName, str(exc))) |
559 self.logger.write_error(traceback.format_exc()) |
559 self.logger.write_error(traceback.format_exc()) |
560 |
560 |
561 # Get the xml tree |
561 # Get the xml tree |
562 if self.PlugParams: |
562 if self.PlugParams: |
563 try: |
563 try: |
564 xmlfile = open(self.PluginXmlFilePath(PlugName), 'r') |
564 xmlfile = open(self.PluginXmlFilePath(PlugName), 'r') |
565 tree = minidom.parse(xmlfile) |
565 tree = minidom.parse(xmlfile) |
566 self.PlugParams[1].loadXMLTree(tree.childNodes[0]) |
566 self.PlugParams[1].loadXMLTree(tree.childNodes[0]) |
567 xmlfile.close() |
567 xmlfile.close() |
568 except Exception, exc: |
568 except Exception, exc: |
569 self.logger.write_error("Couldn't load plugin parameters %s :\n %s" % (PlugName, str(exc))) |
569 self.logger.write_error(_("Couldn't load plugin parameters %s :\n %s") % (PlugName, str(exc))) |
570 self.logger.write_error(traceback.format_exc()) |
570 self.logger.write_error(traceback.format_exc()) |
571 |
571 |
572 def LoadChilds(self): |
572 def LoadChilds(self): |
573 # Iterate over all PlugName@PlugType in plugin directory, and try to open them |
573 # Iterate over all PlugName@PlugType in plugin directory, and try to open them |
574 for PlugDir in os.listdir(self.PlugPath()): |
574 for PlugDir in os.listdir(self.PlugPath()): |
926 """ |
926 """ |
927 |
927 |
928 # Update PLCOpenEditor Plugin Block types before generate ST code |
928 # Update PLCOpenEditor Plugin Block types before generate ST code |
929 self.RefreshPluginsBlockLists() |
929 self.RefreshPluginsBlockLists() |
930 |
930 |
931 self.logger.write("Generating SoftPLC IEC-61131 ST/IL/SFC code...\n") |
931 self.logger.write(_("Generating SoftPLC IEC-61131 ST/IL/SFC code...\n")) |
932 buildpath = self._getBuildPath() |
932 buildpath = self._getBuildPath() |
933 # ask PLCOpenEditor controller to write ST/IL/SFC code file |
933 # ask PLCOpenEditor controller to write ST/IL/SFC code file |
934 program, errors, warnings = self.GenerateProgram(self._getIECgeneratedcodepath()) |
934 program, errors, warnings = self.GenerateProgram(self._getIECgeneratedcodepath()) |
935 if len(warnings) > 0: |
935 if len(warnings) > 0: |
936 self.logger.write_warning("Warnings in ST/IL/SFC code generator :\n") |
936 self.logger.write_warning(_("Warnings in ST/IL/SFC code generator :\n")) |
937 for warning in warnings: |
937 for warning in warnings: |
938 self.logger.write_warning("%s\n"%warning) |
938 self.logger.write_warning("%s\n"%warning) |
939 if len(errors) > 0: |
939 if len(errors) > 0: |
940 # Failed ! |
940 # Failed ! |
941 self.logger.write_error("Error in ST/IL/SFC code generator :\n%s\n"%errors[0]) |
941 self.logger.write_error(_("Error in ST/IL/SFC code generator :\n%s\n")%errors[0]) |
942 return False |
942 return False |
943 plc_file = open(self._getIECcodepath(), "w") |
943 plc_file = open(self._getIECcodepath(), "w") |
944 if getattr(self, "PluggedChilds", None) is not None: |
944 if getattr(self, "PluggedChilds", None) is not None: |
945 # Add ST Library from plugins |
945 # Add ST Library from plugins |
946 plc_file.write(self.STLibraryFactory()) |
946 plc_file.write(self.STLibraryFactory()) |
997 last_section = None # only write section once |
997 last_section = None # only write section once |
998 self.logger.write_warning("%04d: %s" % (i, line)) |
998 self.logger.write_warning("%04d: %s" % (i, line)) |
999 |
999 |
1000 f.close() |
1000 f.close() |
1001 |
1001 |
1002 self.logger.write_error("Error : IEC to C compiler returned %d\n"%status) |
1002 self.logger.write_error(_("Error : IEC to C compiler returned %d\n")%status) |
1003 return False |
1003 return False |
1004 |
1004 |
1005 # Now extract C files of stdout |
1005 # Now extract C files of stdout |
1006 C_files = [ fname for fname in result.splitlines() if fname[-2:]==".c" or fname[-2:]==".C" ] |
1006 C_files = [ fname for fname in result.splitlines() if fname[-2:]==".c" or fname[-2:]==".C" ] |
1007 # remove those that are not to be compiled because included by others |
1007 # remove those that are not to be compiled because included by others |
1008 C_files.remove("POUS.c") |
1008 C_files.remove("POUS.c") |
1009 if not C_files: |
1009 if not C_files: |
1010 self.logger.write_error("Error : At least one configuration and one ressource must be declared in PLC !\n") |
1010 self.logger.write_error(_("Error : At least one configuration and one ressource must be declared in PLC !\n")) |
1011 return False |
1011 return False |
1012 # transform those base names to full names with path |
1012 # transform those base names to full names with path |
1013 C_files = map(lambda filename:os.path.join(buildpath, filename), C_files) |
1013 C_files = map(lambda filename:os.path.join(buildpath, filename), C_files) |
1014 self.logger.write("Extracting Located Variables...\n") |
1014 self.logger.write(_("Extracting Located Variables...\n")) |
1015 # Keep track of generated located variables for later use by self._Generate_C |
1015 # Keep track of generated located variables for later use by self._Generate_C |
1016 self.PLCGeneratedLocatedVars = self.GetLocations() |
1016 self.PLCGeneratedLocatedVars = self.GetLocations() |
1017 # Keep track of generated C files for later use by self.PlugGenerate_C |
1017 # Keep track of generated C files for later use by self.PlugGenerate_C |
1018 self.PLCGeneratedCFiles = C_files |
1018 self.PLCGeneratedCFiles = C_files |
1019 # compute CFLAGS for plc |
1019 # compute CFLAGS for plc |
1268 os.mkdir(buildpath) |
1268 os.mkdir(buildpath) |
1269 # There is something to clean |
1269 # There is something to clean |
1270 self.EnableMethod("_Clean", True) |
1270 self.EnableMethod("_Clean", True) |
1271 |
1271 |
1272 self.logger.flush() |
1272 self.logger.flush() |
1273 self.logger.write("Start build in %s\n" % buildpath) |
1273 self.logger.write(_("Start build in %s\n") % buildpath) |
1274 |
1274 |
1275 # Generate SoftPLC IEC code |
1275 # Generate SoftPLC IEC code |
1276 IECGenRes = self._Generate_SoftPLC() |
1276 IECGenRes = self._Generate_SoftPLC() |
1277 self.ShowMethod("_showIECcode", True) |
1277 self.ShowMethod("_showIECcode", True) |
1278 |
1278 |
1279 # If IEC code gen fail, bail out. |
1279 # If IEC code gen fail, bail out. |
1280 if not IECGenRes: |
1280 if not IECGenRes: |
1281 self.logger.write_error("IEC-61131-3 code generation failed !\n") |
1281 self.logger.write_error(_("IEC-61131-3 code generation failed !\n")) |
1282 return False |
1282 return False |
1283 |
1283 |
1284 # Reset variable and program list that are parsed from |
1284 # Reset variable and program list that are parsed from |
1285 # CSV file generated by IEC2C compiler. |
1285 # CSV file generated by IEC2C compiler. |
1286 self.ResetIECProgramsAndVariables() |
1286 self.ResetIECProgramsAndVariables() |
1287 |
1287 |
1288 # Generate C code and compilation params from plugin hierarchy |
1288 # Generate C code and compilation params from plugin hierarchy |
1289 self.logger.write("Generating plugins C code\n") |
1289 self.logger.write(_("Generating plugins C code\n")) |
1290 try: |
1290 try: |
1291 self.LocationCFilesAndCFLAGS, self.LDFLAGS, ExtraFiles = self._Generate_C( |
1291 self.LocationCFilesAndCFLAGS, self.LDFLAGS, ExtraFiles = self._Generate_C( |
1292 buildpath, |
1292 buildpath, |
1293 self.PLCGeneratedLocatedVars) |
1293 self.PLCGeneratedLocatedVars) |
1294 except Exception, exc: |
1294 except Exception, exc: |
1295 self.logger.write_error("Plugins code generation failed !\n") |
1295 self.logger.write_error(_("Plugins code generation failed !\n")) |
1296 self.logger.write_error(traceback.format_exc()) |
1296 self.logger.write_error(traceback.format_exc()) |
1297 return False |
1297 return False |
1298 |
1298 |
1299 # Get temprary directory path |
1299 # Get temporary directory path |
1300 extrafilespath = self._getExtraFilesPath() |
1300 extrafilespath = self._getExtraFilesPath() |
1301 # Remove old directory |
1301 # Remove old directory |
1302 if os.path.exists(extrafilespath): |
1302 if os.path.exists(extrafilespath): |
1303 shutil.rmtree(extrafilespath) |
1303 shutil.rmtree(extrafilespath) |
1304 # Recreate directory |
1304 # Recreate directory |
1327 code_path = os.path.join(buildpath,filename) |
1327 code_path = os.path.join(buildpath,filename) |
1328 open(code_path, "w").write(code) |
1328 open(code_path, "w").write(code) |
1329 # Insert this file as first file to be compiled at root plugin |
1329 # Insert this file as first file to be compiled at root plugin |
1330 self.LocationCFilesAndCFLAGS[0][1].insert(0,(code_path, self.plcCFLAGS)) |
1330 self.LocationCFilesAndCFLAGS[0][1].insert(0,(code_path, self.plcCFLAGS)) |
1331 except Exception, exc: |
1331 except Exception, exc: |
1332 self.logger.write_error(name+" generation failed !\n") |
1332 self.logger.write_error(name+_(" generation failed !\n")) |
1333 self.logger.write_error(traceback.format_exc()) |
1333 self.logger.write_error(traceback.format_exc()) |
1334 return False |
1334 return False |
1335 |
1335 |
1336 self.logger.write("C code generated successfully.\n") |
1336 self.logger.write(_("C code generated successfully.\n")) |
1337 |
1337 |
1338 # Get current or fresh builder |
1338 # Get current or fresh builder |
1339 builder = self.GetBuilder() |
1339 builder = self.GetBuilder() |
1340 if builder is None: |
1340 if builder is None: |
1341 self.logger.write_error("Fatal : cannot get builder.\n") |
1341 self.logger.write_error(_("Fatal : cannot get builder.\n")) |
1342 return False |
1342 return False |
1343 |
1343 |
1344 # Build |
1344 # Build |
1345 try: |
1345 try: |
1346 if not builder.build() : |
1346 if not builder.build() : |
1347 self.logger.write_error("C Build failed.\n") |
1347 self.logger.write_error(_("C Build failed.\n")) |
1348 return False |
1348 return False |
1349 except Exception, exc: |
1349 except Exception, exc: |
1350 self.logger.write_error("C Build crashed !\n") |
1350 self.logger.write_error(_("C Build crashed !\n")) |
1351 self.logger.write_error(traceback.format_exc()) |
1351 self.logger.write_error(traceback.format_exc()) |
1352 return False |
1352 return False |
1353 |
1353 |
1354 # Update GUI status about need for transfer |
1354 # Update GUI status about need for transfer |
1355 self.CompareLocalAndRemotePLC() |
1355 self.CompareLocalAndRemotePLC() |
1444 # TODO : use explicit status instead of boolean |
1444 # TODO : use explicit status instead of boolean |
1445 if self._connector is not None: |
1445 if self._connector is not None: |
1446 status = self._connector.GetPLCstatus() |
1446 status = self._connector.GetPLCstatus() |
1447 else: |
1447 else: |
1448 status = "Disconnected" |
1448 status = "Disconnected" |
|
1449 _ = lambda x : x |
1449 for args in { |
1450 for args in { |
1450 "Started":[("_Run", False), |
1451 _("Started"): [("_Run", False), |
1451 ("_Debug", False), |
1452 ("_Debug", False), |
1452 ("_Stop", True)], |
1453 ("_Stop", True)], |
1453 "Stopped":[("_Run", True), |
1454 _("Stopped"): [("_Run", True), |
1454 ("_Debug", True), |
1455 ("_Debug", True), |
1455 ("_Stop", False)], |
1456 ("_Stop", False)], |
1456 "Empty": [("_Run", False), |
1457 _("Empty"): [("_Run", False), |
1457 ("_Debug", False), |
1458 ("_Debug", False), |
1458 ("_Stop", False)], |
1459 ("_Stop", False)], |
1459 "Dirty": [("_Run", True), |
1460 _("Dirty"): [("_Run", True), |
1460 ("_Debug", True), |
1461 ("_Debug", True), |
1461 ("_Stop", False)], |
1462 ("_Stop", False)], |
1462 "Broken": [("_Run", True), |
1463 _("Broken"): [("_Run", True), |
1463 ("_Debug", True), |
1464 ("_Debug", True), |
1464 ("_Stop", False)], |
1465 ("_Stop", False)], |
1465 "Disconnected": [("_Run", False), |
1466 _("Disconnected"):[("_Run", False), |
1466 ("_Debug", False), |
1467 ("_Debug", False), |
1467 ("_Stop", False), |
1468 ("_Stop", False), |
1468 ("_Transfer", False), |
1469 ("_Transfer", False), |
1469 ("_Connect", True), |
1470 ("_Connect", True), |
1470 ("_Disconnect", False)], |
1471 ("_Disconnect", False)], |
1471 }.get(status,[]): |
1472 }.get(status,[]): |
1472 self.ShowMethod(*args) |
1473 self.ShowMethod(*args) |
1473 return status |
1474 return status |
1474 |
1475 |
1475 def PullPLCStatusProc(self, event): |
1476 def PullPLCStatusProc(self, event): |
1476 if self._connector is None: |
1477 if self._connector is None: |
1477 self.StatusTimer.Stop() |
1478 self.StatusTimer.Stop() |
1478 current_status = self.UpdateMethodsFromPLCStatus() |
1479 current_status = self.UpdateMethodsFromPLCStatus() |
1479 if current_status != self.previous_plcstate: |
1480 if current_status != self.previous_plcstate: |
1480 self.previous_plcstate = current_status |
1481 self.previous_plcstate = current_status |
1481 self.StatusPrint.get(current_status, self.logger.write)("PLC is %s\n"%current_status) |
1482 if current_status is not None: |
|
1483 status = _(current_status) |
|
1484 else: |
|
1485 status = "" |
|
1486 self.StatusPrint.get(current_status, self.logger.write)(_("PLC is %s\n")%status) |
1482 self.AppFrame.RefreshAll() |
1487 self.AppFrame.RefreshAll() |
1483 |
1488 |
1484 def _Run(self): |
1489 def _Run(self): |
1485 """ |
1490 """ |
1486 Start PLC |
1491 Start PLC |
1602 if value is not None: |
1607 if value is not None: |
1603 self.CallWeakcallables(IECPath, "NewValue", debug_tick, value) |
1608 self.CallWeakcallables(IECPath, "NewValue", debug_tick, value) |
1604 self.CallWeakcallables("__tick__", "NewDataAvailable") |
1609 self.CallWeakcallables("__tick__", "NewDataAvailable") |
1605 elif debug_vars is not None: |
1610 elif debug_vars is not None: |
1606 wx.CallAfter(self.logger.write_warning, |
1611 wx.CallAfter(self.logger.write_warning, |
1607 "Debug data not coherent %d != %d\n"%(len(debug_vars), len(self.TracedIECPath))) |
1612 _("Debug data not coherent %d != %d\n")%(len(debug_vars), len(self.TracedIECPath))) |
1608 elif debug_tick == -1: |
1613 elif debug_tick == -1: |
1609 #wx.CallAfter(self.logger.write, "Debugger unavailable\n") |
1614 #wx.CallAfter(self.logger.write, "Debugger unavailable\n") |
1610 pass |
1615 pass |
1611 else: |
1616 else: |
1612 wx.CallAfter(self.logger.write, "Debugger disabled\n") |
1617 wx.CallAfter(self.logger.write, _("Debugger disabled\n")) |
1613 self.debug_break = True |
1618 self.debug_break = True |
1614 self.IECdebug_lock.release() |
1619 self.IECdebug_lock.release() |
1615 |
1620 |
1616 def KillDebugThread(self): |
1621 def KillDebugThread(self): |
1617 self.debug_break = True |
1622 self.debug_break = True |
1618 self.DebugThread.join(timeout=1) |
1623 self.DebugThread.join(timeout=1) |
1619 if self.DebugThread.isAlive(): |
1624 if self.DebugThread.isAlive(): |
1620 self.logger.write_warning("Debug Thread couldn't be killed") |
1625 self.logger.write_warning(_("Debug Thread couldn't be killed")) |
1621 self.DebugThread = None |
1626 self.DebugThread = None |
1622 |
1627 |
1623 def _Debug(self): |
1628 def _Debug(self): |
1624 """ |
1629 """ |
1625 Start PLC (Debug Mode) |
1630 Start PLC (Debug Mode) |
1626 """ |
1631 """ |
1627 if self.GetIECProgramsAndVariables(): |
1632 if self.GetIECProgramsAndVariables(): |
1628 self._connector.StartPLC(debug=True) |
1633 self._connector.StartPLC(debug=True) |
1629 self.logger.write("Starting PLC (debug mode)\n") |
1634 self.logger.write(_("Starting PLC (debug mode)\n")) |
1630 if self.PLCDebug is None: |
1635 if self.PLCDebug is None: |
1631 self.RefreshPluginsBlockLists() |
1636 self.RefreshPluginsBlockLists() |
1632 def _onclose(): |
1637 def _onclose(): |
1633 self.PLCDebug = None |
1638 self.PLCDebug = None |
1634 self.PLCDebug = PLCOpenEditor(self.AppFrame, self, debug=True) |
1639 self.PLCDebug = PLCOpenEditor(self.AppFrame, self, debug=True) |
1700 |
1705 |
1701 # Get connector from uri |
1706 # Get connector from uri |
1702 try: |
1707 try: |
1703 self._connector = connectors.ConnectorFactory(uri, self) |
1708 self._connector = connectors.ConnectorFactory(uri, self) |
1704 except Exception, msg: |
1709 except Exception, msg: |
1705 self.logger.write_error("Exception while connecting %s!\n"%uri) |
1710 self.logger.write_error(_("Exception while connecting %s!\n")%uri) |
1706 self.logger.write_error(traceback.format_exc()) |
1711 self.logger.write_error(traceback.format_exc()) |
1707 |
1712 |
1708 # Did connection success ? |
1713 # Did connection success ? |
1709 if self._connector is None: |
1714 if self._connector is None: |
1710 # Oups. |
1715 # Oups. |
1711 self.logger.write_error("Connection failed to %s!\n"%uri) |
1716 self.logger.write_error(_("Connection failed to %s!\n")%uri) |
1712 else: |
1717 else: |
1713 self.ShowMethod("_Connect", False) |
1718 self.ShowMethod("_Connect", False) |
1714 self.ShowMethod("_Disconnect", True) |
1719 self.ShowMethod("_Disconnect", True) |
1715 self.ShowMethod("_Transfer", True) |
1720 self.ShowMethod("_Transfer", True) |
1716 |
1721 |
1717 self.CompareLocalAndRemotePLC() |
1722 self.CompareLocalAndRemotePLC() |
1718 |
1723 |
1719 # Init with actual PLC status and print it |
1724 # Init with actual PLC status and print it |
1720 self.previous_plcstate = self.UpdateMethodsFromPLCStatus() |
1725 self.previous_plcstate = self.UpdateMethodsFromPLCStatus() |
1721 self.logger.write("PLC is %s\n"%self.previous_plcstate) |
1726 if self.previous_plcstate is not None: |
|
1727 status = _(self.previous_plcstate) |
|
1728 else: |
|
1729 status = "" |
|
1730 self.logger.write(_("PLC is %s\n")%status) |
1722 |
1731 |
1723 # Start the status Timer |
1732 # Start the status Timer |
1724 self.StatusTimer.Start(milliseconds=500, oneShot=False) |
1733 self.StatusTimer.Start(milliseconds=500, oneShot=False) |
1725 |
1734 |
1726 def CompareLocalAndRemotePLC(self): |
1735 def CompareLocalAndRemotePLC(self): |
1730 MD5 = self.GetLastBuildMD5() |
1739 MD5 = self.GetLastBuildMD5() |
1731 # Check remote target PLC correspondance to that md5 |
1740 # Check remote target PLC correspondance to that md5 |
1732 if MD5 is not None: |
1741 if MD5 is not None: |
1733 if not self._connector.MatchMD5(MD5): |
1742 if not self._connector.MatchMD5(MD5): |
1734 self.logger.write_warning( |
1743 self.logger.write_warning( |
1735 "Latest build do not match with target, please transfer.\n") |
1744 _("Latest build do not match with target, please transfer.\n")) |
1736 self.EnableMethod("_Transfer", True) |
1745 self.EnableMethod("_Transfer", True) |
1737 else: |
1746 else: |
1738 self.logger.write( |
1747 self.logger.write( |
1739 "Latest build match target, no transfer needed.\n") |
1748 _("Latest build match target, no transfer needed.\n")) |
1740 self.EnableMethod("_Transfer", True) |
1749 self.EnableMethod("_Transfer", True) |
1741 #self.EnableMethod("_Transfer", False) |
1750 #self.EnableMethod("_Transfer", False) |
1742 else: |
1751 else: |
1743 self.logger.write_warning( |
1752 self.logger.write_warning( |
1744 "Cannot compare latest build to target. Please build.\n") |
1753 _("Cannot compare latest build to target. Please build.\n")) |
1745 self.EnableMethod("_Transfer", False) |
1754 self.EnableMethod("_Transfer", False) |
1746 |
1755 |
1747 |
1756 |
1748 def _Disconnect(self): |
1757 def _Disconnect(self): |
1749 self._connector = None |
1758 self._connector = None |
1780 if self.PLCDebug is not None: |
1789 if self.PLCDebug is not None: |
1781 self.PLCDebug.Close() |
1790 self.PLCDebug.Close() |
1782 self.PLCDebug = None |
1791 self.PLCDebug = None |
1783 self.UnsubscribeAllDebugIECVariable() |
1792 self.UnsubscribeAllDebugIECVariable() |
1784 self.ProgramTransferred() |
1793 self.ProgramTransferred() |
1785 self.logger.write("Transfer completed successfully.\n") |
1794 self.logger.write(_("Transfer completed successfully.\n")) |
1786 else: |
1795 else: |
1787 self.logger.write_error("Transfer failed\n") |
1796 self.logger.write_error(_("Transfer failed\n")) |
1788 else: |
1797 else: |
1789 self.logger.write_error("No PLC to transfer (did build success ?)\n") |
1798 self.logger.write_error(_("No PLC to transfer (did build success ?)\n")) |
1790 self.UpdateMethodsFromPLCStatus() |
1799 self.UpdateMethodsFromPLCStatus() |
1791 |
1800 |
1792 PluginMethods = [ |
1801 PluginMethods = [ |
1793 {"bitmap" : opjimg("editPLC"), |
1802 {"bitmap" : opjimg("editPLC"), |
1794 "name" : "Edit PLC", |
1803 "name" : _("Edit PLC"), |
1795 "tooltip" : "Edit PLC program with PLCOpenEditor", |
1804 "tooltip" : _("Edit PLC program with PLCOpenEditor"), |
1796 "method" : "_EditPLC"}, |
1805 "method" : "_EditPLC"}, |
1797 {"bitmap" : opjimg("Build"), |
1806 {"bitmap" : opjimg("Build"), |
1798 "name" : "Build", |
1807 "name" : _("Build"), |
1799 "tooltip" : "Build project into build folder", |
1808 "tooltip" : _("Build project into build folder"), |
1800 "method" : "_build"}, |
1809 "method" : "_build"}, |
1801 {"bitmap" : opjimg("Clean"), |
1810 {"bitmap" : opjimg("Clean"), |
1802 "name" : "Clean", |
1811 "name" : _("Clean"), |
1803 "enabled" : False, |
1812 "enabled" : False, |
1804 "tooltip" : "Clean project build folder", |
1813 "tooltip" : _("Clean project build folder"), |
1805 "method" : "_Clean"}, |
1814 "method" : "_Clean"}, |
1806 {"bitmap" : opjimg("Run"), |
1815 {"bitmap" : opjimg("Run"), |
1807 "name" : "Run", |
1816 "name" : _("Run"), |
1808 "shown" : False, |
1817 "shown" : False, |
1809 "tooltip" : "Start PLC", |
1818 "tooltip" : _("Start PLC"), |
1810 "method" : "_Run"}, |
1819 "method" : "_Run"}, |
1811 {"bitmap" : opjimg("Debug"), |
1820 {"bitmap" : opjimg("Debug"), |
1812 "name" : "Debug", |
1821 "name" : _("Debug"), |
1813 "shown" : False, |
1822 "shown" : False, |
1814 "tooltip" : "Start PLC (debug mode)", |
1823 "tooltip" : _("Start PLC (debug mode)"), |
1815 "method" : "_Debug"}, |
1824 "method" : "_Debug"}, |
1816 # {"bitmap" : opjimg("Debug"), |
1825 # {"bitmap" : opjimg("Debug"), |
1817 # "name" : "Do_Test_Debug", |
1826 # "name" : "Do_Test_Debug", |
1818 # "tooltip" : "Test debug mode)", |
1827 # "tooltip" : "Test debug mode)", |
1819 # "method" : "_Do_Test_Debug"}, |
1828 # "method" : "_Do_Test_Debug"}, |
1820 {"bitmap" : opjimg("Stop"), |
1829 {"bitmap" : opjimg("Stop"), |
1821 "name" : "Stop", |
1830 "name" : _("Stop"), |
1822 "shown" : False, |
1831 "shown" : False, |
1823 "tooltip" : "Stop Running PLC", |
1832 "tooltip" : _("Stop Running PLC"), |
1824 "method" : "_Stop"}, |
1833 "method" : "_Stop"}, |
1825 {"bitmap" : opjimg("Connect"), |
1834 {"bitmap" : opjimg("Connect"), |
1826 "name" : "Connect", |
1835 "name" : _("Connect"), |
1827 "tooltip" : "Connect to the target PLC", |
1836 "tooltip" : _("Connect to the target PLC"), |
1828 "method" : "_Connect"}, |
1837 "method" : "_Connect"}, |
1829 {"bitmap" : opjimg("Transfer"), |
1838 {"bitmap" : opjimg("Transfer"), |
1830 "name" : "Transfer", |
1839 "name" : _("Transfer"), |
1831 "shown" : False, |
1840 "shown" : False, |
1832 "tooltip" : "Transfer PLC", |
1841 "tooltip" : _("Transfer PLC"), |
1833 "method" : "_Transfer"}, |
1842 "method" : "_Transfer"}, |
1834 {"bitmap" : opjimg("Disconnect"), |
1843 {"bitmap" : opjimg("Disconnect"), |
1835 "name" : "Disconnect", |
1844 "name" : _("Disconnect"), |
1836 "shown" : False, |
1845 "shown" : False, |
1837 "tooltip" : "Disconnect from PLC", |
1846 "tooltip" : _("Disconnect from PLC"), |
1838 "method" : "_Disconnect"}, |
1847 "method" : "_Disconnect"}, |
1839 {"bitmap" : opjimg("ShowIECcode"), |
1848 {"bitmap" : opjimg("ShowIECcode"), |
1840 "name" : "Show code", |
1849 "name" : _("Show code"), |
1841 "shown" : False, |
1850 "shown" : False, |
1842 "tooltip" : "Show IEC code generated by PLCGenerator", |
1851 "tooltip" : _("Show IEC code generated by PLCGenerator"), |
1843 "method" : "_showIECcode"}, |
1852 "method" : "_showIECcode"}, |
1844 {"bitmap" : opjimg("editIECrawcode"), |
1853 {"bitmap" : opjimg("editIECrawcode"), |
1845 "name" : "Raw IEC code", |
1854 "name" : _("Raw IEC code"), |
1846 "tooltip" : "Edit raw IEC code added to code generated by PLCGenerator", |
1855 "tooltip" : _("Edit raw IEC code added to code generated by PLCGenerator"), |
1847 "method" : "_editIECrawcode"}, |
1856 "method" : "_editIECrawcode"}, |
1848 {"bitmap" : opjimg("editPYTHONcode"), |
1857 {"bitmap" : opjimg("editPYTHONcode"), |
1849 "name" : "Python code", |
1858 "name" : "Python code", |
1850 "tooltip" : "Write Python runtime code, for use with python_eval FBs", |
1859 "tooltip" : "Write Python runtime code, for use with python_eval FBs", |
1851 "method" : "_editPYTHONcode"}, |
1860 "method" : "_editPYTHONcode"}, |