diff -r 2221e99d2f8f -r d0e6fc0701fb plugger.py --- a/plugger.py Wed Dec 24 00:02:12 2008 +0100 +++ b/plugger.py Tue Dec 30 22:43:48 2008 +0100 @@ -850,6 +850,10 @@ # define name for IEC raw code file return os.path.join(self.PlugPath(), "raw_plc.st") + def _getPYTHONcodepath(self): + # define name for IEC raw code file + return os.path.join(self.PlugPath(), "runtime.py") + def GetLocations(self): locations = [] filepath = os.path.join(self._getBuildPath(),"LOCATED_VARIABLES.h") @@ -984,7 +988,18 @@ @param locations: ignored @return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND """ - return [(C_file_name, self.plcCFLAGS) for C_file_name in self.PLCGeneratedCFiles ] , "", False + + res = ([(C_file_name, self.plcCFLAGS) + for C_file_name in self.PLCGeneratedCFiles ], + "", # no ldflags + False) # do not expose retreive/publish calls + + pyfile=self._getPYTHONcodepath() + if os.path.exists(pyfile): + res += (("runtime.py", file(pyfile,"rb")),) + + return res + def ResetIECProgramsAndVariables(self): """ @@ -1263,6 +1278,17 @@ new_dialog.Show() + def _editPYTHONcode(self): + from PythonSTC import PythonCodePanel + new_dialog = wx.Frame(self.AppFrame) + + PYTHON_viewer = PythonCodePanel(new_dialog, self.AppFrame) + #ST_viewer.Enable(False) + pyfile=self._getPYTHONcodepath() + PYTHON_viewer.LoadSourceFile(pyfile) + + new_dialog.Show() + def _EditPLC(self): if self.PLCEditor is None: self.RefreshPluginsBlockLists() @@ -1648,7 +1674,11 @@ "tooltip" : "Show IEC code generated by PLCGenerator", "method" : "_showIECcode"}, {"bitmap" : opjimg("editIECrawcode"), - "name" : "Append code", + "name" : "Raw IEC code", "tooltip" : "Edit raw IEC code added to code generated by PLCGenerator", "method" : "_editIECrawcode"}, + {"bitmap" : opjimg("editPYTHONcode"), + "name" : "Python code", + "tooltip" : "Write Python runtime code, for use with python_eval FBs", + "method" : "_editPYTHONcode"}, ]