PLCControler.py
changeset 92 76d5001393df
parent 90 2245e8776086
child 94 e7f5a251f251
equal deleted inserted replaced
91:e8e9ddeed76c 92:76d5001393df
   862                     if pou.getBodyType() in ["FBD","LD","SFC"]:
   862                     if pou.getBodyType() in ["FBD","LD","SFC"]:
   863                         for instance in pou.getInstances():
   863                         for instance in pou.getInstances():
   864                             if isinstance(instance, plcopen.comment):
   864                             if isinstance(instance, plcopen.comment):
   865                                 block_infos["comment"] = instance.getContentText()
   865                                 block_infos["comment"] = instance.getContentText()
   866                     BlockTypes[-1]["list"].append(block_infos)
   866                     BlockTypes[-1]["list"].append(block_infos)
   867 
   867     
   868     # Return Block types checking for recursion
   868     # Return Block types checking for recursion
   869     def GetBlockTypes(self):
   869     def GetBlockTypes(self):
   870         if self.CurrentElementEditing != None:
   870         if self.CurrentElementEditing != None:
   871             if self.Project:
   871             if self.Project:
   872                 current_name = self.ElementsOpened[self.CurrentElementEditing]
   872                 current_name = self.ElementsOpened[self.CurrentElementEditing]
   879             else:
   879             else:
   880                 name = ""
   880                 name = ""
   881                 type = None
   881                 type = None
   882             if type == "function":
   882             if type == "function":
   883                 blocktypes = []
   883                 blocktypes = []
   884                 for category in BlockTypes[:-1]:
   884                 for category in BlockTypes[:-1] + PluginTypes:
   885                     cat = {"name" : category["name"], "list" : []}
   885                     cat = {"name" : category["name"], "list" : []}
   886                     for block in category["list"]:
   886                     for block in category["list"]:
   887                         if block["type"] == "function":
   887                         if block["type"] == "function":
   888                             cat["list"].append(block)
   888                             cat["list"].append(block)
   889                     if len(cat["list"]) > 0:
   889                     if len(cat["list"]) > 0:
   890                         blocktypes.append(cat)
   890                         blocktypes.append(cat)
   891             else:
   891             else:
   892                 blocktypes = [category for category in BlockTypes[:-1]]
   892                 blocktypes = [category for category in BlockTypes[:-1] + PluginTypes]
   893             if self.Project:
   893             if self.Project:
   894                 blocktypes.append({"name" : "User-defined POUs", "list": []})
   894                 blocktypes.append({"name" : "User-defined POUs", "list": []})
   895                 for blocktype in BlockTypes[-1]["list"]:
   895                 for blocktype in BlockTypes[-1]["list"]:
   896                     if blocktype["name"] != name and not self.PouIsUsedBy(name, blocktype["name"]) and not (type == "function" and blocktype["type"] != "function"):
   896                     if blocktype["name"] != name and not self.PouIsUsedBy(name, blocktype["name"]) and not (type == "function" and blocktype["type"] != "function"):
   897                         blocktypes[-1]["list"].append(blocktype)
   897                         blocktypes[-1]["list"].append(blocktype)
   922                 for blocktype in BlockTypes[-1]["list"]:
   922                 for blocktype in BlockTypes[-1]["list"]:
   923                     if blocktype["name"] != name and not self.PouIsUsedBy(name, blocktype["name"]) and not (type == "function" and blocktype["type"] != "function"):
   923                     if blocktype["name"] != name and not self.PouIsUsedBy(name, blocktype["name"]) and not (type == "function" and blocktype["type"] != "function"):
   924                         blocktypes.append(blocktype["name"])
   924                         blocktypes.append(blocktype["name"])
   925             return blocktypes
   925             return blocktypes
   926         return []
   926         return []
   927 
       
   928 
   927 
   929     # Return Block types checking for recursion
   928     # Return Block types checking for recursion
   930     def GetBlockResource(self):
   929     def GetBlockResource(self):
   931         blocktypes = []
   930         blocktypes = []
   932         for category in BlockTypes[:-1]:
   931         for category in BlockTypes[:-1]: