--- a/plcopen/plcopen.py Fri Oct 24 16:39:57 2008 +0200
+++ b/plcopen/plcopen.py Fri Nov 21 13:45:25 2008 +0100
@@ -310,56 +310,55 @@
def AddCustomBlockType(self, pou):
pou_name = pou.getname()
pou_type = pou.getpouType()
- if pou_type != "program":
- block_infos = {"name" : pou_name, "type" : pou_type, "extensible" : False,
- "inputs" : [], "outputs" : [], "comment" : "",
- "generate" : generate_block, "initialise" : initialise_block}
- if pou.getinterface():
- return_type = pou.interface.getreturnType()
- if return_type:
- var_type = return_type.getcontent()
- if var_type["name"] == "derived":
- block_infos["outputs"].append(("", var_type["value"].getname(), "none"))
- elif var_type["name"] in ["string", "wstring"]:
- block_infos["outputs"].append(("", var_type["name"].upper(), "none"))
- else:
- block_infos["outputs"].append(("", var_type["name"], "none"))
- for type, varlist in pou.getvars():
- if type == "InOut":
- for var in varlist.getvariable():
- var_type = var.type.getcontent()
- if var_type["name"] == "derived":
- block_infos["inputs"].append((var.getname(), var_type["value"].getname(), "none"))
- block_infos["outputs"].append((var.getname(), var_type["value"].getname(), "none"))
- elif var_type["name"] in ["string", "wstring"]:
- block_infos["inputs"].append((var.getname(), var_type["name"].upper(), "none"))
- block_infos["outputs"].append((var.getname(), var_type["name"].upper(), "none"))
- else:
- block_infos["inputs"].append((var.getname(), var_type["name"], "none"))
- block_infos["outputs"].append((var.getname(), var_type["name"], "none"))
- elif type == "Input":
- for var in varlist.getvariable():
- var_type = var.type.getcontent()
- if var_type["name"] == "derived":
- block_infos["inputs"].append((var.getname(), var_type["value"].getname(), "none"))
- elif var_type["name"] in ["string", "wstring"]:
- block_infos["inputs"].append((var.getname(), var_type["name"].upper(), "none"))
- else:
- block_infos["inputs"].append((var.getname(), var_type["name"], "none"))
- elif type == "Output":
- for var in varlist.getvariable():
- var_type = var.type.getcontent()
- if var_type["name"] == "derived":
- block_infos["outputs"].append((var.getname(), var_type["value"].getname(), "none"))
- elif var_type["name"] in ["string", "wstring"]:
- block_infos["outputs"].append((var.getname(), var_type["name"].upper(), "none"))
- else:
- block_infos["outputs"].append((var.getname(), var_type["name"], "none"))
- if pou.getbodyType() in ["FBD","LD","SFC"]:
- for instance in pou.getinstances():
- if isinstance(instance, PLCOpenClasses.get("commonObjects_comment", None)):
- block_infos["comment"] = instance.getcontentText()
- self.CustomBlockTypes.append(block_infos)
+ block_infos = {"name" : pou_name, "type" : pou_type, "extensible" : False,
+ "inputs" : [], "outputs" : [], "comment" : "",
+ "generate" : generate_block, "initialise" : initialise_block}
+ if pou.getinterface():
+ return_type = pou.interface.getreturnType()
+ if return_type:
+ var_type = return_type.getcontent()
+ if var_type["name"] == "derived":
+ block_infos["outputs"].append(("", var_type["value"].getname(), "none"))
+ elif var_type["name"] in ["string", "wstring"]:
+ block_infos["outputs"].append(("", var_type["name"].upper(), "none"))
+ else:
+ block_infos["outputs"].append(("", var_type["name"], "none"))
+ for type, varlist in pou.getvars():
+ if type == "InOut":
+ for var in varlist.getvariable():
+ var_type = var.type.getcontent()
+ if var_type["name"] == "derived":
+ block_infos["inputs"].append((var.getname(), var_type["value"].getname(), "none"))
+ block_infos["outputs"].append((var.getname(), var_type["value"].getname(), "none"))
+ elif var_type["name"] in ["string", "wstring"]:
+ block_infos["inputs"].append((var.getname(), var_type["name"].upper(), "none"))
+ block_infos["outputs"].append((var.getname(), var_type["name"].upper(), "none"))
+ else:
+ block_infos["inputs"].append((var.getname(), var_type["name"], "none"))
+ block_infos["outputs"].append((var.getname(), var_type["name"], "none"))
+ elif type == "Input":
+ for var in varlist.getvariable():
+ var_type = var.type.getcontent()
+ if var_type["name"] == "derived":
+ block_infos["inputs"].append((var.getname(), var_type["value"].getname(), "none"))
+ elif var_type["name"] in ["string", "wstring"]:
+ block_infos["inputs"].append((var.getname(), var_type["name"].upper(), "none"))
+ else:
+ block_infos["inputs"].append((var.getname(), var_type["name"], "none"))
+ elif type == "Output":
+ for var in varlist.getvariable():
+ var_type = var.type.getcontent()
+ if var_type["name"] == "derived":
+ block_infos["outputs"].append((var.getname(), var_type["value"].getname(), "none"))
+ elif var_type["name"] in ["string", "wstring"]:
+ block_infos["outputs"].append((var.getname(), var_type["name"].upper(), "none"))
+ else:
+ block_infos["outputs"].append((var.getname(), var_type["name"], "none"))
+ if pou.getbodyType() in ["FBD","LD","SFC"]:
+ for instance in pou.getinstances():
+ if isinstance(instance, PLCOpenClasses.get("commonObjects_comment", None)):
+ block_infos["comment"] = instance.getcontentText()
+ self.CustomBlockTypes.append(block_infos)
setattr(cls, "AddCustomBlockType", AddCustomBlockType)
def RefreshElementUsingTree(self):
@@ -501,7 +500,7 @@
type = pou.getpouType()
customblocktypes = []
for customblocktype in self.CustomBlockTypes:
- if customblocktype["name"] != exclude and not self.ElementIsUsedBy(exclude, customblocktype["name"]) and not (onlyfunctions and customblocktype["type"] != "function"):
+ if customblocktype["type"] != "program" and customblocktype["name"] != exclude and not self.ElementIsUsedBy(exclude, customblocktype["name"]) and not (onlyfunctions and customblocktype["type"] != "function"):
customblocktypes.append(customblocktype)
return customblocktypes
setattr(cls, "GetCustomBlockTypes", GetCustomBlockTypes)
@@ -510,7 +509,7 @@
def GetCustomFunctionBlockTypes(self, exclude = ""):
customblocktypes = []
for customblocktype in self.CustomBlockTypes:
- if customblocktype["name"] != exclude and not self.ElementIsUsedBy(exclude, customblocktype["name"]):
+ if customblocktype["type"] == "functionBlock" and customblocktype["name"] != exclude and not self.ElementIsUsedBy(exclude, customblocktype["name"]):
customblocktypes.append(customblocktype["name"])
return customblocktypes
setattr(cls, "GetCustomFunctionBlockTypes", GetCustomFunctionBlockTypes)