Bug preventing variable or datatype type name to change when POU or datatype name changed fixed
authorgreg
Mon, 04 May 2009 09:33:46 +0200
changeset 348 09fdd7616a86
parent 347 7affe341d37f
child 349 96cc6179b918
Bug preventing variable or datatype type name to change when POU or datatype name changed fixed
plcopen/plcopen.py
--- a/plcopen/plcopen.py	Wed Apr 29 12:27:34 2009 +0200
+++ b/plcopen/plcopen.py	Mon May 04 09:33:46 2009 +0200
@@ -258,6 +258,19 @@
     setattr(cls, "removeconfigurationResource", removeconfigurationResource)
 
     def updateElementName(self, old_name, new_name):
+        for datatype in self.types.getdataTypeElements():
+            datatype_content = datatype.baseType.getcontent()
+            if datatype_content["name"] == "derived" and datatype_content["value"].getname() == old_name:
+                datatype_content["value"].setname(new_name)
+            elif datatype_content["name"] in ["array", "subrangeSigned", "subrangeUnsigned"]:
+                basetype_content = datatype_content["value"].baseType.getcontent()
+                if basetype_content["name"] == "derived" and basetype_content["value"].getname() == old_name:
+                    basetype_content["value"].setname(new_name)
+            elif datatype_content["name"] == "struct":
+                for element in datatype_content["value"].getvariable():
+                    element_type = element.type.getcontent()
+                    if element_type["name"] == "derived" and element_type["value"].getname() == old_name:
+                        element_type["value"].setname(new_name)
         for pou in self.types.getpouElements():
             pou.updateElementName(old_name, new_name)
         for configuration in self.instances.configurations.getconfiguration():
@@ -969,6 +982,13 @@
     setattr(cls, "removeaction", removeaction)
 
     def updateElementName(self, old_name, new_name):
+        if self.interface:
+            for content in self.interface.getcontent():
+                for var in content["value"].getvariable():
+                    var_type_content = var.gettype().getcontent()
+                    if var_type_content["name"] == "derived":
+                        if var_type_content["value"].getname() == old_name:
+                            var_type_content["value"].setname(new_name)
         self.body.updateElementName(old_name, new_name)
         for action in self.getactionList():
             action.updateElementName(old_name, new_name)