plcopen/structures.py
changeset 1307 26e8b99bc2c3
parent 1298 f034fb2b1aab
child 1310 3d7fa2257b24
equal deleted inserted replaced
1289:1d221eda1e42 1307:26e8b99bc2c3
    40         return reduce(lambda x, y: x + separator + y, mylist)
    40         return reduce(lambda x, y: x + separator + y, mylist)
    41     else :
    41     else :
    42         return mylist
    42         return mylist
    43 
    43 
    44 def generate_block(generator, block, block_infos, body, link, order=False, to_inout=False):
    44 def generate_block(generator, block, block_infos, body, link, order=False, to_inout=False):
    45     body_type = body.getcontent()["name"]
    45     body_type = body.getcontent().getLocalTag()
    46     name = block.getinstanceName()
    46     name = block.getinstanceName()
    47     type = block.gettypeName()
    47     type = block.gettypeName()
    48     executionOrderId = block.getexecutionOrderId()
    48     executionOrderId = block.getexecutionOrderId()
    49     input_variables = block.inputVariables.getvariable()
    49     input_variables = block.inputVariables.getvariable()
    50     output_variables = block.outputVariables.getvariable()
    50     output_variables = block.outputVariables.getvariable()
   156                                   (name, (generator.TagName, "block", block.getlocalId(), "name")),
   156                                   (name, (generator.TagName, "block", block.getlocalId(), "name")),
   157                                   ("(", ())]
   157                                   ("(", ())]
   158             generator.Program += JoinList([(", ", ())], vars)
   158             generator.Program += JoinList([(", ", ())], vars)
   159             generator.Program += [(");\n", ())]
   159             generator.Program += [(");\n", ())]
   160     
   160     
   161     if link:
   161     if link is not None:
   162         connectionPoint = link.getposition()[-1]
   162         connectionPoint = link.getposition()[-1]
   163         output_parameter = link.getformalParameter()
   163         output_parameter = link.getformalParameter()
   164     else:
   164     else:
   165         connectionPoint = None
   165         connectionPoint = None
   166         output_parameter = None
   166         output_parameter = None
   175                     if output_parameter != "ENO":
   175                     if output_parameter != "ENO":
   176                         output_idx = output_names.index(output_parameter)
   176                         output_idx = output_names.index(output_parameter)
   177     else:
   177     else:
   178         for i, variable in enumerate(output_variables):
   178         for i, variable in enumerate(output_variables):
   179             blockPointx, blockPointy = variable.connectionPointOut.getrelPositionXY()
   179             blockPointx, blockPointy = variable.connectionPointOut.getrelPositionXY()
   180             if (not connectionPoint or 
   180             if (connectionPoint is None or 
   181                 block.getx() + blockPointx == connectionPoint.getx() and 
   181                 block.getx() + blockPointx == connectionPoint.getx() and 
   182                 block.gety() + blockPointy == connectionPoint.gety()):
   182                 block.gety() + blockPointy == connectionPoint.gety()):
   183                 output_variable = variable
   183                 output_variable = variable
   184                 output_parameter = variable.getformalParameter()
   184                 output_parameter = variable.getformalParameter()
   185                 output_idx = i
   185                 output_idx = i