67 self.Output.Flush() |
70 self.Output.Flush() |
68 self.Output = None |
71 self.Output = None |
69 if self.Output is not None: |
72 if self.Output is not None: |
70 self.Action.Flush() |
73 self.Action.Flush() |
71 self.Action = None |
74 self.Action = None |
|
75 |
|
76 def SetValue(self, value): |
|
77 self.PreviousValue = self.Value |
|
78 self.Value = value |
|
79 if self.Value != self.PreviousValue: |
|
80 self.Refresh() |
|
81 self.SpreadCurrent() |
|
82 |
|
83 def SpreadCurrent(self): |
|
84 if self.Parent.Debug: |
|
85 spreading = self.Value |
|
86 if spreading and not self.PreviousSpreading: |
|
87 self.Output.SpreadCurrent(True) |
|
88 if self.Action is not None: |
|
89 self.Action.SpreadCurrent(True) |
|
90 elif not spreading and self.PreviousSpreading: |
|
91 self.Output.SpreadCurrent(False) |
|
92 if self.Action is not None: |
|
93 self.Action.SpreadCurrent(False) |
|
94 self.PreviousSpreading = spreading |
72 |
95 |
73 # Make a clone of this SFC_Step |
96 # Make a clone of this SFC_Step |
74 def Clone(self, parent, id = None, name = "Step", pos = None): |
97 def Clone(self, parent, id = None, name = "Step", pos = None): |
75 step = SFC_Step(parent, name, self.Initial, id) |
98 step = SFC_Step(parent, name, self.Initial, id) |
76 step.SetSize(self.Size[0], self.Size[1]) |
99 step.SetSize(self.Size[0], self.Size[1]) |
470 self.Error = (start[1], end[1]) |
493 self.Error = (start[1], end[1]) |
471 |
494 |
472 # Draws step |
495 # Draws step |
473 def Draw(self, dc): |
496 def Draw(self, dc): |
474 Graphic_Element.Draw(self, dc) |
497 Graphic_Element.Draw(self, dc) |
475 dc.SetPen(wx.BLACK_PEN) |
498 if self.Value: |
|
499 dc.SetPen(wx.GREEN_PEN) |
|
500 else: |
|
501 dc.SetPen(wx.BLACK_PEN) |
476 dc.SetBrush(wx.WHITE_BRUSH) |
502 dc.SetBrush(wx.WHITE_BRUSH) |
477 |
503 |
478 if getattr(dc, "printing", False): |
504 if getattr(dc, "printing", False): |
479 name_size = dc.GetTextExtent(self.Name) |
505 name_size = dc.GetTextExtent(self.Name) |
480 else: |
506 else: |
520 self.Input = Connector(self, "", None, wx.Point(self.Size[0] / 2, 0), NORTH, onlyone = True) |
546 self.Input = Connector(self, "", None, wx.Point(self.Size[0] / 2, 0), NORTH, onlyone = True) |
521 self.Output = Connector(self, "", None, wx.Point(self.Size[0] / 2, self.Size[1]), SOUTH, onlyone = True) |
547 self.Output = Connector(self, "", None, wx.Point(self.Size[0] / 2, self.Size[1]), SOUTH, onlyone = True) |
522 self.SetType(type, condition) |
548 self.SetType(type, condition) |
523 self.SetPriority(priority) |
549 self.SetPriority(priority) |
524 self.Errors = {} |
550 self.Errors = {} |
|
551 self.Value = None |
|
552 self.PreviousValue = None |
|
553 self.PreviousSpreading = False |
525 |
554 |
526 def Flush(self): |
555 def Flush(self): |
527 if self.Input is not None: |
556 if self.Input is not None: |
528 self.Input.Flush() |
557 self.Input.Flush() |
529 self.Input = None |
558 self.Input = None |
531 self.Output.Flush() |
560 self.Output.Flush() |
532 self.Output = None |
561 self.Output = None |
533 if self.Type == "connection" and self.Condition is not None: |
562 if self.Type == "connection" and self.Condition is not None: |
534 self.Condition.Flush() |
563 self.Condition.Flush() |
535 self.Condition = None |
564 self.Condition = None |
|
565 |
|
566 def SetValue(self, value): |
|
567 self.PreviousValue = self.Value |
|
568 self.Value = value |
|
569 if self.Value != self.PreviousValue: |
|
570 self.Refresh() |
|
571 self.SpreadCurrent() |
|
572 |
|
573 def SpreadCurrent(self): |
|
574 if self.Parent.Debug: |
|
575 if self.Value is None: |
|
576 self.Value = False |
|
577 spreading = self.Input.ReceivingCurrent() & self.Value |
|
578 if spreading and not self.PreviousSpreading: |
|
579 self.Output.SpreadCurrent(True) |
|
580 elif not spreading and self.PreviousSpreading: |
|
581 self.Output.SpreadCurrent(False) |
|
582 self.PreviousSpreading = spreading |
536 |
583 |
537 # Make a clone of this SFC_Transition |
584 # Make a clone of this SFC_Transition |
538 def Clone(self, parent, id = None, pos = None): |
585 def Clone(self, parent, id = None, pos = None): |
539 transition = SFC_Transition(parent, self.Type, self.Condition, self.Priority, id) |
586 transition = SFC_Transition(parent, self.Type, self.Condition, self.Priority, id) |
540 transition.SetSize(self.Size[0], self.Size[1]) |
587 transition.SetSize(self.Size[0], self.Size[1]) |
849 pass |
896 pass |
850 |
897 |
851 # Draws transition |
898 # Draws transition |
852 def Draw(self, dc): |
899 def Draw(self, dc): |
853 Graphic_Element.Draw(self, dc) |
900 Graphic_Element.Draw(self, dc) |
854 dc.SetPen(wx.BLACK_PEN) |
901 if self.Value: |
855 dc.SetBrush(wx.BLACK_BRUSH) |
902 dc.SetPen(wx.GREEN_PEN) |
|
903 dc.SetBrush(wx.GREEN_BRUSH) |
|
904 else: |
|
905 dc.SetPen(wx.BLACK_PEN) |
|
906 dc.SetBrush(wx.BLACK_BRUSH) |
856 |
907 |
857 if getattr(dc, "printing", False): |
908 if getattr(dc, "printing", False): |
858 if self.Type != "connection": |
909 if self.Type != "connection": |
859 condition_size = dc.GetTextExtent(self.Condition) |
910 condition_size = dc.GetTextExtent(self.Condition) |
860 if self.Priority != 0: |
911 if self.Priority != 0: |
927 elif self.Type in [SELECTION_CONVERGENCE, SIMULTANEOUS_CONVERGENCE]: |
978 elif self.Type in [SELECTION_CONVERGENCE, SIMULTANEOUS_CONVERGENCE]: |
928 self.Inputs = [] |
979 self.Inputs = [] |
929 for i in xrange(number): |
980 for i in xrange(number): |
930 self.Inputs.append(Connector(self, "", None, wx.Point(i * SFC_DEFAULT_SEQUENCE_INTERVAL, 0), NORTH, onlyone = True)) |
981 self.Inputs.append(Connector(self, "", None, wx.Point(i * SFC_DEFAULT_SEQUENCE_INTERVAL, 0), NORTH, onlyone = True)) |
931 self.Outputs = [Connector(self, "", None, wx.Point(self.Size[0] / 2, self.Size[1]), SOUTH, onlyone = True)] |
982 self.Outputs = [Connector(self, "", None, wx.Point(self.Size[0] / 2, self.Size[1]), SOUTH, onlyone = True)] |
|
983 self.Value = None |
|
984 self.PreviousValue = None |
932 |
985 |
933 def Flush(self): |
986 def Flush(self): |
934 for input in self.Inputs: |
987 for input in self.Inputs: |
935 input.Flush() |
988 input.Flush() |
936 self.Inputs = [] |
989 self.Inputs = [] |
937 for output in self.Outputs: |
990 for output in self.Outputs: |
938 output.Flush() |
991 output.Flush() |
939 self.Outputs = [] |
992 self.Outputs = [] |
|
993 |
|
994 def SpreadCurrent(self): |
|
995 if self.Parent.Debug: |
|
996 self.PreviousValue = self.Value |
|
997 if self.Type == SELECTION_CONVERGENCE: |
|
998 self.Value = False |
|
999 for input in self.Inputs: |
|
1000 self.Value |= input.ReceivingCurrent() |
|
1001 elif self.Type == SIMULTANEOUS_CONVERGENCE: |
|
1002 self.Value = True |
|
1003 for input in self.Inputs: |
|
1004 self.Value &= input.ReceivingCurrent() |
|
1005 elif self.Type in [SELECTION_DIVERGENCE, SIMULTANEOUS_DIVERGENCE]: |
|
1006 self.Value = self.Inputs[0].ReceivingCurrent() |
|
1007 else: |
|
1008 self.Value = False |
|
1009 if self.Value and not self.PreviousValue: |
|
1010 self.Refresh() |
|
1011 for output in self.Outputs: |
|
1012 output.SpreadCurrent(True) |
|
1013 elif not self.Value and self.PreviousValue: |
|
1014 self.Refresh() |
|
1015 for output in self.Outputs: |
|
1016 output.SpreadCurrent(False) |
940 |
1017 |
941 # Make a clone of this SFC_Divergence |
1018 # Make a clone of this SFC_Divergence |
942 def Clone(self, parent, id = None, pos = None): |
1019 def Clone(self, parent, id = None, pos = None): |
943 divergence = SFC_Divergence(parent, self.Type, max(len(self.Inputs), len(self.Outputs)), id) |
1020 divergence = SFC_Divergence(parent, self.Type, max(len(self.Inputs), len(self.Outputs)), id) |
944 divergence.SetSize(self.Size[0], self.Size[1]) |
1021 divergence.SetSize(self.Size[0], self.Size[1]) |
1311 dc.SetLogicalFunction(wx.COPY) |
1388 dc.SetLogicalFunction(wx.COPY) |
1312 |
1389 |
1313 # Draws divergence |
1390 # Draws divergence |
1314 def Draw(self, dc): |
1391 def Draw(self, dc): |
1315 Graphic_Element.Draw(self, dc) |
1392 Graphic_Element.Draw(self, dc) |
1316 dc.SetPen(wx.BLACK_PEN) |
1393 if self.Value: |
1317 dc.SetBrush(wx.BLACK_BRUSH) |
1394 dc.SetPen(wx.GREEN_PEN) |
|
1395 dc.SetBrush(wx.GREEN_BRUSH) |
|
1396 else: |
|
1397 dc.SetPen(wx.BLACK_PEN) |
|
1398 dc.SetBrush(wx.BLACK_BRUSH) |
1318 # Draw plain rectangle for representing the divergence |
1399 # Draw plain rectangle for representing the divergence |
1319 if self.Type in [SELECTION_DIVERGENCE, SELECTION_CONVERGENCE]: |
1400 if self.Type in [SELECTION_DIVERGENCE, SELECTION_CONVERGENCE]: |
1320 dc.DrawRectangle(self.Pos.x, self.Pos.y, self.Size[0] + 1, self.Size[1] + 1) |
1401 dc.DrawRectangle(self.Pos.x, self.Pos.y, self.Size[0] + 1, self.Size[1] + 1) |
1321 elif self.Type in [SIMULTANEOUS_DIVERGENCE, SIMULTANEOUS_CONVERGENCE]: |
1402 elif self.Type in [SIMULTANEOUS_DIVERGENCE, SIMULTANEOUS_CONVERGENCE]: |
1322 dc.DrawLine(self.Pos.x - SFC_SIMULTANEOUS_SEQUENCE_EXTRA, self.Pos.y, |
1403 dc.DrawLine(self.Pos.x - SFC_SIMULTANEOUS_SEQUENCE_EXTRA, self.Pos.y, |
1347 self.Id = id |
1428 self.Id = id |
1348 self.Size = wx.Size(SFC_JUMP_SIZE[0], SFC_JUMP_SIZE[1]) |
1429 self.Size = wx.Size(SFC_JUMP_SIZE[0], SFC_JUMP_SIZE[1]) |
1349 self.Errors = {} |
1430 self.Errors = {} |
1350 # Create an input and output connector |
1431 # Create an input and output connector |
1351 self.Input = Connector(self, "", None, wx.Point(self.Size[0] / 2, 0), NORTH, onlyone = True) |
1432 self.Input = Connector(self, "", None, wx.Point(self.Size[0] / 2, 0), NORTH, onlyone = True) |
|
1433 self.Value = None |
|
1434 self.PreviousValue = None |
1352 |
1435 |
1353 def Flush(self): |
1436 def Flush(self): |
1354 if self.Input is not None: |
1437 if self.Input is not None: |
1355 self.Input.Flush() |
1438 self.Input.Flush() |
1356 self.Input = None |
1439 self.Input = None |
|
1440 |
|
1441 def SpreadCurrent(self): |
|
1442 if self.Parent.Debug: |
|
1443 self.PreviousValue = self.Value |
|
1444 self.Value = self.Input.ReceivingCurrent() |
|
1445 if self.Value != self.PreviousValue: |
|
1446 self.Refresh() |
1357 |
1447 |
1358 # Make a clone of this SFC_Jump |
1448 # Make a clone of this SFC_Jump |
1359 def Clone(self, parent, id = None, pos = None): |
1449 def Clone(self, parent, id = None, pos = None): |
1360 jump = SFC_Jump(parent, self.Target, id) |
1450 jump = SFC_Jump(parent, self.Target, id) |
1361 jump.SetSize(self.Size[0], self.Size[1]) |
1451 jump.SetSize(self.Size[0], self.Size[1]) |
1529 dc.SetLogicalFunction(wx.COPY) |
1619 dc.SetLogicalFunction(wx.COPY) |
1530 |
1620 |
1531 # Draws divergence |
1621 # Draws divergence |
1532 def Draw(self, dc): |
1622 def Draw(self, dc): |
1533 Graphic_Element.Draw(self, dc) |
1623 Graphic_Element.Draw(self, dc) |
1534 dc.SetPen(wx.BLACK_PEN) |
1624 if self.Value: |
1535 dc.SetBrush(wx.BLACK_BRUSH) |
1625 dc.SetPen(wx.GREEN_PEN) |
|
1626 dc.SetBrush(wx.GREEN_BRUSH) |
|
1627 else: |
|
1628 dc.SetPen(wx.BLACK_PEN) |
|
1629 dc.SetBrush(wx.BLACK_BRUSH) |
1536 |
1630 |
1537 if getattr(dc, "printing", False): |
1631 if getattr(dc, "printing", False): |
1538 target_size = dc.GetTextExtent(self.Target) |
1632 target_size = dc.GetTextExtent(self.Target) |
1539 else: |
1633 else: |
1540 target_size = self.TargetSize |
1634 target_size = self.TargetSize |
1574 self.MinSize = wx.Size(SFC_ACTION_MIN_SIZE[0], SFC_ACTION_MIN_SIZE[1]) |
1668 self.MinSize = wx.Size(SFC_ACTION_MIN_SIZE[0], SFC_ACTION_MIN_SIZE[1]) |
1575 self.Errors = {} |
1669 self.Errors = {} |
1576 # Create an input and output connector |
1670 # Create an input and output connector |
1577 self.Input = Connector(self, "", None, wx.Point(0, SFC_ACTION_MIN_SIZE[1] / 2), WEST, onlyone = True) |
1671 self.Input = Connector(self, "", None, wx.Point(0, SFC_ACTION_MIN_SIZE[1] / 2), WEST, onlyone = True) |
1578 self.SetActions(actions) |
1672 self.SetActions(actions) |
|
1673 self.Value = None |
|
1674 self.PreviousValue = None |
1579 |
1675 |
1580 def Flush(self): |
1676 def Flush(self): |
1581 if self.Input is not None: |
1677 if self.Input is not None: |
1582 self.Input.Flush() |
1678 self.Input.Flush() |
1583 self.Input = None |
1679 self.Input = None |
|
1680 |
|
1681 def SpreadCurrent(self): |
|
1682 if self.Parent.Debug: |
|
1683 self.PreviousValue = self.Value |
|
1684 self.Value = self.Input.ReceivingCurrent() |
|
1685 if self.Value != self.PreviousValue: |
|
1686 self.Refresh() |
1584 |
1687 |
1585 # Make a clone of this SFC_ActionBlock |
1688 # Make a clone of this SFC_ActionBlock |
1586 def Clone(self, parent, id = None, pos = None): |
1689 def Clone(self, parent, id = None, pos = None): |
1587 actions = [action.copy() for action in self.Actions] |
1690 actions = [action.copy() for action in self.Actions] |
1588 action_block = SFC_ActionBlock(parent, actions, id) |
1691 action_block = SFC_ActionBlock(parent, actions, id) |
1749 self.Errors[infos[1]][infos[2]] = (start[1], end[1]) |
1852 self.Errors[infos[1]][infos[2]] = (start[1], end[1]) |
1750 |
1853 |
1751 # Draws divergence |
1854 # Draws divergence |
1752 def Draw(self, dc): |
1855 def Draw(self, dc): |
1753 Graphic_Element.Draw(self, dc) |
1856 Graphic_Element.Draw(self, dc) |
1754 dc.SetPen(wx.BLACK_PEN) |
1857 if self.Value: |
|
1858 dc.SetPen(wx.GREEN_PEN) |
|
1859 else: |
|
1860 dc.SetPen(wx.BLACK_PEN) |
1755 dc.SetBrush(wx.WHITE_BRUSH) |
1861 dc.SetBrush(wx.WHITE_BRUSH) |
1756 colsize = [self.ColSize[0], self.Size[0] - self.ColSize[0] - self.ColSize[2], self.ColSize[2]] |
1862 colsize = [self.ColSize[0], self.Size[0] - self.ColSize[0] - self.ColSize[2], self.ColSize[2]] |
1757 # Draw plain rectangle for representing the action block |
1863 # Draw plain rectangle for representing the action block |
1758 dc.DrawRectangle(self.Pos.x, self.Pos.y, self.Size[0] + 1, self.Size[1] + 1) |
1864 dc.DrawRectangle(self.Pos.x, self.Pos.y, self.Size[0] + 1, self.Size[1] + 1) |
1759 dc.DrawLine(self.Pos.x + colsize[0], self.Pos.y, |
1865 dc.DrawLine(self.Pos.x + colsize[0], self.Pos.y, |