2 # Generated python file of Graph GraphLoopSwitch
6 GraphLoopSwitch = Graph( 'GraphLoopSwitch' )
7 GraphLoopSwitch.SetName( 'GraphLoopSwitch' )
8 GraphLoopSwitch.SetAuthor( '' )
9 GraphLoopSwitch.SetComment( '' )
10 GraphLoopSwitch.Coords( 0 , 0 )
12 # Creation of Factory Nodes
14 # Creation of InLine Nodes
16 PyIsOdd.append( 'from time import * ' )
17 PyIsOdd.append( 'def IsOdd(a,Even) : ' )
18 PyIsOdd.append( ' print a,"IsOdd (GraphLoopSwitch1)" ' )
19 PyIsOdd.append( ' sleep( 1 ) ' )
20 PyIsOdd.append( ' return a ' )
21 IsOdd = GraphLoopSwitch.INode( 'IsOdd' , PyIsOdd )
22 IsOdd.SetName( 'IsOdd' )
24 IsOdd.SetComment( 'Python function' )
25 IsOdd.Coords( 397 , 1 )
26 IsOdd.InPort( 'a' , 'long' )
27 IsOdd.InPort( 'Even' , 'boolean' )
28 IsOdd.OutPort( 'a' , 'long' )
30 # Creation of Loop Nodes
32 PyInitLoop.append( ' ' )
34 PyMoreInitLoop.append( ' ' )
36 PyNextInitLoop.append( ' ' )
37 InitLoop,EndOfInitLoop = GraphLoopSwitch.LNode( '' , PyInitLoop , '' , PyMoreInitLoop , '' , PyNextInitLoop )
38 EndOfInitLoop.SetName( 'EndOfInitLoop' )
39 EndOfInitLoop.SetAuthor( '' )
40 EndOfInitLoop.SetComment( '' )
41 EndOfInitLoop.Coords( 767 , 102 )
43 PyEndOfInitLoop.append( 'def EndOfInitLoop( DoLoop , Index , Min , Max ) :' )
44 PyEndOfInitLoop.append( ' Index = Index + 1 ' )
45 PyEndOfInitLoop.append( ' if Index <= Max : ' )
46 PyEndOfInitLoop.append( ' DoLoop = 1 ' )
47 PyEndOfInitLoop.append( ' else : ' )
48 PyEndOfInitLoop.append( ' DoLoop = 0 ' )
49 PyEndOfInitLoop.append( ' return DoLoop,Index,Min,Max ' )
50 EndOfInitLoop.SetPyFunction( 'EndOfInitLoop' , PyEndOfInitLoop )
51 InitLoop.SetName( 'InitLoop' )
52 InitLoop.SetAuthor( '' )
53 InitLoop.SetComment( '' )
54 InitLoop.Coords( 10 , 108 )
55 InitLoop.InPort( 'Index' , 'long' )
56 InitLoop.InPort( 'Min' , 'long' )
57 InitLoop.InPort( 'Max' , 'long' )
58 InitLoop.OutPort( 'Index' , 'long' )
59 InitLoop.OutPort( 'Min' , 'long' )
60 InitLoop.OutPort( 'Max' , 'long' )
62 # Creation of Switch Nodes
64 PySwitch.append( 'from time import * ' )
65 PySwitch.append( 'def Switch(a) : ' )
66 PySwitch.append( ' if ( a & 1 ) == 0 : ' )
67 PySwitch.append( ' sleep(1) ' )
68 PySwitch.append( ' return a & 1,1-(a&1),a ' )
69 Switch,EndSwitch = GraphLoopSwitch.SNode( 'Switch' , PySwitch )
70 EndSwitch.SetName( 'EndSwitch' )
71 EndSwitch.SetAuthor( '' )
72 EndSwitch.SetComment( '' )
73 EndSwitch.Coords( 587 , 103 )
75 PyEndSwitch.append( 'def EndSwitch(a) : ' )
76 PyEndSwitch.append( ' if ( a & 1 ) == 0 : ' )
77 PyEndSwitch.append( ' sleep(1) ' )
78 PyEndSwitch.append( ' return a ' )
79 EndSwitch.SetPyFunction( 'EndSwitch' , PyEndSwitch )
80 EndSwitch.InPort( 'a' , 'long' )
81 EndSwitch.OutPort( 'a' , 'long' )
82 Switch.SetName( 'Switch' )
83 Switch.SetAuthor( '' )
84 Switch.SetComment( '' )
85 Switch.Coords( 194 , 109 )
86 Switch.InPort( 'a' , 'long' )
87 Switch.OutPort( 'Odd' , 'long' )
88 Switch.OutPort( 'Even' , 'int' )
89 Switch.OutPort( 'a' , 'int' )
92 IsOdda = IsOdd.Port( 'a' )
93 EndSwitcha = GraphLoopSwitch.Link( IsOdda , EndSwitch.Port( 'a' ) )
94 EndSwitcha.AddCoord( 1 , 576 , 136 )
95 EndSwitcha.AddCoord( 2 , 575 , 81 )
97 InitLoopIndex = InitLoop.Port( 'Index' )
98 Switcha = GraphLoopSwitch.Link( InitLoopIndex , Switch.Port( 'a' ) )
100 InitLoopMin = InitLoop.Port( 'Min' )
101 EndOfInitLoopMin = GraphLoopSwitch.Link( InitLoopMin , EndOfInitLoop.Port( 'Min' ) )
103 InitLoopMax = InitLoop.Port( 'Max' )
104 EndOfInitLoopMax = GraphLoopSwitch.Link( InitLoopMax , EndOfInitLoop.Port( 'Max' ) )
106 SwitchOdd = Switch.Port( 'Odd' )
107 IsOddInGate = GraphLoopSwitch.Link( SwitchOdd , IsOdd.Port( 'InGate' ) )
109 SwitchEven = Switch.Port( 'Even' )
110 EndSwitchDefault = GraphLoopSwitch.Link( SwitchEven , EndSwitch.Port( 'Default' ) )
112 IsOddEven = GraphLoopSwitch.Link( SwitchEven , IsOdd.Port( 'Even' ) )
113 IsOddEven.AddCoord( 1 , 375 , 111 )
114 IsOddEven.AddCoord( 2 , 375 , 172 )
116 Switcha = Switch.Port( 'a' )
117 IsOdda = GraphLoopSwitch.Link( Switcha , IsOdd.Port( 'a' ) )
118 IsOdda.AddCoord( 1 , 362 , 82 )
119 IsOdda.AddCoord( 2 , 360 , 201 )
121 EndSwitcha = EndSwitch.Port( 'a' )
122 EndOfInitLoopIndex = GraphLoopSwitch.Link( EndSwitcha , EndOfInitLoop.Port( 'Index' ) )
124 # Creation of Input datas
125 InitLoopIndex = InitLoop.Input( 'Index' , 0)
126 InitLoopMin = InitLoop.Input( 'Min' , 0)
127 InitLoopMax = InitLoop.Input( 'Max' , 100)
129 # Creation of Output variables
130 EndOfInitLoopIndex = EndOfInitLoop.Port( 'Index' )
131 EndOfInitLoopMin = EndOfInitLoop.Port( 'Min' )
132 EndOfInitLoopMax = EndOfInitLoop.Port( 'Max' )
134 GraphLoopSwitch.Run()
135 GraphLoopSwitch.DoneW()
136 GraphLoopSwitch.State()
137 GraphLoopSwitch.PrintPorts()