164 '''See PlugTemplate.GetVariableLocationTree() for a description.''' |
164 '''See PlugTemplate.GetVariableLocationTree() for a description.''' |
165 |
165 |
166 current_location = ".".join(map(str, self.GetCurrentLocation())) |
166 current_location = ".".join(map(str, self.GetCurrentLocation())) |
167 |
167 |
168 vars = [] |
168 vars = [] |
169 input = output = 0 |
169 input = memory = output = 0 |
170 for var in self.CFile.variables.getvariable(): |
170 for var in self.CFile.variables.getvariable(): |
171 var_size = self.GetSizeOfType(var.gettype()) |
171 var_size = self.GetSizeOfType(var.gettype()) |
172 if var.getclass() == "input": |
172 if var.getclass() == "input": |
173 var_class = LOCATION_VAR_INPUT |
173 var_class = LOCATION_VAR_INPUT |
174 var_location = "%%I%s%s.%d"%(var_size, current_location, input) |
174 var_location = "%%I%s%s.%d"%(var_size, current_location, input) |
175 input += 1 |
175 input += 1 |
|
176 elif var.getclass() == "memory": |
|
177 var_class = LOCATION_VAR_INPUT |
|
178 var_location = "%%M%s%s.%d"%(var_size, current_location, memory) |
|
179 memory += 1 |
176 else: |
180 else: |
177 var_class = LOCATION_VAR_OUTPUT |
181 var_class = LOCATION_VAR_OUTPUT |
178 var_location = "%%Q%s%s.%d"%(var_size, current_location, output) |
182 var_location = "%%Q%s%s.%d"%(var_size, current_location, output) |
179 output += 1 |
183 output += 1 |
180 vars.append({"name": var.getname(), |
184 vars.append({"name": var.getname(), |
301 |
305 |
302 """ |
306 """ |
303 |
307 |
304 # Adding variables |
308 # Adding variables |
305 vars = [] |
309 vars = [] |
306 inputs = outputs = 0 |
310 inputs = memories = outputs = 0 |
307 for variable in self.CFile.variables.variable: |
311 for variable in self.CFile.variables.variable: |
308 var = {"Name" : variable.getname(), "Type" : variable.gettype()} |
312 var = {"Name" : variable.getname(), "Type" : variable.gettype()} |
309 if variable.getclass() == "input": |
313 if variable.getclass() == "input": |
310 var["location"] = "__I%s%s_%d"%(self.GetSizeOfType(var["Type"]), location_str, inputs) |
314 var["location"] = "__I%s%s_%d"%(self.GetSizeOfType(var["Type"]), location_str, inputs) |
311 inputs += 1 |
315 inputs += 1 |
|
316 elif variable.getclass() == "memory": |
|
317 var["location"] = "__M%s%s_%d"%(self.GetSizeOfType(var["Type"]), location_str, memories) |
|
318 memories += 1 |
312 else: |
319 else: |
313 var["location"] = "__Q%s%s_%d"%(self.GetSizeOfType(var["Type"]), location_str, outputs) |
320 var["location"] = "__Q%s%s_%d"%(self.GetSizeOfType(var["Type"]), location_str, outputs) |
314 outputs += 1 |
321 outputs += 1 |
315 vars.append(var) |
322 vars.append(var) |
316 text += "/* Beremiz c_ext plugin user variables definition */\n" |
323 text += "/* Beremiz c_ext plugin user variables definition */\n" |