264 project = self.GetProject(debug) |
264 project = self.GetProject(debug) |
265 if project is not None: |
265 if project is not None: |
266 return [config.getname() for config in project.getconfigurations()] |
266 return [config.getname() for config in project.getconfigurations()] |
267 return [] |
267 return [] |
268 |
268 |
269 # Return project pou variables |
269 # Return project pou variable names |
270 def GetProjectPouVariables(self, pou_name = None, debug = False): |
270 def GetProjectPouVariableNames(self, pou_name = None, debug = False): |
271 variables = [] |
271 variables = [] |
272 project = self.GetProject(debug) |
272 project = self.GetProject(debug) |
273 if project is not None: |
273 if project is not None: |
274 for pou in project.getpous(): |
274 for pou in project.getpous(): |
275 if pou_name is None or pou_name == pou.getname(): |
275 if pou_name is None or pou_name == pou.getname(): |
1259 tempvar["Documentation"] = doc.gettext() |
1259 tempvar["Documentation"] = doc.gettext() |
1260 else: |
1260 else: |
1261 tempvar["Documentation"] = "" |
1261 tempvar["Documentation"] = "" |
1262 |
1262 |
1263 return tempvar |
1263 return tempvar |
|
1264 |
|
1265 # Add a global var to configuration to configuration |
|
1266 def AddConfigurationGlobalVar(self, config_name, type, var_name, |
|
1267 location="", description=""): |
|
1268 if self.Project is not None: |
|
1269 # Found the configuration corresponding to name |
|
1270 configuration = self.Project.getconfiguration(config_name) |
|
1271 if configuration is not None: |
|
1272 # Set configuration global vars |
|
1273 configuration.addglobalVar(type, var_name, location, description) |
1264 |
1274 |
1265 # Replace the configuration globalvars by those given |
1275 # Replace the configuration globalvars by those given |
1266 def SetConfigurationGlobalVars(self, name, vars): |
1276 def SetConfigurationGlobalVars(self, name, vars): |
1267 if self.Project is not None: |
1277 if self.Project is not None: |
1268 # Found the configuration corresponding to name |
1278 # Found the configuration corresponding to name |
1287 tempvar = self.GetVariableDictionary(varlist, var) |
1297 tempvar = self.GetVariableDictionary(varlist, var) |
1288 tempvar["Class"] = "Global" |
1298 tempvar["Class"] = "Global" |
1289 vars.append(tempvar) |
1299 vars.append(tempvar) |
1290 return vars |
1300 return vars |
1291 |
1301 |
|
1302 # Return configuration variable names |
|
1303 def GetConfigurationVariableNames(self, config_name = None, debug = False): |
|
1304 variables = [] |
|
1305 project = self.GetProject(debug) |
|
1306 if project is not None: |
|
1307 for configuration in self.Project.getconfigurations(): |
|
1308 if config_name is None or config_name == configuration.getname(): |
|
1309 variables.extend( |
|
1310 [var.getname() for var in reduce( |
|
1311 lambda x, y: x + y, [varlist.getvariable() |
|
1312 for varlist in configuration.globalVars], |
|
1313 [])]) |
|
1314 return variables |
|
1315 |
1292 # Replace the resource globalvars by those given |
1316 # Replace the resource globalvars by those given |
1293 def SetConfigurationResourceGlobalVars(self, config_name, name, vars): |
1317 def SetConfigurationResourceGlobalVars(self, config_name, name, vars): |
1294 if self.Project is not None: |
1318 if self.Project is not None: |
1295 # Found the resource corresponding to name |
1319 # Found the resource corresponding to name |
1296 resource = self.Project.getconfigurationResource(config_name, name) |
1320 resource = self.Project.getconfigurationResource(config_name, name) |
1313 for var in varlist.getvariable(): |
1337 for var in varlist.getvariable(): |
1314 tempvar = self.GetVariableDictionary(varlist, var) |
1338 tempvar = self.GetVariableDictionary(varlist, var) |
1315 tempvar["Class"] = "Global" |
1339 tempvar["Class"] = "Global" |
1316 vars.append(tempvar) |
1340 vars.append(tempvar) |
1317 return vars |
1341 return vars |
|
1342 |
|
1343 # Return resource variable names |
|
1344 def GetConfigurationResourceVariableNames(self, |
|
1345 config_name = None, resource_name = None, debug = False): |
|
1346 variables = [] |
|
1347 project = self.GetProject(debug) |
|
1348 if project is not None: |
|
1349 for configuration in self.Project.getconfigurations(): |
|
1350 if config_name is None or config_name == configuration.getname(): |
|
1351 for resource in configuration.getresource(): |
|
1352 if resource_name is None or resource.getname() == resource_name: |
|
1353 variables.extend( |
|
1354 [var.getname() for var in reduce( |
|
1355 lambda x, y: x + y, [varlist.getvariable() |
|
1356 for varlist in resource.globalVars], |
|
1357 [])]) |
|
1358 return variables |
1318 |
1359 |
1319 # Recursively generate element name tree for a structured variable |
1360 # Recursively generate element name tree for a structured variable |
1320 def GenerateVarTree(self, typename, debug = False): |
1361 def GenerateVarTree(self, typename, debug = False): |
1321 project = self.GetProject(debug) |
1362 project = self.GetProject(debug) |
1322 if project is not None: |
1363 if project is not None: |
2074 |
2115 |
2075 # Return the names of the pou elements |
2116 # Return the names of the pou elements |
2076 def GetEditedElementVariables(self, tagname, debug = False): |
2117 def GetEditedElementVariables(self, tagname, debug = False): |
2077 words = tagname.split("::") |
2118 words = tagname.split("::") |
2078 if words[0] in ["P","T","A"]: |
2119 if words[0] in ["P","T","A"]: |
2079 return self.GetProjectPouVariables(words[1], debug) |
2120 return self.GetProjectPouVariableNames(words[1], debug) |
|
2121 elif words[0] in ["C", "R"]: |
|
2122 names = self.GetConfigurationVariableNames(words[1], debug) |
|
2123 if words[0] == "R": |
|
2124 names.extend(self.GetConfigurationResourceVariableNames( |
|
2125 words[1], words[2], debug)) |
|
2126 return names |
2080 return [] |
2127 return [] |
2081 |
2128 |
2082 def GetEditedElementCopy(self, tagname, debug = False): |
2129 def GetEditedElementCopy(self, tagname, debug = False): |
2083 element = self.GetEditedElement(tagname, debug) |
2130 element = self.GetEditedElement(tagname, debug) |
2084 if element is not None: |
2131 if element is not None: |