82 for varlist in interface.getContent(): |
83 for varlist in interface.getContent(): |
83 variables = [] |
84 variables = [] |
84 located = False |
85 located = False |
85 for var in varlist["value"].getVariable(): |
86 for var in varlist["value"].getVariable(): |
86 type = var.getType().getValue() |
87 type = var.getType().getValue() |
|
88 if not isinstance(type, (StringType, UnicodeType)): |
|
89 type = type.getName() |
87 initial = var.getInitialValue() |
90 initial = var.getInitialValue() |
88 if initial: |
91 if initial: |
89 initial_value = initial.getValue() |
92 initial_value = initial.getValue() |
90 else: |
93 else: |
91 initial_value = None |
94 initial_value = None |
92 address = var.getAddress() |
95 address = var.getAddress() |
93 if address == "": |
96 if address: |
94 address = None |
|
95 else: |
|
96 located = True |
97 located = True |
97 variables.append((type, var.getName(), address, initial_value)) |
98 variables.append((type, var.getName(), address, initial_value)) |
98 self.Interface.append((varTypeNames[varlist["name"]], varlist["value"].getRetain(), |
99 self.Interface.append((varTypeNames[varlist["name"]], varlist["value"].getRetain(), |
99 varlist["value"].getConstant(), located, variables)) |
100 varlist["value"].getConstant(), located, variables)) |
100 |
101 |
157 value = self.ComputeFBDExpression(body, connections[0]) |
158 value = self.ComputeFBDExpression(body, connections[0]) |
158 vars.append(self.ExtractModifier(variable, value)) |
159 vars.append(self.ExtractModifier(variable, value)) |
159 variable = instance.outputVariables.getVariable()[0] |
160 variable = instance.outputVariables.getVariable()[0] |
160 return self.ExtractModifier(variable, "%s(%s)"%(type, ", ".join(vars))) |
161 return self.ExtractModifier(variable, "%s(%s)"%(type, ", ".join(vars))) |
161 elif block_infos["type"] == "functionBlock": |
162 elif block_infos["type"] == "functionBlock": |
162 if self.Interface[-1][0] != "VAR" or self.Interface[-1][1] or self.Interface[-1][2] or self.Interface[-1][3]: |
163 if not self.BlockComputed.get(name, False): |
163 self.Interface.append(("VAR", False, False, False, [])) |
|
164 if not self.IsAlreadyDefined(name): |
|
165 self.Interface[-1][4].append((type, name, None, None)) |
|
166 vars = [] |
164 vars = [] |
167 for variable in instance.inputVariables.getVariable(): |
165 for variable in instance.inputVariables.getVariable(): |
168 connections = variable.connectionPointIn.getConnections() |
166 connections = variable.connectionPointIn.getConnections() |
169 if connections and len(connections) == 1: |
167 if connections and len(connections) == 1: |
170 parameter = variable.getFormalParameter() |
168 parameter = variable.getFormalParameter() |
171 value = self.ComputeFBDExpression(body, connections[0]) |
169 value = self.ComputeFBDExpression(body, connections[0]) |
172 vars.append(self.ExtractModifier(variable, "%s := %s"%(parameter, value))) |
170 vars.append(self.ExtractModifier(variable, "%s := %s"%(parameter, value))) |
173 self.Program += " %s(%s);\n"%(name, ", ".join(vars)) |
171 self.Program += " %s(%s);\n"%(name, ", ".join(vars)) |
|
172 self.BlockComputed[name] = True |
174 connectionPoint = link.getPosition()[-1] |
173 connectionPoint = link.getPosition()[-1] |
175 for variable in instance.outputVariables.getVariable(): |
174 for variable in instance.outputVariables.getVariable(): |
176 blockPointx, blockPointy = variable.connectionPointOut.getRelPosition() |
175 blockPointx, blockPointy = variable.connectionPointOut.getRelPosition() |
177 if instance.getX() + blockPointx == connectionPoint.getX() and instance.getY() + blockPointy == connectionPoint.getY(): |
176 if instance.getX() + blockPointx == connectionPoint.getX() and instance.getY() + blockPointy == connectionPoint.getY(): |
178 return self.ExtractModifier(variable, "%s.%s"%(name, variable.getFormalParameter())) |
177 return self.ExtractModifier(variable, "%s.%s"%(name, variable.getFormalParameter())) |