equal
deleted
inserted
replaced
852 return os.path.join(self.PlugPath(), "raw_plc.st") |
852 return os.path.join(self.PlugPath(), "raw_plc.st") |
853 |
853 |
854 def _getPYTHONcodepath(self): |
854 def _getPYTHONcodepath(self): |
855 # define name for IEC raw code file |
855 # define name for IEC raw code file |
856 return os.path.join(self.PlugPath(), "runtime.py") |
856 return os.path.join(self.PlugPath(), "runtime.py") |
|
857 |
|
858 def _getWXGLADEpath(self): |
|
859 # define name for IEC raw code file |
|
860 return os.path.join(self.PlugPath(), "hmi.wxg") |
857 |
861 |
858 def GetLocations(self): |
862 def GetLocations(self): |
859 locations = [] |
863 locations = [] |
860 filepath = os.path.join(self._getBuildPath(),"LOCATED_VARIABLES.h") |
864 filepath = os.path.join(self._getBuildPath(),"LOCATED_VARIABLES.h") |
861 if os.path.isfile(filepath): |
865 if os.path.isfile(filepath): |
974 if builder is not None: |
978 if builder is not None: |
975 return builder.GetBinaryCodeMD5() |
979 return builder.GetBinaryCodeMD5() |
976 else: |
980 else: |
977 return None |
981 return None |
978 |
982 |
|
983 def launch_wxglade(self,options, wait=False): |
|
984 from wxglade import __file__ as fileName |
|
985 path = os.path.dirname(fileName) |
|
986 glade = os.path.join(path,'wxglade.py') |
|
987 mode = {False:os.P_NOWAIT, True:os.P_WAIT}[wait] |
|
988 print (mode,sys.executable,[sys.executable]+[glade]+options) |
|
989 os.spawnv(mode,sys.executable,[sys.executable]+[glade]+options) |
|
990 |
979 ####################################################################### |
991 ####################################################################### |
980 # |
992 # |
981 # C CODE GENERATION METHODS |
993 # C CODE GENERATION METHODS |
982 # |
994 # |
983 ####################################################################### |
995 ####################################################################### |
996 False) # do not expose retreive/publish calls |
1008 False) # do not expose retreive/publish calls |
997 |
1009 |
998 pyfile=self._getPYTHONcodepath() |
1010 pyfile=self._getPYTHONcodepath() |
999 if os.path.exists(pyfile): |
1011 if os.path.exists(pyfile): |
1000 res += (("runtime.py", file(pyfile,"rb")),) |
1012 res += (("runtime.py", file(pyfile,"rb")),) |
|
1013 wxgfile=self._getWXGLADEpath() |
|
1014 if os.path.exists(wxgfile): |
|
1015 hmipyfile=os.path.join(self._getBuildPath(),"hmi.py") |
|
1016 self.launch_wxglade(['-o', hmipyfile, '-g','python', wxgfile], wait=True) |
|
1017 res += (("hmi.py", file(hmipyfile,"rb")),) |
1001 |
1018 |
1002 return res |
1019 return res |
1003 |
1020 |
1004 |
1021 |
1005 def ResetIECProgramsAndVariables(self): |
1022 def ResetIECProgramsAndVariables(self): |
1100 """ |
1117 """ |
1101 self.GetIECProgramsAndVariables() |
1118 self.GetIECProgramsAndVariables() |
1102 |
1119 |
1103 python_eval_fb_list = [] |
1120 python_eval_fb_list = [] |
1104 for v in self._VariablesList : |
1121 for v in self._VariablesList : |
1105 if v["vartype"] == "FB" and v["type"] == "PYTHON_EVAL": |
1122 if v["vartype"] == "FB" and v["type"] in ["PYTHON_EVAL","PYTHON_POLL"]: |
1106 python_eval_fb_list.append(v) |
1123 python_eval_fb_list.append(v) |
1107 python_eval_fb_count = max(1, len(python_eval_fb_list)) |
1124 python_eval_fb_count = max(1, len(python_eval_fb_list)) |
1108 |
1125 |
1109 # prepare debug code |
1126 # prepare debug code |
1110 python_code = targets.code("plc_python") % { |
1127 python_code = targets.code("plc_python") % { |
1288 pyfile=self._getPYTHONcodepath() |
1305 pyfile=self._getPYTHONcodepath() |
1289 PYTHON_viewer.LoadSourceFile(pyfile) |
1306 PYTHON_viewer.LoadSourceFile(pyfile) |
1290 |
1307 |
1291 new_dialog.Show() |
1308 new_dialog.Show() |
1292 |
1309 |
|
1310 def _editWXGLADE(self): |
|
1311 wxg_filename = self._getWXGLADEpath() |
|
1312 if not os.path.exists(wxg_filename): |
|
1313 open(wxg_filename,"w").write("""<?xml version="1.0"?> |
|
1314 <application path="" name="" class="" option="0" language="python" top_window="frame_1" encoding="UTF-8" use_gettext="0" overwrite="0" use_new_namespace="1" for_version="2.8" is_template="0"> |
|
1315 <object class="HMIFrame" name="frame_1" base="EditFrame"> |
|
1316 <style>wxDEFAULT_FRAME_STYLE</style> |
|
1317 <title>frame_1</title> |
|
1318 </object> |
|
1319 </application> |
|
1320 """) |
|
1321 self.launch_wxglade([wxg_filename]) |
|
1322 |
1293 def _EditPLC(self): |
1323 def _EditPLC(self): |
1294 if self.PLCEditor is None: |
1324 if self.PLCEditor is None: |
1295 self.RefreshPluginsBlockLists() |
1325 self.RefreshPluginsBlockLists() |
1296 def _onclose(): |
1326 def _onclose(): |
1297 self.PLCEditor = None |
1327 self.PLCEditor = None |
1698 "method" : "_editIECrawcode"}, |
1728 "method" : "_editIECrawcode"}, |
1699 {"bitmap" : opjimg("editPYTHONcode"), |
1729 {"bitmap" : opjimg("editPYTHONcode"), |
1700 "name" : "Python code", |
1730 "name" : "Python code", |
1701 "tooltip" : "Write Python runtime code, for use with python_eval FBs", |
1731 "tooltip" : "Write Python runtime code, for use with python_eval FBs", |
1702 "method" : "_editPYTHONcode"}, |
1732 "method" : "_editPYTHONcode"}, |
|
1733 {"bitmap" : opjimg("editWXGLADE"), |
|
1734 "name" : "WXGLADE GUI", |
|
1735 "tooltip" : "Edit a WxWidgets GUI with WXGlade", |
|
1736 "method" : "_editWXGLADE"}, |
1703 ] |
1737 ] |