291 datatypes, pou_types["function"], pou_types["functionBlock"], |
291 datatypes, pou_types["function"], pou_types["functionBlock"], |
292 pou_types["program"], configurations] |
292 pou_types["program"], configurations] |
293 return infos |
293 return infos |
294 return None |
294 return None |
295 |
295 |
|
296 # Return project topology informations |
|
297 def GetProjectTopology(self): |
|
298 if self.Project: |
|
299 infos = {"name": self.Project.getname(), "type": ITEM_PROJECT, "values" : []} |
|
300 for config in self.Project.getconfigurations(): |
|
301 config_infos = {"name" : config.getname(), "type": ITEM_CONFIGURATION, "values" : []} |
|
302 for resource in config.getresource(): |
|
303 resource_infos = {"name" : resource.getname(), "type": ITEM_RESOURCE, "values": []} |
|
304 for task in resource.gettask(): |
|
305 for pou in task.getpouInstance(): |
|
306 instance_infos = self.GetPouTopology(pou.getname(), pou.gettype()) |
|
307 if instance_infos is not None: |
|
308 resource_infos["values"].append(instance_infos) |
|
309 for pou in resource.getpouInstance(): |
|
310 instance_infos = self.GetPouTopology(pou.getname(), pou.gettype()) |
|
311 if instance_infos is not None: |
|
312 resource_infos["values"].append(instance_infos) |
|
313 for varlist in resource.getglobalVars(): |
|
314 for variable in varlist.getvariable(): |
|
315 vartype_content = variable.gettype().getcontent() |
|
316 if vartype_content["name"] == "derived": |
|
317 var_infos = self.GetPouTopology(variable.getname(), vartype_content["value"].getname()) |
|
318 if var_infos is not None: |
|
319 resource_infos["values"].append(var_infos) |
|
320 elif vartype_content["name"] in ["string", "wstring"]: |
|
321 resource_infos["values"].append({"name" : "%s(%s)"%(variable.getname(), vartype_content["name"].upper()), |
|
322 "type" : ITEM_VARIABLE, "values" : []}) |
|
323 else: |
|
324 resource_infos["values"].append({"name" : "%s(%s)"%(variable.getname(), vartype_content["name"]), |
|
325 "type" : ITEM_VARIABLE, "values" : []}) |
|
326 config_infos["values"].append(resource_infos) |
|
327 for varlist in config.getglobalVars(): |
|
328 for variable in varlist.getvariable(): |
|
329 vartype_content = variable.gettype().getcontent() |
|
330 if vartype_content["name"] == "derived": |
|
331 var_infos = self.GetPouTopology(variable.getname(), vartype_content["value"].getname()) |
|
332 if var_infos is not None: |
|
333 config_infos["values"].append(var_infos) |
|
334 elif vartype_content["name"] in ["string", "wstring"]: |
|
335 config_infos["values"].append({"name" : "%s(%s)"%(variable.getname(), vartype_content["name"].upper()), |
|
336 "type" : ITEM_VARIABLE, "values" : []}) |
|
337 else: |
|
338 config_infos["values"].append({"name" : "%s(%s)"%(variable.getname(), vartype_content["name"]), |
|
339 "type" : ITEM_VARIABLE, "values" : []}) |
|
340 infos["values"].append(config_infos) |
|
341 return infos |
|
342 return None |
|
343 |
|
344 # Return pou topology informations |
|
345 def GetPouTopology(self, name, type): |
|
346 if self.Project: |
|
347 pou = self.Project.getpou(type) |
|
348 if pou is not None: |
|
349 pou_infos = {"name" : "%s(%s)"%(name, type), "type" : ITEM_POU, "values" : []} |
|
350 if pou.interface: |
|
351 # Extract variables from every varLists |
|
352 for type, varlist in pou.getvars(): |
|
353 for variable in varlist.getvariable(): |
|
354 vartype_content = variable.gettype().getcontent() |
|
355 if vartype_content["name"] == "derived": |
|
356 var_infos = self.GetPouTopology(variable.getname(), vartype_content["value"].getname()) |
|
357 if var_infos is not None: |
|
358 pou_infos["values"].append(var_infos) |
|
359 elif vartype_content["name"] in ["string", "wstring"]: |
|
360 pou_infos["values"].append({"name" : "%s(%s)"%(variable.getname(), vartype_content["name"].upper()), |
|
361 "type" : ITEM_VARIABLE, "values" : []}) |
|
362 else: |
|
363 pou_infos["values"].append({"name" : "%s(%s)"%(variable.getname(), vartype_content["name"]), |
|
364 "type" : ITEM_VARIABLE, "values" : []}) |
|
365 return pou_infos |
|
366 block_infos = GetBlockType(type) |
|
367 if block_infos is not None and block_infos["type"] != "function": |
|
368 pou_infos = {"name" : "%s(%s)"%(name, type), "type" : ITEM_POU, "values" : []} |
|
369 for varname, vartype, varmodifier in block_infos["inputs"]: |
|
370 pou_infos["values"].append({"name" : "%s(%s)"%(varname, vartype), "type" : ITEM_VARIABLE, "values" : []}) |
|
371 for varname, vartype, varmodifier in block_infos["outputs"]: |
|
372 pou_infos["values"].append({"name" : "%s(%s)"%(varname, vartype), "type" : ITEM_VARIABLE, "values" : []}) |
|
373 return pou_infos |
|
374 |
|
375 if type in TypeHierarchy: |
|
376 return {"name" : "%s(%s)"%(name, type), "type" : ITEM_VARIABLE, "values" : []} |
|
377 |
|
378 return None |
|
379 |
296 # Refresh the tree of user-defined data type cross-use |
380 # Refresh the tree of user-defined data type cross-use |
297 def RefreshDataTypeUsingTree(self): |
381 def RefreshDataTypeUsingTree(self): |
298 # Reset the tree of user-defined pou cross-use |
382 # Reset the tree of user-defined pou cross-use |
299 self.DataTypeUsingTree = {} |
383 self.DataTypeUsingTree = {} |
300 if self.Project: |
384 if self.Project: |