PLCControler.py
changeset 6 c8cf918ee7ea
parent 5 f8652b073e84
child 13 69075340d6a9
--- a/PLCControler.py	Wed Mar 21 16:38:28 2007 +0100
+++ b/PLCControler.py	Fri Apr 06 18:06:00 2007 +0200
@@ -200,6 +200,19 @@
     def GetProjectConfigNames(self):
         return [config.getName() for config in self.Project.getConfigurations()]
     
+    # Return project pou variables
+    def GetProjectPouVariables(self, pou_name=None):
+        variables = []
+        for pou in self.Project.getPous():
+            if not pou_name or pou_name == pou.getName():
+                variables.extend([var["Name"] for var in self.GetPouInterfaceVars(pou)])
+                if pou.getBodyType() == "SFC":
+                    for transition in pou.getTransitionList():
+                        variables.append(transition.getName())
+                    for action in pou.getActionList():
+                        variables.append(action.getName())
+        return variables
+    
     # Return file path if project is an open file
     def GetFilePath(self):
         return self.FilePath
@@ -466,6 +479,16 @@
             idx = self.ElementsOpened.index(old_computedname)
             self.ElementsOpened[idx] = new_computedname
 
+    # Change the name of a pou action
+    def ChangePouVariableName(self, pou_name, old_name, new_name):
+        # Found the pou action corresponding to old name and change its name to new name
+        pou = self.Project.getPou(pou_name)
+        for type, varlist in pou.getVars():
+            for var in varlist.getVariable():
+                if var.getName() == old_name:
+                    var.setName(new_name)
+        self.RefreshBlockTypes()
+        
     # Change the name of a configuration
     def ChangeConfigurationName(self, old_name, new_name):
         # Found the configuration corresponding to old name and change its name to new name
@@ -1783,7 +1806,7 @@
     def OpenXMLFile(self, filepath):
         if sys:
             sys.stdout = HolePseudoFile()
-        tree = pyxsval.parseAndValidate(filepath, "plcopen/TC6_XML_V10_B.xsd")
+        tree = pyxsval.parseAndValidate(filepath, os.path.join(sys.path[0], "plcopen/TC6_XML_V10_B.xsd"))
         if sys:
             sys.stdout = sys.__stdout__
         
@@ -1809,7 +1832,7 @@
 
             if sys:
                 sys.stdout = HolePseudoFile()
-            pyxsval.parseAndValidateString(text, open("plcopen/TC6_XML_V10_B.xsd","r").read())
+            pyxsval.parseAndValidateString(text, open(os.path.join(sys.path[0], "plcopen/TC6_XML_V10_B.xsd"),"r").read())
             if sys:
                 sys.stdout = sys.__stdout__