--- a/plugger.py Wed Nov 26 09:05:04 2008 +0100
+++ b/plugger.py Wed Dec 10 17:37:21 2008 +0100
@@ -18,6 +18,8 @@
from xmlclass import GenerateClassesFromXSDstring
from wxPopen import ProcessLogger
+from PLCControler import PLCControler _BaseParamsClass = GenerateClassesFromXSDstring("""<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="BaseParams">
@@ -83,6 +85,7 @@
+ LibraryControler = None def _AddParamsMembers(self):
@@ -110,6 +113,9 @@
def PluginXmlFilePath(self, PlugName=None):
return os.path.join(self.PlugPath(PlugName), "plugin.xml")
+ def PluginLibraryFilePath(self, PlugName=None): + return os.path.join(os.path.join(os.path.split(__file__)[0], "plugins", self.PlugType, "pous.xml")) def PlugPath(self,PlugName=None):
PlugName = self.BaseParams.getName()
@@ -264,9 +270,13 @@
return LocationCFilesAndCFLAGS, LDFLAGS, extra_files
def BlockTypesFactory(self):
+ if self.LibraryControler is not None: + return [{"name" : "%s POUs" % self.PlugType, "list": self.LibraryControler.Project.GetCustomBlockTypes()}] def STLibraryFactory(self):
+ if self.LibraryControler is not None: + return self.LibraryControler.GenerateProgram() @@ -528,7 +538,13 @@
methode_name = os.path.join(self.PlugPath(PlugName), "methods.py")
if os.path.isfile(methode_name):
+ # Get library blocks if plcopen library exist + library_path = self.PluginLibraryFilePath(PlugName) + if os.path.isfile(library_path): + self.LibraryControler = PLCControler() + self.LibraryControler.OpenXMLFile(library_path) @@ -604,7 +620,6 @@
from time import localtime
from datetime import datetime
# import necessary stuff from PLCOpenEditor
-from PLCControler import PLCControler
from PLCOpenEditor import PLCOpenEditor, ProjectDialog
from TextViewer import TextViewer
from plcopen.structures import IEC_KEYWORDS, TypeHierarchy_list
@@ -688,6 +703,9 @@
# copy PluginMethods so that it can be later customized
self.PluginMethods = [dic.copy() for dic in self.PluginMethods]
+ def PluginLibraryFilePath(self, PlugName=None): + return os.path.join(os.path.join(os.path.split(__file__)[0], "pous.xml")) def PlugTestModified(self):
return self.ChangesToSave or not self.ProjectIsSaved()
@@ -875,6 +893,13 @@
self.logger.write_error("Error in ST/IL/SFC code generator :\n%s\n"%result)
plc_file = open(self._getIECcodepath(), "w")
+ if getattr(self, "PluggedChilds", None) is not None: + # Add ST Library from plugins + plc_file.write(self.STLibraryFactory()) + for child in self.IterChilds(): + plc_file.write(child.STLibraryFactory()) if os.path.isfile(self._getIECrawcodepath()):
plc_file.write(open(self._getIECrawcodepath(), "r").read())