editors/SFCViewer.py
changeset 1744 69dfdb26f600
parent 1743 c3c3d1318130
child 1745 f9d32913bad4
equal deleted inserted replaced
1743:c3c3d1318130 1744:69dfdb26f600
    80         "LD_PowerRail": [("SFC_Transition", WEST)],
    80         "LD_PowerRail": [("SFC_Transition", WEST)],
    81 
    81 
    82         "LD_Coil": [("SFC_Transition", WEST)]
    82         "LD_Coil": [("SFC_Transition", WEST)]
    83     }
    83     }
    84 
    84 
    85     def __init__(self, parent, tagname, window, controler, debug = False, instancepath = ""):
    85     def __init__(self, parent, tagname, window, controler, debug=False, instancepath=""):
    86         Viewer.__init__(self, parent, tagname, window, controler, debug, instancepath)
    86         Viewer.__init__(self, parent, tagname, window, controler, debug, instancepath)
    87         self.CurrentLanguage = "SFC"
    87         self.CurrentLanguage = "SFC"
    88 
    88 
    89     def ConnectConnectors(self, start, end):
    89     def ConnectConnectors(self, start, end):
    90         startpoint = [start.GetPosition(False), start.GetDirection()]
    90         startpoint = [start.GetPosition(False), start.GetDirection()]
    95         end.Connect((wire, -1), False)
    95         end.Connect((wire, -1), False)
    96         wire.ConnectStartPoint(None, start)
    96         wire.ConnectStartPoint(None, start)
    97         wire.ConnectEndPoint(None, end)
    97         wire.ConnectEndPoint(None, end)
    98         return wire
    98         return wire
    99 
    99 
   100     def CreateTransition(self, connector, next = None):
   100     def CreateTransition(self, connector, next=None):
   101         previous = connector.GetParentBlock()
   101         previous = connector.GetParentBlock()
   102         id = self.GetNewId()
   102         id = self.GetNewId()
   103         transition = SFC_Transition(self, "reference", "", 0, id)
   103         transition = SFC_Transition(self, "reference", "", 0, id)
   104         pos = connector.GetPosition(False)
   104         pos = connector.GetPosition(False)
   105         transition.SetPosition(pos.x, pos.y + SFC_WIRE_MIN_SIZE)
   105         transition.SetPosition(pos.x, pos.y + SFC_WIRE_MIN_SIZE)
   145         self.RemoveBlock(transition)
   145         self.RemoveBlock(transition)
   146         self.Controler.RemoveEditedElementInstance(self.TagName, transition.GetId())
   146         self.Controler.RemoveEditedElementInstance(self.TagName, transition.GetId())
   147         wire = self.ConnectConnectors(next, previous)
   147         wire = self.ConnectConnectors(next, previous)
   148         return wire
   148         return wire
   149 
   149 
   150     def CreateStep(self, name, connector, next = None):
   150     def CreateStep(self, name, connector, next=None):
   151         previous = connector.GetParentBlock()
   151         previous = connector.GetParentBlock()
   152         id = self.GetNewId()
   152         id = self.GetNewId()
   153         step = SFC_Step(self, name, False, id)
   153         step = SFC_Step(self, name, False, id)
   154         if next:
   154         if next:
   155             step.AddOutput()
   155             step.AddOutput()
   339         if blockName == "SFC_Divergence":
   339         if blockName == "SFC_Divergence":
   340             blockName = block.Type
   340             blockName = block.Type
   341         return blockName
   341         return blockName
   342 
   342 
   343     # This method check the IEC 61131-3 compatibility between two SFC blocks
   343     # This method check the IEC 61131-3 compatibility between two SFC blocks
   344     def BlockCompatibility(self, startblock = None, endblock = None, direction = None):
   344     def BlockCompatibility(self, startblock=None, endblock=None, direction=None):
   345         if startblock is not None and endblock is not None and (isinstance(startblock, SFC_Objects)\
   345         if startblock is not None and endblock is not None and (isinstance(startblock, SFC_Objects)\
   346                                                                or isinstance(endblock, SFC_Objects)):
   346                                                                or isinstance(endblock, SFC_Objects)):
   347             # Full "SFC_StandardRules" table would be symmetrical and
   347             # Full "SFC_StandardRules" table would be symmetrical and
   348             # to avoid duplicate records and minimize the table only upper part is defined.
   348             # to avoid duplicate records and minimize the table only upper part is defined.
   349             if (direction == SOUTH or direction == EAST):
   349             if (direction == SOUTH or direction == EAST):