diff -r efedc9d06a59 -r b7062a7018ec plcopen/plcopen.py --- a/plcopen/plcopen.py Thu Jan 12 17:04:22 2012 +0100 +++ b/plcopen/plcopen.py Tue Jan 17 16:44:00 2012 +0100 @@ -433,8 +433,13 @@ def AddCustomBlockType(self, pou): pou_name = pou.getname() pou_type = pou.getpouType() + pou_description = pou.getdescription() + if pou_description != "": + pou_comment = "%s\n%s" % (pou_name, pou_description) + else: + pou_comment = pou_name block_infos = {"name" : pou_name, "type" : pou_type, "extensible" : False, - "inputs" : [], "outputs" : [], "comment" : "", + "inputs" : [], "outputs" : [], "comment" : pou_comment, "generate" : generate_block, "initialise" : initialise_block} if pou.getinterface(): return_type = pou.interface.getreturnType() @@ -477,10 +482,8 @@ 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() + block_infos["usage"] = "\n (%s) => (%s)" % (", ".join(["%s:%s" % (input[1], input[0]) for input in block_infos["inputs"]]), + ", ".join(["%s:%s" % (output[1], output[0]) for output in block_infos["outputs"]])) self.CustomBlockTypes.append(block_infos) setattr(cls, "AddCustomBlockType", AddCustomBlockType) @@ -1188,6 +1191,21 @@ cls = PLCOpenClasses.get("pous_pou", None) if cls: + def setdescription(self, description): + doc = self.getdocumentation() + if doc is None: + doc = PLCOpenClasses["formattedText"]() + self.setdocumentation(doc) + doc.settext(description) + setattr(cls, "setdescription", setdescription) + + def getdescription(self): + doc = self.getdocumentation() + if doc is not None: + return doc.gettext() + return "" + setattr(cls, "getdescription", getdescription) + def setbodyType(self, type): if len(self.body) > 0: if type == "IL":