274 return [{"name" : "%s POUs" % self.PlugType, "list": self.LibraryControler.Project.GetCustomBlockTypes()}] |
274 return [{"name" : "%s POUs" % self.PlugType, "list": self.LibraryControler.Project.GetCustomBlockTypes()}] |
275 return [] |
275 return [] |
276 |
276 |
277 def STLibraryFactory(self): |
277 def STLibraryFactory(self): |
278 if self.LibraryControler is not None: |
278 if self.LibraryControler is not None: |
279 return self.LibraryControler.GenerateProgram() |
279 program, errors, warnings = self.LibraryControler.GenerateProgram() |
|
280 return program |
280 return "" |
281 return "" |
281 |
282 |
282 def IterChilds(self): |
283 def IterChilds(self): |
283 for PlugType, PluggedChilds in self.PluggedChilds.items(): |
284 for PlugType, PluggedChilds in self.PluggedChilds.items(): |
284 for PlugInstance in PluggedChilds: |
285 for PlugInstance in PluggedChilds: |
894 self.RefreshPluginsBlockLists() |
895 self.RefreshPluginsBlockLists() |
895 |
896 |
896 self.logger.write("Generating SoftPLC IEC-61131 ST/IL/SFC code...\n") |
897 self.logger.write("Generating SoftPLC IEC-61131 ST/IL/SFC code...\n") |
897 buildpath = self._getBuildPath() |
898 buildpath = self._getBuildPath() |
898 # ask PLCOpenEditor controller to write ST/IL/SFC code file |
899 # ask PLCOpenEditor controller to write ST/IL/SFC code file |
899 result = self.GenerateProgram(self._getIECgeneratedcodepath()) |
900 program, errors, warnings = self.GenerateProgram(self._getIECgeneratedcodepath()) |
900 if result is not None: |
901 if len(warnings) > 0: |
|
902 self.logger.write_warning("Warnings in ST/IL/SFC code generator :\n") |
|
903 for warning in warnings: |
|
904 self.logger.write_warning("%s\n"%warning) |
|
905 if len(errors) > 0: |
901 # Failed ! |
906 # Failed ! |
902 self.logger.write_error("Error in ST/IL/SFC code generator :\n%s\n"%result) |
907 self.logger.write_error("Error in ST/IL/SFC code generator :\n%s\n"%errors[0]) |
903 return False |
908 return False |
904 plc_file = open(self._getIECcodepath(), "w") |
909 plc_file = open(self._getIECcodepath(), "w") |
905 if getattr(self, "PluggedChilds", None) is not None: |
910 if getattr(self, "PluggedChilds", None) is not None: |
906 # Add ST Library from plugins |
911 # Add ST Library from plugins |
907 plc_file.write(self.STLibraryFactory()) |
912 plc_file.write(self.STLibraryFactory()) |