197 return [pou.getName() for pou in self.Project.getPous()] |
197 return [pou.getName() for pou in self.Project.getPous()] |
198 |
198 |
199 # Return project pou names |
199 # Return project pou names |
200 def GetProjectConfigNames(self): |
200 def GetProjectConfigNames(self): |
201 return [config.getName() for config in self.Project.getConfigurations()] |
201 return [config.getName() for config in self.Project.getConfigurations()] |
|
202 |
|
203 # Return project pou variables |
|
204 def GetProjectPouVariables(self, pou_name=None): |
|
205 variables = [] |
|
206 for pou in self.Project.getPous(): |
|
207 if not pou_name or pou_name == pou.getName(): |
|
208 variables.extend([var["Name"] for var in self.GetPouInterfaceVars(pou)]) |
|
209 if pou.getBodyType() == "SFC": |
|
210 for transition in pou.getTransitionList(): |
|
211 variables.append(transition.getName()) |
|
212 for action in pou.getActionList(): |
|
213 variables.append(action.getName()) |
|
214 return variables |
202 |
215 |
203 # Return file path if project is an open file |
216 # Return file path if project is an open file |
204 def GetFilePath(self): |
217 def GetFilePath(self): |
205 return self.FilePath |
218 return self.FilePath |
206 |
219 |
464 new_computedname = self.ComputePouActionName(pou_name, new_name) |
477 new_computedname = self.ComputePouActionName(pou_name, new_name) |
465 if old_computedname in self.ElementsOpened: |
478 if old_computedname in self.ElementsOpened: |
466 idx = self.ElementsOpened.index(old_computedname) |
479 idx = self.ElementsOpened.index(old_computedname) |
467 self.ElementsOpened[idx] = new_computedname |
480 self.ElementsOpened[idx] = new_computedname |
468 |
481 |
|
482 # Change the name of a pou action |
|
483 def ChangePouVariableName(self, pou_name, old_name, new_name): |
|
484 # Found the pou action corresponding to old name and change its name to new name |
|
485 pou = self.Project.getPou(pou_name) |
|
486 for type, varlist in pou.getVars(): |
|
487 for var in varlist.getVariable(): |
|
488 if var.getName() == old_name: |
|
489 var.setName(new_name) |
|
490 self.RefreshBlockTypes() |
|
491 |
469 # Change the name of a configuration |
492 # Change the name of a configuration |
470 def ChangeConfigurationName(self, old_name, new_name): |
493 def ChangeConfigurationName(self, old_name, new_name): |
471 # Found the configuration corresponding to old name and change its name to new name |
494 # Found the configuration corresponding to old name and change its name to new name |
472 configuration = self.Project.getConfiguration(old_name) |
495 configuration = self.Project.getConfiguration(old_name) |
473 configuration.setName(new_name) |
496 configuration.setName(new_name) |
1781 return tasks_data, instances_data |
1804 return tasks_data, instances_data |
1782 |
1805 |
1783 def OpenXMLFile(self, filepath): |
1806 def OpenXMLFile(self, filepath): |
1784 if sys: |
1807 if sys: |
1785 sys.stdout = HolePseudoFile() |
1808 sys.stdout = HolePseudoFile() |
1786 tree = pyxsval.parseAndValidate(filepath, "plcopen/TC6_XML_V10_B.xsd") |
1809 tree = pyxsval.parseAndValidate(filepath, os.path.join(sys.path[0], "plcopen/TC6_XML_V10_B.xsd")) |
1787 if sys: |
1810 if sys: |
1788 sys.stdout = sys.__stdout__ |
1811 sys.stdout = sys.__stdout__ |
1789 |
1812 |
1790 self.Project = plcopen.project() |
1813 self.Project = plcopen.project() |
1791 self.Project.loadXMLTree(tree.getTree().childNodes[0]) |
1814 self.Project.loadXMLTree(tree.getTree().childNodes[0]) |
1807 "xsi:schemaLocation" : "http://www.plcopen.org/xml/tc6.xsd http://www.plcopen.org/xml/tc6.xsd"} |
1830 "xsi:schemaLocation" : "http://www.plcopen.org/xml/tc6.xsd http://www.plcopen.org/xml/tc6.xsd"} |
1808 text += self.Project.generateXMLText("project", 0, extras) |
1831 text += self.Project.generateXMLText("project", 0, extras) |
1809 |
1832 |
1810 if sys: |
1833 if sys: |
1811 sys.stdout = HolePseudoFile() |
1834 sys.stdout = HolePseudoFile() |
1812 pyxsval.parseAndValidateString(text, open("plcopen/TC6_XML_V10_B.xsd","r").read()) |
1835 pyxsval.parseAndValidateString(text, open(os.path.join(sys.path[0], "plcopen/TC6_XML_V10_B.xsd"),"r").read()) |
1813 if sys: |
1836 if sys: |
1814 sys.stdout = sys.__stdout__ |
1837 sys.stdout = sys.__stdout__ |
1815 |
1838 |
1816 if filepath: |
1839 if filepath: |
1817 xmlfile = open(filepath,"w") |
1840 xmlfile = open(filepath,"w") |