39 |
39 |
40 """ |
40 """ |
41 Class that implements the graphic representation of a step |
41 Class that implements the graphic representation of a step |
42 """ |
42 """ |
43 |
43 |
44 class SFC_Step(Graphic_Element): |
44 class SFC_Step(Graphic_Element, DebugDataConsumer): |
45 |
45 |
46 # Create a new step |
46 # Create a new step |
47 def __init__(self, parent, name, initial = False, id = None): |
47 def __init__(self, parent, name, initial = False, id = None): |
48 Graphic_Element.__init__(self, parent) |
48 Graphic_Element.__init__(self, parent) |
|
49 DebugDataConsumer.__init__(self) |
49 self.SetName(name) |
50 self.SetName(name) |
50 self.Initial = initial |
51 self.Initial = initial |
51 self.Id = id |
52 self.Id = id |
52 self.Error = None |
53 self.Error = None |
53 self.Size = wx.Size(SFC_STEP_DEFAULT_SIZE[0], SFC_STEP_DEFAULT_SIZE[1]) |
54 self.Size = wx.Size(SFC_STEP_DEFAULT_SIZE[0], SFC_STEP_DEFAULT_SIZE[1]) |
56 self.Input = Connector(self, "", None, wx.Point(self.Size[0] / 2, 0), NORTH) |
57 self.Input = Connector(self, "", None, wx.Point(self.Size[0] / 2, 0), NORTH) |
57 else: |
58 else: |
58 self.Input = None |
59 self.Input = None |
59 self.Output = None |
60 self.Output = None |
60 self.Action = None |
61 self.Action = None |
61 self.Value = None |
|
62 self.PreviousValue = None |
62 self.PreviousValue = None |
63 self.PreviousSpreading = False |
63 self.PreviousSpreading = False |
64 |
64 |
65 def Flush(self): |
65 def Flush(self): |
66 if self.Input is not None: |
66 if self.Input is not None: |
75 |
75 |
76 def SetValue(self, value): |
76 def SetValue(self, value): |
77 self.PreviousValue = self.Value |
77 self.PreviousValue = self.Value |
78 self.Value = value |
78 self.Value = value |
79 if self.Value != self.PreviousValue: |
79 if self.Value != self.PreviousValue: |
80 self.Refresh() |
80 self.Parent.UpdateRefreshRect(self.GetRedrawRect()) |
81 self.SpreadCurrent() |
81 self.SpreadCurrent() |
82 |
82 |
83 def SpreadCurrent(self): |
83 def SpreadCurrent(self): |
84 if self.Parent.Debug: |
84 if self.Parent.Debug: |
85 spreading = self.Value |
85 spreading = self.Value |
545 |
545 |
546 """ |
546 """ |
547 Class that implements the graphic representation of a transition |
547 Class that implements the graphic representation of a transition |
548 """ |
548 """ |
549 |
549 |
550 class SFC_Transition(Graphic_Element): |
550 class SFC_Transition(Graphic_Element, DebugDataConsumer): |
551 |
551 |
552 # Create a new transition |
552 # Create a new transition |
553 def __init__(self, parent, type = "reference", condition = None, priority = 0, id = None): |
553 def __init__(self, parent, type = "reference", condition = None, priority = 0, id = None): |
554 Graphic_Element.__init__(self, parent) |
554 Graphic_Element.__init__(self, parent) |
|
555 DebugDataConsumer.__init__(self) |
555 self.Type = None |
556 self.Type = None |
556 self.Id = id |
557 self.Id = id |
557 self.Priority = 0 |
558 self.Priority = 0 |
558 self.Size = wx.Size(SFC_TRANSITION_SIZE[0], SFC_TRANSITION_SIZE[1]) |
559 self.Size = wx.Size(SFC_TRANSITION_SIZE[0], SFC_TRANSITION_SIZE[1]) |
559 # Create an input and output connector |
560 # Create an input and output connector |
560 self.Input = Connector(self, "", None, wx.Point(self.Size[0] / 2, 0), NORTH, onlyone = True) |
561 self.Input = Connector(self, "", None, wx.Point(self.Size[0] / 2, 0), NORTH, onlyone = True) |
561 self.Output = Connector(self, "", None, wx.Point(self.Size[0] / 2, self.Size[1]), SOUTH, onlyone = True) |
562 self.Output = Connector(self, "", None, wx.Point(self.Size[0] / 2, self.Size[1]), SOUTH, onlyone = True) |
562 self.SetType(type, condition) |
563 self.SetType(type, condition) |
563 self.SetPriority(priority) |
564 self.SetPriority(priority) |
564 self.Errors = {} |
565 self.Errors = {} |
565 self.Value = None |
|
566 self.PreviousValue = None |
566 self.PreviousValue = None |
567 self.PreviousSpreading = False |
567 self.PreviousSpreading = False |
568 |
568 |
569 def Flush(self): |
569 def Flush(self): |
570 if self.Input is not None: |
570 if self.Input is not None: |
579 |
579 |
580 def SetValue(self, value): |
580 def SetValue(self, value): |
581 self.PreviousValue = self.Value |
581 self.PreviousValue = self.Value |
582 self.Value = value |
582 self.Value = value |
583 if self.Value != self.PreviousValue: |
583 if self.Value != self.PreviousValue: |
584 self.Refresh() |
584 self.Parent.UpdateRefreshRect(self.GetRedrawRect()) |
585 self.SpreadCurrent() |
585 self.SpreadCurrent() |
586 |
586 |
587 def SpreadCurrent(self): |
587 def SpreadCurrent(self): |
588 if self.Parent.Debug: |
588 if self.Parent.Debug: |
589 if self.Value is None: |
589 if self.Value is None: |
1027 elif self.Type in [SELECTION_DIVERGENCE, SIMULTANEOUS_DIVERGENCE]: |
1027 elif self.Type in [SELECTION_DIVERGENCE, SIMULTANEOUS_DIVERGENCE]: |
1028 self.Value = self.Inputs[0].ReceivingCurrent() |
1028 self.Value = self.Inputs[0].ReceivingCurrent() |
1029 else: |
1029 else: |
1030 self.Value = False |
1030 self.Value = False |
1031 if self.Value and not self.PreviousValue: |
1031 if self.Value and not self.PreviousValue: |
1032 self.Refresh() |
1032 self.Parent.UpdateRefreshRect(self.GetRedrawRect()) |
1033 for output in self.Outputs: |
1033 for output in self.Outputs: |
1034 output.SpreadCurrent(True) |
1034 output.SpreadCurrent(True) |
1035 elif not self.Value and self.PreviousValue: |
1035 elif not self.Value and self.PreviousValue: |
1036 self.Refresh() |
1036 self.Parent.UpdateRefreshRect(self.GetRedrawRect()) |
1037 for output in self.Outputs: |
1037 for output in self.Outputs: |
1038 output.SpreadCurrent(False) |
1038 output.SpreadCurrent(False) |
1039 |
1039 |
1040 # Make a clone of this SFC_Divergence |
1040 # Make a clone of this SFC_Divergence |
1041 def Clone(self, parent, id = None, pos = None): |
1041 def Clone(self, parent, id = None, pos = None): |
1467 def SpreadCurrent(self): |
1467 def SpreadCurrent(self): |
1468 if self.Parent.Debug: |
1468 if self.Parent.Debug: |
1469 self.PreviousValue = self.Value |
1469 self.PreviousValue = self.Value |
1470 self.Value = self.Input.ReceivingCurrent() |
1470 self.Value = self.Input.ReceivingCurrent() |
1471 if self.Value != self.PreviousValue: |
1471 if self.Value != self.PreviousValue: |
1472 self.Refresh() |
1472 self.Parent.UpdateRefreshRect(self.GetRedrawRect()) |
1473 |
1473 |
1474 # Make a clone of this SFC_Jump |
1474 # Make a clone of this SFC_Jump |
1475 def Clone(self, parent, id = None, pos = None): |
1475 def Clone(self, parent, id = None, pos = None): |
1476 jump = SFC_Jump(parent, self.Target, id) |
1476 jump = SFC_Jump(parent, self.Target, id) |
1477 jump.SetSize(self.Size[0], self.Size[1]) |
1477 jump.SetSize(self.Size[0], self.Size[1]) |
1712 def SpreadCurrent(self): |
1712 def SpreadCurrent(self): |
1713 if self.Parent.Debug: |
1713 if self.Parent.Debug: |
1714 self.PreviousValue = self.Value |
1714 self.PreviousValue = self.Value |
1715 self.Value = self.Input.ReceivingCurrent() |
1715 self.Value = self.Input.ReceivingCurrent() |
1716 if self.Value != self.PreviousValue: |
1716 if self.Value != self.PreviousValue: |
1717 self.Refresh() |
1717 self.Parent.UpdateRefreshRect(self.GetRedrawRect()) |
1718 |
1718 |
1719 # Make a clone of this SFC_ActionBlock |
1719 # Make a clone of this SFC_ActionBlock |
1720 def Clone(self, parent, id = None, pos = None): |
1720 def Clone(self, parent, id = None, pos = None): |
1721 actions = [action.copy() for action in self.Actions] |
1721 actions = [action.copy() for action in self.Actions] |
1722 action_block = SFC_ActionBlock(parent, actions, id) |
1722 action_block = SFC_ActionBlock(parent, actions, id) |