Bug preventing loading STLibrary when adding a plugin fixed
authorlbessard
Mon, 23 Mar 2009 16:39:23 +0100
changeset 325 f2604900bf25
parent 324 01a7b01bf896
child 326 386566f263f3
Bug preventing loading STLibrary when adding a plugin fixed
plugger.py
--- a/plugger.py	Mon Mar 23 16:38:11 2009 +0100
+++ b/plugger.py	Mon Mar 23 16:39:23 2009 +0100
@@ -106,14 +106,15 @@
         self.PluggedChilds = {}
         # copy PluginMethods so that it can be later customized
         self.PluginMethods = [dic.copy() for dic in self.PluginMethods]
-
+        self.LoadSTLibrary()
+        
     def PluginBaseXmlFilePath(self, PlugName=None):
         return os.path.join(self.PlugPath(PlugName), "baseplugin.xml")
     
     def PluginXmlFilePath(self, PlugName=None):
         return os.path.join(self.PlugPath(PlugName), "plugin.xml")
 
-    def PluginLibraryFilePath(self, PlugName=None):
+    def PluginLibraryFilePath(self):
         return os.path.join(os.path.join(os.path.split(__file__)[0], "plugins", self.PlugType, "pous.xml"))
 
     def PlugPath(self,PlugName=None):
@@ -534,18 +535,18 @@
         
         return newPluginOpj
             
+    def LoadSTLibrary(self):
+        # Get library blocks if plcopen library exist
+        library_path = self.PluginLibraryFilePath()
+        if os.path.isfile(library_path):
+            self.LibraryControler = PLCControler()
+            self.LibraryControler.OpenXMLFile(library_path)
 
     def LoadXMLParams(self, PlugName = None):
         methode_name = os.path.join(self.PlugPath(PlugName), "methods.py")
         if os.path.isfile(methode_name):
             execfile(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)
-        
         # Get the base xml tree
         if self.MandatoryParams:
             try:
@@ -704,9 +705,10 @@
         self.debug_break = False
         # 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"))
+        self.LoadSTLibrary()
+
+    def PluginLibraryFilePath(self):
+        return os.path.join(os.path.split(__file__)[0], "pous.xml")
 
     def PlugTestModified(self):
          return self.ChangesToSave or not self.ProjectIsSaved()