--- a/PLCControler.py Tue Feb 26 15:32:19 2008 +0100
+++ b/PLCControler.py Tue Feb 26 15:34:38 2008 +0100
@@ -293,6 +293,90 @@
return infos
return None
+ # Return project topology informations
+ def GetProjectTopology(self):
+ if self.Project:
+ infos = {"name": self.Project.getname(), "type": ITEM_PROJECT, "values" : []}
+ for config in self.Project.getconfigurations():
+ config_infos = {"name" : config.getname(), "type": ITEM_CONFIGURATION, "values" : []}
+ for resource in config.getresource():
+ resource_infos = {"name" : resource.getname(), "type": ITEM_RESOURCE, "values": []}
+ for task in resource.gettask():
+ for pou in task.getpouInstance():
+ instance_infos = self.GetPouTopology(pou.getname(), pou.gettype())
+ if instance_infos is not None:
+ resource_infos["values"].append(instance_infos)
+ for pou in resource.getpouInstance():
+ instance_infos = self.GetPouTopology(pou.getname(), pou.gettype())
+ if instance_infos is not None:
+ resource_infos["values"].append(instance_infos)
+ for varlist in resource.getglobalVars():
+ for variable in varlist.getvariable():
+ vartype_content = variable.gettype().getcontent()
+ if vartype_content["name"] == "derived":
+ var_infos = self.GetPouTopology(variable.getname(), vartype_content["value"].getname())
+ if var_infos is not None:
+ resource_infos["values"].append(var_infos)
+ elif vartype_content["name"] in ["string", "wstring"]:
+ resource_infos["values"].append({"name" : "%s(%s)"%(variable.getname(), vartype_content["name"].upper()),
+ "type" : ITEM_VARIABLE, "values" : []})
+ else:
+ resource_infos["values"].append({"name" : "%s(%s)"%(variable.getname(), vartype_content["name"]),
+ "type" : ITEM_VARIABLE, "values" : []})
+ config_infos["values"].append(resource_infos)
+ for varlist in config.getglobalVars():
+ for variable in varlist.getvariable():
+ vartype_content = variable.gettype().getcontent()
+ if vartype_content["name"] == "derived":
+ var_infos = self.GetPouTopology(variable.getname(), vartype_content["value"].getname())
+ if var_infos is not None:
+ config_infos["values"].append(var_infos)
+ elif vartype_content["name"] in ["string", "wstring"]:
+ config_infos["values"].append({"name" : "%s(%s)"%(variable.getname(), vartype_content["name"].upper()),
+ "type" : ITEM_VARIABLE, "values" : []})
+ else:
+ config_infos["values"].append({"name" : "%s(%s)"%(variable.getname(), vartype_content["name"]),
+ "type" : ITEM_VARIABLE, "values" : []})
+ infos["values"].append(config_infos)
+ return infos
+ return None
+
+ # Return pou topology informations
+ def GetPouTopology(self, name, type):
+ if self.Project:
+ pou = self.Project.getpou(type)
+ if pou is not None:
+ pou_infos = {"name" : "%s(%s)"%(name, type), "type" : ITEM_POU, "values" : []}
+ if pou.interface:
+ # Extract variables from every varLists
+ for type, varlist in pou.getvars():
+ for variable in varlist.getvariable():
+ vartype_content = variable.gettype().getcontent()
+ if vartype_content["name"] == "derived":
+ var_infos = self.GetPouTopology(variable.getname(), vartype_content["value"].getname())
+ if var_infos is not None:
+ pou_infos["values"].append(var_infos)
+ elif vartype_content["name"] in ["string", "wstring"]:
+ pou_infos["values"].append({"name" : "%s(%s)"%(variable.getname(), vartype_content["name"].upper()),
+ "type" : ITEM_VARIABLE, "values" : []})
+ else:
+ pou_infos["values"].append({"name" : "%s(%s)"%(variable.getname(), vartype_content["name"]),
+ "type" : ITEM_VARIABLE, "values" : []})
+ return pou_infos
+ block_infos = GetBlockType(type)
+ if block_infos is not None and block_infos["type"] != "function":
+ pou_infos = {"name" : "%s(%s)"%(name, type), "type" : ITEM_POU, "values" : []}
+ for varname, vartype, varmodifier in block_infos["inputs"]:
+ pou_infos["values"].append({"name" : "%s(%s)"%(varname, vartype), "type" : ITEM_VARIABLE, "values" : []})
+ for varname, vartype, varmodifier in block_infos["outputs"]:
+ pou_infos["values"].append({"name" : "%s(%s)"%(varname, vartype), "type" : ITEM_VARIABLE, "values" : []})
+ return pou_infos
+
+ if type in TypeHierarchy:
+ return {"name" : "%s(%s)"%(name, type), "type" : ITEM_VARIABLE, "values" : []}
+
+ return None
+
# Refresh the tree of user-defined data type cross-use
def RefreshDataTypeUsingTree(self):
# Reset the tree of user-defined pou cross-use
@@ -1646,7 +1730,9 @@
result = wire.GetConnectedInfos(0)
if result != None:
refLocalId, formalParameter = result
- connection.addconnection()
+ connections = connection.getconnections()
+ if connections is None or len(connection.getconnections()) <= idx:
+ connection.addconnection()
connection.setconnectionId(idx, refLocalId)
connection.setconnectionPoints(idx, points)
if formalParameter != "":