Now generated global variable declaration is done in one separate block. Also "fixed" (masked?) problem when deleting blocks with invalid type
authoretisserant
Tue, 19 Aug 2008 18:06:41 +0200
changeset 233 de7ddb376150
parent 232 cbdfef9b2020
child 234 b9898f557e9b
Now generated global variable declaration is done in one separate block. Also "fixed" (masked?) problem when deleting blocks with invalid type
PLCControler.py
--- a/PLCControler.py	Tue Aug 19 18:04:56 2008 +0200
+++ b/PLCControler.py	Tue Aug 19 18:06:41 2008 +0200
@@ -643,8 +643,16 @@
         current_varlist = None
         current_type = None
         for var in vars:
-            if current_type != (var["Class"], var["Retain"], var["Constant"], var["Location"] in ["", None]):
-                current_type = (var["Class"], var["Retain"], var["Constant"], var["Location"] in ["", None])
+            next_type = (var["Class"], 
+                                var["Retain"], 
+                                var["Constant"], 
+                                var["Location"] in ["", None] or 
+                                    # When declaring globals, located 
+                                    # and not located variables are 
+                                    # in the same declaration block
+                                    var["Class"] == "Global")
+            if current_type != next_type:
+                current_type = next_type
                 if var["Class"] == "Local":
                     current_varlist = plcopen.interface_localVars()
                 elif var["Class"] == "Global":
@@ -1685,12 +1693,12 @@
             new_type = infos.get("type", old_type)
             old_typeinfos = self.GetBlockType(old_type)
             new_typeinfos = self.GetBlockType(new_type)
-            if new_typeinfos["type"] != old_typeinfos["type"]:
+            if new_type != old_type and new_typeinfos["type"] != old_typeinfos["type"]:
                 if new_typeinfos["type"] == "function":
                     self.RemoveEditedElementPouVar(tagname, old_type, old_name)
                 else:
                     self.AddEditedElementPouVar(tagname, new_type, new_name)
-            elif new_typeinfos["type"] != "function" and old_name != new_name:
+            elif old_name != new_name and new_typeinfos["type"] != "function":
                 self.ChangeEditedElementPouVar(tagname, old_type, old_name, new_type, new_name)
             for param, value in infos.items():
                 if param == "name":