plcopen/plcopen.py
changeset 238 389f2046e495
parent 225 7726c8ffda42
child 246 9cf9694e8d66
equal deleted inserted replaced
237:097e8ee006cb 238:389f2046e495
   311         pou_name = pou.getname()
   311         pou_name = pou.getname()
   312         pou_type = pou.getpouType()
   312         pou_type = pou.getpouType()
   313         if pou_type != "program":
   313         if pou_type != "program":
   314             block_infos = {"name" : pou_name, "type" : pou_type, "extensible" : False,
   314             block_infos = {"name" : pou_name, "type" : pou_type, "extensible" : False,
   315                            "inputs" : [], "outputs" : [], "comment" : "",
   315                            "inputs" : [], "outputs" : [], "comment" : "",
   316                            "generate" : generate_block, "initialise" : initialise_block }
   316                            "generate" : generate_block, "initialise" : initialise_block}
   317             if pou.getinterface():
   317             if pou.getinterface():
   318                 for type, varlist in pou.getvars():
   318                 for type, varlist in pou.getvars():
   319                     if type == "InOut":
   319                     if type == "InOut":
   320                         for var in varlist.getvariable():
   320                         for var in varlist.getvariable():
   321                             var_type = var.type.getcontent()
   321                             var_type = var.type.getcontent()
   492         return None
   492         return None
   493     setattr(cls, "GetCustomBlockType", GetCustomBlockType)
   493     setattr(cls, "GetCustomBlockType", GetCustomBlockType)
   494 
   494 
   495     # Return Block types checking for recursion
   495     # Return Block types checking for recursion
   496     def GetCustomBlockTypes(self, exclude = ""):
   496     def GetCustomBlockTypes(self, exclude = ""):
   497         pou = self.getpou(exclude)
   497         type = None
   498         type = pou.getpouType()
   498         if exclude != "":
       
   499             pou = self.getpou(exclude)
       
   500             if pou is not None:
       
   501                 type = pou.getpouType()
   499         customblocktypes = []
   502         customblocktypes = []
   500         for customblocktype in self.CustomBlockTypes:
   503         for customblocktype in self.CustomBlockTypes:
   501             if customblocktype["name"] != exclude and not self.ElementIsUsedBy(exclude, customblocktype["name"]) and not (type == "function" and customblocktype["type"] != "function"):
   504             if customblocktype["name"] != exclude and not self.ElementIsUsedBy(exclude, customblocktype["name"]) and not (type == "function" and customblocktype["type"] != "function"):
   502                 customblocktypes.append(customblocktype)
   505                 customblocktypes.append(customblocktype)
   503         return customblocktypes
   506         return customblocktypes