656 if wx.Platform == '__WXMSW__': |
656 if wx.Platform == '__WXMSW__': |
657 exe_ext=".exe" |
657 exe_ext=".exe" |
658 else: |
658 else: |
659 exe_ext="" |
659 exe_ext="" |
660 |
660 |
661 iec2c_path = os.path.join(base_folder, "matiec", "iec2c"+exe_ext) |
|
662 ieclib_path = os.path.join(base_folder, "matiec", "lib") |
|
663 |
|
664 # import for project creation timestamping |
661 # import for project creation timestamping |
665 from threading import Timer, Lock, Thread, Semaphore |
662 from threading import Timer, Lock, Thread, Semaphore |
666 from time import localtime |
663 from time import localtime |
667 from datetime import datetime |
664 from datetime import datetime |
668 # import necessary stuff from PLCOpenEditor |
665 # import necessary stuff from PLCOpenEditor |
745 self.SetAppFrame(frame, logger) |
742 self.SetAppFrame(frame, logger) |
746 self._builder = None |
743 self._builder = None |
747 self._connector = None |
744 self._connector = None |
748 self.Deleting = False |
745 self.Deleting = False |
749 |
746 |
|
747 self.iec2c_path = os.path.join(base_folder, "matiec", "iec2c"+exe_ext) |
|
748 self.ieclib_path = os.path.join(base_folder, "matiec", "lib") |
|
749 |
750 # Setup debug information |
750 # Setup debug information |
751 self.IECdebug_datas = {} |
751 self.IECdebug_datas = {} |
752 self.IECdebug_lock = Lock() |
752 self.IECdebug_lock = Lock() |
753 |
753 |
754 self.DebugTimer=None |
754 self.DebugTimer=None |
805 return self.ChangesToSave or not self.ProjectIsSaved() |
805 return self.ChangesToSave or not self.ProjectIsSaved() |
806 |
806 |
807 def GetPlugRoot(self): |
807 def GetPlugRoot(self): |
808 return self |
808 return self |
809 |
809 |
|
810 def GetIECLibPath(self): |
|
811 return self.ieclib_path |
|
812 |
|
813 def GetIEC2cPath(self): |
|
814 return self.iec2c_path |
|
815 |
810 def GetCurrentLocation(self): |
816 def GetCurrentLocation(self): |
811 return () |
817 return () |
812 |
818 |
813 def GetCurrentName(self): |
819 def GetCurrentName(self): |
814 return "" |
820 return "" |
1054 # Now compile IEC code into many C files |
1060 # Now compile IEC code into many C files |
1055 # files are listed to stdout, and errors to stderr. |
1061 # files are listed to stdout, and errors to stderr. |
1056 status, result, err_result = ProcessLogger( |
1062 status, result, err_result = ProcessLogger( |
1057 self.logger, |
1063 self.logger, |
1058 "\"%s\" -f -I \"%s\" -T \"%s\" \"%s\""%( |
1064 "\"%s\" -f -I \"%s\" -T \"%s\" \"%s\""%( |
1059 iec2c_path, |
1065 self.iec2c_path, |
1060 ieclib_path, |
1066 self.ieclib_path, |
1061 buildpath, |
1067 buildpath, |
1062 self._getIECcodepath()), |
1068 self._getIECcodepath()), |
1063 no_stdout=True, no_stderr=True).spin() |
1069 no_stdout=True, no_stderr=True).spin() |
1064 if status: |
1070 if status: |
1065 # Failed ! |
1071 # Failed ! |
1105 # Keep track of generated located variables for later use by self._Generate_C |
1111 # Keep track of generated located variables for later use by self._Generate_C |
1106 self.PLCGeneratedLocatedVars = self.GetLocations() |
1112 self.PLCGeneratedLocatedVars = self.GetLocations() |
1107 # Keep track of generated C files for later use by self.PlugGenerate_C |
1113 # Keep track of generated C files for later use by self.PlugGenerate_C |
1108 self.PLCGeneratedCFiles = C_files |
1114 self.PLCGeneratedCFiles = C_files |
1109 # compute CFLAGS for plc |
1115 # compute CFLAGS for plc |
1110 self.plcCFLAGS = "\"-I"+ieclib_path+"\"" |
1116 self.plcCFLAGS = "\"-I"+self.ieclib_path+"\"" |
1111 return True |
1117 return True |
1112 |
1118 |
1113 def GetBuilder(self): |
1119 def GetBuilder(self): |
1114 """ |
1120 """ |
1115 Return a Builder (compile C code into machine code) |
1121 Return a Builder (compile C code into machine code) |
1272 # Generate main, based on template |
1278 # Generate main, based on template |
1273 if self.BeremizRoot.getEnable_Plugins(): |
1279 if self.BeremizRoot.getEnable_Plugins(): |
1274 plc_main_code = targets.code("plc_common_main") % { |
1280 plc_main_code = targets.code("plc_common_main") % { |
1275 "calls_prototypes":"\n".join([( |
1281 "calls_prototypes":"\n".join([( |
1276 "int __init_%(s)s(int argc,char **argv);\n"+ |
1282 "int __init_%(s)s(int argc,char **argv);\n"+ |
1277 "void __cleanup_%(s)s();\n"+ |
1283 "void __cleanup_%(s)s(void);\n"+ |
1278 "void __retrieve_%(s)s();\n"+ |
1284 "void __retrieve_%(s)s(void);\n"+ |
1279 "void __publish_%(s)s();")%{'s':locstr} for locstr in locstrs]), |
1285 "void __publish_%(s)s(void);")%{'s':locstr} for locstr in locstrs]), |
1280 "retrieve_calls":"\n ".join([ |
1286 "retrieve_calls":"\n ".join([ |
1281 "__retrieve_%s();"%locstr for locstr in locstrs]), |
1287 "__retrieve_%s();"%locstr for locstr in locstrs]), |
1282 "publish_calls":"\n ".join([ #Call publish in reverse order |
1288 "publish_calls":"\n ".join([ #Call publish in reverse order |
1283 "__publish_%s();"%locstrs[i-1] for i in xrange(len(locstrs), 0, -1)]), |
1289 "__publish_%s();"%locstrs[i-1] for i in xrange(len(locstrs), 0, -1)]), |
1284 "init_calls":"\n ".join([ |
1290 "init_calls":"\n ".join([ |