PLCControler.py
changeset 483 779a519f78f2
parent 452 34fc9b813205
child 484 acef952101a5
--- a/PLCControler.py	Thu Dec 10 12:26:06 2009 +0100
+++ b/PLCControler.py	Thu Dec 10 16:37:11 2009 +0100
@@ -875,13 +875,12 @@
         current_type = None
         for var in vars:
             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")
+                         var["Option"], 
+                         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
                 infos = VAR_CLASS_INFOS.get(var["Class"], None)
@@ -890,10 +889,12 @@
                 else:
                     current_varlist = plcopen.varList()
                 varlist_list.append((var["Class"], current_varlist))
-                if var["Retain"] == "Yes":
+                if var["Option"] == "Constant":
+                    current_varlist.setconstant(True)
+                elif var["Option"] == "Retain":
                     current_varlist.setretain(True)
-                if var["Constant"] == "Yes":
-                    current_varlist.setconstant(True)
+                elif var["Option"] == "Non-Retain":
+                    current_varlist.setnonretain(True)
             # Create variable and change its properties
             tempvar = plcopen.varListPlain_variable()
             tempvar.setname(var["Name"])
@@ -935,7 +936,7 @@
         returned by Get*Vars)
         '''
 
-        tempvar = {"Name" : var.getname()}
+        tempvar = {"Name": var.getname()}
 
         vartype_content = var.gettype().getcontent()
         if vartype_content["name"] == "derived":
@@ -959,15 +960,14 @@
         else:
             tempvar["Location"] = ""
 
-        if varlist.getretain():
-            tempvar["Retain"] = "Yes"
+        if varlist.getconstant():
+            tempvar["Option"] = "Constant"
+        elif varlist.getretain():
+            tempvar["Option"] = "Retain"
+        elif varlist.getnonretain():
+            tempvar["Option"] = "Non-Retain"
         else:
-            tempvar["Retain"] = "No"
-
-        if varlist.getconstant():
-            tempvar["Constant"] = "Yes"
-        else:
-            tempvar["Constant"] = "No"
+            tempvar["Option"] = ""
 
         doc = var.getdocumentation()
         if doc: