plcopen/structures.py
changeset 28 fc23e1f415d8
parent 27 dae55dd9ee14
child 40 49c8ebc1ee25
equal deleted inserted replaced
27:dae55dd9ee14 28:fc23e1f415d8
   126 
   126 
   127 """
   127 """
   128 Function that returns the block definition associated to the block type given
   128 Function that returns the block definition associated to the block type given
   129 """
   129 """
   130 
   130 
   131 def GetBlockType(type):
   131 def GetBlockType(type, inputs = None):
   132     for category in BlockTypes:
   132     for category in BlockTypes:
   133         for blocktype in category["list"]:
   133         for blocktype in category["list"]:
   134             if blocktype["name"] == type:
   134             if inputs:
       
   135                 block_inputs = tuple([var_type for name, var_type, modifier in blocktype["inputs"]])
       
   136                 same_inputs = inputs == block_inputs
       
   137             else:
       
   138                 same_inputs = True
       
   139             if blocktype["name"] == type and same_inputs:
   135                 return blocktype
   140                 return blocktype
   136     return None
   141     return None
   137 
   142 
   138 
   143 
   139 #-------------------------------------------------------------------------------
   144 #-------------------------------------------------------------------------------