equal
deleted
inserted
replaced
129 path = self.findObject(paths, lambda p: os.path.isfile(os.path.join(p, "ieclib.txt"))) |
129 path = self.findObject(paths, lambda p: os.path.isfile(os.path.join(p, "ieclib.txt"))) |
130 return path |
130 return path |
131 |
131 |
132 def findLibCPath(self): |
132 def findLibCPath(self): |
133 path = None |
133 path = None |
134 paths = [ |
134 if self.ieclib_path is not None: |
135 os.path.join(self.ieclib_path, "C"), |
135 paths = [ |
136 self.ieclib_path] |
136 os.path.join(self.ieclib_path, "C"), |
137 path = self.findObject(paths, lambda p: os.path.isfile(os.path.join(p, "iec_types.h"))) |
137 self.ieclib_path] |
|
138 path = self.findObject( |
|
139 paths, |
|
140 lambda p: os.path.isfile(os.path.join(p, "iec_types.h"))) |
138 return path |
141 return path |
139 |
142 |
140 def findSupportedOptions(self): |
143 def findSupportedOptions(self): |
141 buildcmd = "\"%s\" -h" % (self.getCmd()) |
144 buildcmd = "\"%s\" -h" % (self.getCmd()) |
142 options = ["-f", "-l", "-p"] |
145 options = ["-f", "-l", "-p"] |
170 |
173 |
171 def getLibCPath(self): |
174 def getLibCPath(self): |
172 if self.ieclib_c_path is None: |
175 if self.ieclib_c_path is None: |
173 self.ieclib_c_path = self.findLibCPath() |
176 self.ieclib_c_path = self.findLibCPath() |
174 return self.ieclib_c_path |
177 return self.ieclib_c_path |
175 |
|
176 |
|
177 iec2c_cfg = Iec2CSettings() |
|
178 |
178 |
179 |
179 |
180 class ProjectController(ConfigTreeNode, PLCControler): |
180 class ProjectController(ConfigTreeNode, PLCControler): |
181 """ |
181 """ |
182 This class define Root object of the confnode tree. |
182 This class define Root object of the confnode tree. |
218 </xsd:complexType> |
218 </xsd:complexType> |
219 </xsd:element> |
219 </xsd:element> |
220 </xsd:schema> |
220 </xsd:schema> |
221 """ |
221 """ |
222 EditorType = ProjectNodeEditor |
222 EditorType = ProjectNodeEditor |
|
223 iec2c_cfg = None |
223 |
224 |
224 def __init__(self, frame, logger): |
225 def __init__(self, frame, logger): |
225 PLCControler.__init__(self) |
226 PLCControler.__init__(self) |
|
227 |
|
228 if ProjectController.iec2c_cfg is None: |
|
229 ProjectController.iec2c_cfg = Iec2CSettings() |
226 |
230 |
227 self.MandatoryParams = None |
231 self.MandatoryParams = None |
228 self._builder = None |
232 self._builder = None |
229 self._connector = None |
233 self._connector = None |
230 self.DispatchDebugValuesTimer = None |
234 self.DispatchDebugValuesTimer = None |
317 |
321 |
318 def GetCTRoot(self): |
322 def GetCTRoot(self): |
319 return self |
323 return self |
320 |
324 |
321 def GetIECLibPath(self): |
325 def GetIECLibPath(self): |
322 return iec2c_cfg.getLibCPath() |
326 return self.iec2c_cfg.getLibCPath() |
323 |
327 |
324 def GetIEC2cPath(self): |
328 def GetIEC2cPath(self): |
325 return iec2c_cfg.getCmd() |
329 return self.iec2c_cfg.getCmd() |
326 |
330 |
327 def GetCurrentLocation(self): |
331 def GetCurrentLocation(self): |
328 return () |
332 return () |
329 |
333 |
330 def GetCurrentName(self): |
334 def GetCurrentName(self): |
740 plc_file.write(open(self._getIECgeneratedcodepath(), "r").read()) |
744 plc_file.write(open(self._getIECgeneratedcodepath(), "r").read()) |
741 plc_file.close() |
745 plc_file.close() |
742 return True |
746 return True |
743 |
747 |
744 def _Compile_ST_to_SoftPLC(self): |
748 def _Compile_ST_to_SoftPLC(self): |
|
749 iec2c_libpath = self.iec2c_cfg.getLibPath() |
|
750 if iec2c_libpath is None: |
|
751 self.logger.write_error(_("matiec installation is not found\n")) |
|
752 return False |
|
753 |
745 self.logger.write(_("Compiling IEC Program into C code...\n")) |
754 self.logger.write(_("Compiling IEC Program into C code...\n")) |
746 buildpath = self._getBuildPath() |
755 buildpath = self._getBuildPath() |
747 buildcmd = "\"%s\" %s -I \"%s\" -T \"%s\" \"%s\"" % ( |
756 buildcmd = "\"%s\" %s -I \"%s\" -T \"%s\" \"%s\"" % ( |
748 iec2c_cfg.getCmd(), |
757 self.iec2c_cfg.getCmd(), |
749 iec2c_cfg.getOptions(), |
758 self.iec2c_cfg.getOptions(), |
750 iec2c_cfg.getLibPath(), |
759 iec2c_libpath, |
751 buildpath, |
760 buildpath, |
752 self._getIECcodepath()) |
761 self._getIECcodepath()) |
753 |
762 |
754 try: |
763 try: |
755 # Invoke compiler. Output files are listed to stdout, errors to stderr |
764 # Invoke compiler. Output files are listed to stdout, errors to stderr |
816 # Keep track of generated located variables for later use by self._Generate_C |
825 # Keep track of generated located variables for later use by self._Generate_C |
817 self.PLCGeneratedLocatedVars = self.GetLocations() |
826 self.PLCGeneratedLocatedVars = self.GetLocations() |
818 # Keep track of generated C files for later use by self.CTNGenerate_C |
827 # Keep track of generated C files for later use by self.CTNGenerate_C |
819 self.PLCGeneratedCFiles = C_files |
828 self.PLCGeneratedCFiles = C_files |
820 # compute CFLAGS for plc |
829 # compute CFLAGS for plc |
821 self.plcCFLAGS = '"-I%s" -Wno-unused-function' % iec2c_cfg.getLibCPath() |
830 self.plcCFLAGS = '"-I%s" -Wno-unused-function' % self.iec2c_cfg.getLibCPath() |
822 return True |
831 return True |
823 |
832 |
824 def GetBuilder(self): |
833 def GetBuilder(self): |
825 """ |
834 """ |
826 Return a Builder (compile C code into machine code) |
835 Return a Builder (compile C code into machine code) |