593 def ProjectChangePouType(self, name, pou_type): |
593 def ProjectChangePouType(self, name, pou_type): |
594 if self.Project is not None: |
594 if self.Project is not None: |
595 pou = self.Project.getpou(name) |
595 pou = self.Project.getpou(name) |
596 if pou is not None: |
596 if pou is not None: |
597 pou.setpouType(pou_type) |
597 pou.setpouType(pou_type) |
|
598 self.Project.RefreshCustomBlockTypes() |
598 self.BufferProject() |
599 self.BufferProject() |
599 |
600 |
600 def GetPouXml(self, pou_name): |
601 def GetPouXml(self, pou_name): |
601 if self.Project is not None: |
602 if self.Project is not None: |
602 pou = self.Project.getpou(pou_name) |
603 pou = self.Project.getpou(pou_name) |
1209 def GetVariableLocationTree(self): |
1210 def GetVariableLocationTree(self): |
1210 return [] |
1211 return [] |
1211 |
1212 |
1212 # Function that returns the block definition associated to the block type given |
1213 # Function that returns the block definition associated to the block type given |
1213 def GetBlockType(self, type, inputs = None, debug = False): |
1214 def GetBlockType(self, type, inputs = None, debug = False): |
|
1215 result_blocktype = None |
1214 for category in BlockTypes + self.PluginTypes: |
1216 for category in BlockTypes + self.PluginTypes: |
1215 for blocktype in category["list"]: |
1217 for blocktype in category["list"]: |
1216 if inputs: |
1218 if blocktype["name"] == type: |
1217 block_inputs = tuple([var_type for name, var_type, modifier in blocktype["inputs"]]) |
1219 if inputs is not None and inputs != "undefined": |
1218 same_inputs = inputs == block_inputs |
1220 block_inputs = tuple([var_type for name, var_type, modifier in blocktype["inputs"]]) |
1219 else: |
1221 if reduce(lambda x, y: x and y, map(lambda x: x[0] == "ANY" or self.IsOfType(*x), zip(inputs, block_inputs))): |
1220 same_inputs = True |
1222 return blocktype |
1221 if blocktype["name"] == type and same_inputs: |
1223 else: |
1222 return blocktype |
1224 if result_blocktype is not None: |
|
1225 if inputs == "undefined": |
|
1226 return None |
|
1227 else: |
|
1228 result_blocktype["inputs"] = [(i[0], "ANY", i[2]) for i in result_blocktype["inputs"]] |
|
1229 result_blocktype["outputs"] = [(o[0], "ANY", o[2]) for o in result_blocktype["outputs"]] |
|
1230 return result_blocktype |
|
1231 result_blocktype = blocktype |
|
1232 if result_blocktype is not None: |
|
1233 return result_blocktype |
1223 project = self.GetProject(debug) |
1234 project = self.GetProject(debug) |
1224 if project is not None: |
1235 if project is not None: |
1225 return project.GetCustomBlockType(type, inputs) |
1236 return project.GetCustomBlockType(type, inputs) |
1226 return None |
1237 return None |
1227 |
1238 |