Fix bug in SFC function block declarations from transition and action not removed when transition or action is deleted
authorlaurent
Tue, 11 Sep 2012 17:22:11 +0200
changeset 824 be669f4c51c4
parent 823 c6ed7b933617
child 825 0623820aa14a
Fix bug in SFC function block declarations from transition and action not removed when transition or action is deleted
plcopen/plcopen.py
--- a/plcopen/plcopen.py	Tue Sep 11 16:35:11 2012 +0200
+++ b/plcopen/plcopen.py	Tue Sep 11 17:22:11 2012 +0200
@@ -1435,6 +1435,11 @@
             removed = False
             while i < len(transitions) and not removed:
                 if transitions[i].getname() == name:
+                    if transitions[i].getbodyType() in ["FBD", "LD", "SFC"]:
+                        for instance in transitions[i].getinstances():
+                            if isinstance(instance, PLCOpenClasses["fbdObjects_block"]):
+                                self.removepouVar(instance.gettypeName(), 
+                                                  instance.getinstanceName())
                     transitions.pop(i)
                     removed = True
                 i += 1
@@ -1465,7 +1470,7 @@
             return self.actions.getaction()
         return []
     setattr(cls, "getactionList", getactionList)
-        
+    
     def removeaction(self, name):
         if self.actions:
             actions = self.actions.getaction()
@@ -1473,6 +1478,11 @@
             removed = False
             while i < len(actions) and not removed:
                 if actions[i].getname() == name:
+                    if actions[i].getbodyType() in ["FBD", "LD", "SFC"]:
+                        for instance in actions[i].getinstances():
+                            if isinstance(instance, PLCOpenClasses["fbdObjects_block"]):
+                                self.removepouVar(instance.gettypeName(), 
+                                                  instance.getinstanceName())
                     actions.pop(i)
                     removed = True
                 i += 1