--- a/graphics/SFC_Objects.py Sun Sep 07 15:27:53 2008 +0200
+++ b/graphics/SFC_Objects.py Sun Sep 07 15:29:12 2008 +0200
@@ -58,6 +58,9 @@
self.Input = None
self.Output = None
self.Action = None
+ self.Value = None
+ self.PreviousValue = None
+ self.PreviousSpreading = False
def Flush(self):
if self.Input is not None:
@@ -70,6 +73,26 @@
self.Action.Flush()
self.Action = None
+ def SetValue(self, value):
+ self.PreviousValue = self.Value
+ self.Value = value
+ if self.Value != self.PreviousValue:
+ self.Refresh()
+ self.SpreadCurrent()
+
+ def SpreadCurrent(self):
+ if self.Parent.Debug:
+ spreading = self.Value
+ if spreading and not self.PreviousSpreading:
+ self.Output.SpreadCurrent(True)
+ if self.Action is not None:
+ self.Action.SpreadCurrent(True)
+ elif not spreading and self.PreviousSpreading:
+ self.Output.SpreadCurrent(False)
+ if self.Action is not None:
+ self.Action.SpreadCurrent(False)
+ self.PreviousSpreading = spreading
+
# Make a clone of this SFC_Step
def Clone(self, parent, id = None, name = "Step", pos = None):
step = SFC_Step(parent, name, self.Initial, id)
@@ -472,7 +495,10 @@
# Draws step
def Draw(self, dc):
Graphic_Element.Draw(self, dc)
- dc.SetPen(wx.BLACK_PEN)
+ if self.Value:
+ dc.SetPen(wx.GREEN_PEN)
+ else:
+ dc.SetPen(wx.BLACK_PEN)
dc.SetBrush(wx.WHITE_BRUSH)
if getattr(dc, "printing", False):
@@ -522,6 +548,9 @@
self.SetType(type, condition)
self.SetPriority(priority)
self.Errors = {}
+ self.Value = None
+ self.PreviousValue = None
+ self.PreviousSpreading = False
def Flush(self):
if self.Input is not None:
@@ -534,6 +563,24 @@
self.Condition.Flush()
self.Condition = None
+ def SetValue(self, value):
+ self.PreviousValue = self.Value
+ self.Value = value
+ if self.Value != self.PreviousValue:
+ self.Refresh()
+ self.SpreadCurrent()
+
+ def SpreadCurrent(self):
+ if self.Parent.Debug:
+ if self.Value is None:
+ self.Value = False
+ spreading = self.Input.ReceivingCurrent() & self.Value
+ if spreading and not self.PreviousSpreading:
+ self.Output.SpreadCurrent(True)
+ elif not spreading and self.PreviousSpreading:
+ self.Output.SpreadCurrent(False)
+ self.PreviousSpreading = spreading
+
# Make a clone of this SFC_Transition
def Clone(self, parent, id = None, pos = None):
transition = SFC_Transition(parent, self.Type, self.Condition, self.Priority, id)
@@ -851,8 +898,12 @@
# Draws transition
def Draw(self, dc):
Graphic_Element.Draw(self, dc)
- dc.SetPen(wx.BLACK_PEN)
- dc.SetBrush(wx.BLACK_BRUSH)
+ if self.Value:
+ dc.SetPen(wx.GREEN_PEN)
+ dc.SetBrush(wx.GREEN_BRUSH)
+ else:
+ dc.SetPen(wx.BLACK_PEN)
+ dc.SetBrush(wx.BLACK_BRUSH)
if getattr(dc, "printing", False):
if self.Type != "connection":
@@ -929,6 +980,8 @@
for i in xrange(number):
self.Inputs.append(Connector(self, "", None, wx.Point(i * SFC_DEFAULT_SEQUENCE_INTERVAL, 0), NORTH, onlyone = True))
self.Outputs = [Connector(self, "", None, wx.Point(self.Size[0] / 2, self.Size[1]), SOUTH, onlyone = True)]
+ self.Value = None
+ self.PreviousValue = None
def Flush(self):
for input in self.Inputs:
@@ -938,6 +991,30 @@
output.Flush()
self.Outputs = []
+ def SpreadCurrent(self):
+ if self.Parent.Debug:
+ self.PreviousValue = self.Value
+ if self.Type == SELECTION_CONVERGENCE:
+ self.Value = False
+ for input in self.Inputs:
+ self.Value |= input.ReceivingCurrent()
+ elif self.Type == SIMULTANEOUS_CONVERGENCE:
+ self.Value = True
+ for input in self.Inputs:
+ self.Value &= input.ReceivingCurrent()
+ elif self.Type in [SELECTION_DIVERGENCE, SIMULTANEOUS_DIVERGENCE]:
+ self.Value = self.Inputs[0].ReceivingCurrent()
+ else:
+ self.Value = False
+ if self.Value and not self.PreviousValue:
+ self.Refresh()
+ for output in self.Outputs:
+ output.SpreadCurrent(True)
+ elif not self.Value and self.PreviousValue:
+ self.Refresh()
+ for output in self.Outputs:
+ output.SpreadCurrent(False)
+
# Make a clone of this SFC_Divergence
def Clone(self, parent, id = None, pos = None):
divergence = SFC_Divergence(parent, self.Type, max(len(self.Inputs), len(self.Outputs)), id)
@@ -1313,8 +1390,12 @@
# Draws divergence
def Draw(self, dc):
Graphic_Element.Draw(self, dc)
- dc.SetPen(wx.BLACK_PEN)
- dc.SetBrush(wx.BLACK_BRUSH)
+ if self.Value:
+ dc.SetPen(wx.GREEN_PEN)
+ dc.SetBrush(wx.GREEN_BRUSH)
+ else:
+ dc.SetPen(wx.BLACK_PEN)
+ dc.SetBrush(wx.BLACK_BRUSH)
# Draw plain rectangle for representing the divergence
if self.Type in [SELECTION_DIVERGENCE, SELECTION_CONVERGENCE]:
dc.DrawRectangle(self.Pos.x, self.Pos.y, self.Size[0] + 1, self.Size[1] + 1)
@@ -1349,12 +1430,21 @@
self.Errors = {}
# Create an input and output connector
self.Input = Connector(self, "", None, wx.Point(self.Size[0] / 2, 0), NORTH, onlyone = True)
+ self.Value = None
+ self.PreviousValue = None
def Flush(self):
if self.Input is not None:
self.Input.Flush()
self.Input = None
+ def SpreadCurrent(self):
+ if self.Parent.Debug:
+ self.PreviousValue = self.Value
+ self.Value = self.Input.ReceivingCurrent()
+ if self.Value != self.PreviousValue:
+ self.Refresh()
+
# Make a clone of this SFC_Jump
def Clone(self, parent, id = None, pos = None):
jump = SFC_Jump(parent, self.Target, id)
@@ -1531,8 +1621,12 @@
# Draws divergence
def Draw(self, dc):
Graphic_Element.Draw(self, dc)
- dc.SetPen(wx.BLACK_PEN)
- dc.SetBrush(wx.BLACK_BRUSH)
+ if self.Value:
+ dc.SetPen(wx.GREEN_PEN)
+ dc.SetBrush(wx.GREEN_BRUSH)
+ else:
+ dc.SetPen(wx.BLACK_PEN)
+ dc.SetBrush(wx.BLACK_BRUSH)
if getattr(dc, "printing", False):
target_size = dc.GetTextExtent(self.Target)
@@ -1576,12 +1670,21 @@
# Create an input and output connector
self.Input = Connector(self, "", None, wx.Point(0, SFC_ACTION_MIN_SIZE[1] / 2), WEST, onlyone = True)
self.SetActions(actions)
+ self.Value = None
+ self.PreviousValue = None
def Flush(self):
if self.Input is not None:
self.Input.Flush()
self.Input = None
+ def SpreadCurrent(self):
+ if self.Parent.Debug:
+ self.PreviousValue = self.Value
+ self.Value = self.Input.ReceivingCurrent()
+ if self.Value != self.PreviousValue:
+ self.Refresh()
+
# Make a clone of this SFC_ActionBlock
def Clone(self, parent, id = None, pos = None):
actions = [action.copy() for action in self.Actions]
@@ -1751,7 +1854,10 @@
# Draws divergence
def Draw(self, dc):
Graphic_Element.Draw(self, dc)
- dc.SetPen(wx.BLACK_PEN)
+ if self.Value:
+ dc.SetPen(wx.GREEN_PEN)
+ else:
+ dc.SetPen(wx.BLACK_PEN)
dc.SetBrush(wx.WHITE_BRUSH)
colsize = [self.ColSize[0], self.Size[0] - self.ColSize[0] - self.ColSize[2], self.ColSize[2]]
# Draw plain rectangle for representing the action block