diff -r e8d5ab0855d3 -r 79900abdfa3c PLCControler.py --- a/PLCControler.py Tue Apr 05 19:06:00 2011 +0200 +++ b/PLCControler.py Tue Apr 05 19:08:22 2011 +0200 @@ -595,6 +595,7 @@ pou = self.Project.getpou(name) if pou is not None: pou.setpouType(pou_type) + self.Project.RefreshCustomBlockTypes() self.BufferProject() def GetPouXml(self, pou_name): @@ -1211,15 +1212,25 @@ # Function that returns the block definition associated to the block type given def GetBlockType(self, type, inputs = None, debug = False): + result_blocktype = None for category in BlockTypes + self.PluginTypes: for blocktype in category["list"]: - if inputs: - block_inputs = tuple([var_type for name, var_type, modifier in blocktype["inputs"]]) - same_inputs = inputs == block_inputs - else: - same_inputs = True - if blocktype["name"] == type and same_inputs: - return blocktype + if blocktype["name"] == type: + if inputs is not None and inputs != "undefined": + block_inputs = tuple([var_type for name, var_type, modifier in blocktype["inputs"]]) + if reduce(lambda x, y: x and y, map(lambda x: x[0] == "ANY" or self.IsOfType(*x), zip(inputs, block_inputs))): + return blocktype + else: + if result_blocktype is not None: + if inputs == "undefined": + return None + else: + result_blocktype["inputs"] = [(i[0], "ANY", i[2]) for i in result_blocktype["inputs"]] + result_blocktype["outputs"] = [(o[0], "ANY", o[2]) for o in result_blocktype["outputs"]] + return result_blocktype + result_blocktype = blocktype + if result_blocktype is not None: + return result_blocktype project = self.GetProject(debug) if project is not None: return project.GetCustomBlockType(type, inputs)