Bug with located variables generated by Beremiz svgui plugin fixed
authorlbessard
Tue, 25 Mar 2008 18:43:48 +0100
changeset 191 d77f9b783ce8
parent 190 f37abf3ee358
child 192 50926b8abac4
Bug with located variables generated by Beremiz svgui plugin fixed
PLCGenerator.py
--- a/PLCGenerator.py	Thu Mar 13 17:30:37 2008 +0100
+++ b/PLCGenerator.py	Tue Mar 25 18:43:48 2008 +0100
@@ -320,7 +320,7 @@
                 self.ReturnType = returntype_content["value"].getname()
         for varlist in interface.getcontent():
             variables = []
-            located = False
+            located = []
             for var in varlist["value"].getvariable():
                 vartype_content = var.gettype().getcontent()
                 if vartype_content["name"] == "derived":
@@ -328,8 +328,11 @@
                     GeneratePouProgram(var_type)
                     blocktype = GetBlockType(var_type)
                     if blocktype is not None:
-                        variables.extend(blocktype["initialise"](var_type, var.getname()))
-                        located = False
+                        for variable in blocktype["initialise"](var_type, var.getname()):
+                            if variable[2] is not None:
+                                located.append(variable)
+                            else:
+                                variables.append(variable)
                     else:
                         initial = var.getinitialValue()
                         if initial:
@@ -337,9 +340,10 @@
                         else:
                             initial_value = None
                         address = var.getaddress()
-                        if address:
-                            located = True
-                        variables.append((vartype_content["value"].getname(), var.getname(), address, initial_value))
+                        if address is not None:
+                            located.append((vartype_content["value"].getname(), var.getname(), address, initial_value))
+                        else:
+                            variables.append((vartype_content["value"].getname(), var.getname(), None, initial_value))
                 else:
                     initial = var.getinitialValue()
                     if initial:
@@ -347,16 +351,22 @@
                     else:
                         initial_value = None
                     address = var.getaddress()
-                    if address:
-                        located = True
                     if vartype_content["name"] in ["string", "wstring"]:
-                        variables.append((vartype_content["name"].upper(), var.getname(), address, initial_value))
+                        if address is not None:
+                            located.append((vartype_content["name"].upper(), var.getname(), address, initial_value))
+                        else:
+                            variables.append((vartype_content["name"].upper(), var.getname(), None, initial_value))
+                    elif address is not None:
+                        located.append((vartype_content["name"], var.getname(), address, initial_value))
                     else:
-                        variables.append((vartype_content["name"], var.getname(), address, initial_value))
+                        variables.append((vartype_content["name"], var.getname(), None, initial_value))
             if len(variables) > 0:
                 self.Interface.append((varTypeNames[varlist["name"]], varlist["value"].getretain(), 
-                            varlist["value"].getconstant(), located, variables))
-    
+                            varlist["value"].getconstant(), False, variables))
+            if len(located) > 0:
+                self.Interface.append((varTypeNames[varlist["name"]], varlist["value"].getretain(), 
+                            varlist["value"].getconstant(), True, located))
+        
     def GenerateConnectionTypes(self, pou):
         body = pou.getbody()
         body_content = body.getcontent()