2 # Generated python file of Graph GraphSwitch
6 GraphPyFunctions = Graph( 'GraphPyFunctions' )
7 GraphPyFunctions.SetName( 'GraphPyFunctions' )
8 GraphPyFunctions.SetAuthor( '' )
9 GraphPyFunctions.SetComment( '' )
10 GraphPyFunctions.Coords( 0 , 0 )
12 # Creation of Factory Nodes
14 # Creation of InLine Nodes
16 IsOdd = GraphPyFunctions.INode( 'IsOdd' , PyIsOdd )
17 IsOdd.SetName( 'IsOdd' )
19 IsOdd.SetComment( 'Python function' )
20 IsOdd.Coords( 388 , 50 )
21 IsOdd.InPort( 'a' , 'long' )
22 IsOdd.OutPort( 'a' , 'long' )
25 PyIsOdd_1.append( 'from time import * ' )
26 PyIsOdd_1.append( 'def IsOdd(a) : ' )
27 PyIsOdd_1.append( ' print a,"IsOdd" ' )
28 PyIsOdd_1.append( ' sleep( 1 ) ' )
29 PyIsOdd_1.append( ' return a ' )
30 IsOdd_1 = GraphPyFunctions.INode( 'IsOdd' , PyIsOdd_1 )
31 IsOdd_1.SetName( 'IsOdd_1' )
32 IsOdd_1.SetAuthor( '' )
33 IsOdd_1.SetComment( 'Python function' )
34 IsOdd_1.Coords( 391 , 288 )
35 IsOdd_1.InPort( 'a' , 'long' )
36 IsOdd_1.OutPort( 'a' , 'long' )
38 # Creation of Loop Nodes
40 PyInitLoop.append( 'def InitLoop(Index,Min,Max) : ' )
41 PyInitLoop.append( ' return Index,Min,Max ' )
43 PyMoreInitLoop.append( 'def MoreLoop(Index,Min,Max) : ' )
44 PyMoreInitLoop.append( ' if Index <= Max : ' )
45 PyMoreInitLoop.append( ' DoLoop = 1 ' )
46 PyMoreInitLoop.append( ' else : ' )
47 PyMoreInitLoop.append( ' DoLoop = 0 ' )
48 PyMoreInitLoop.append( ' return DoLoop,Index,Min,Max ' )
50 PyNextInitLoop.append( 'def NextLoop(Index,Min,Max) : ' )
51 PyNextInitLoop.append( ' Index = Index + 1 ' )
52 PyNextInitLoop.append( ' return Index,Min,Max ' )
53 InitLoop,EndOfInitLoop = GraphPyFunctions.LNode( 'InitLoop' , PyInitLoop , 'MoreLoop' , PyMoreInitLoop , 'NextLoop' , PyNextInitLoop )
54 EndOfInitLoop.SetName( 'EndOfInitLoop' )
55 EndOfInitLoop.SetAuthor( '' )
56 EndOfInitLoop.SetComment( '' )
57 EndOfInitLoop.Coords( 766 , 127 )
59 EndOfInitLoop.SetPyFunction( 'EndInitLoop' , PyEndOfInitLoop )
60 InitLoop.SetName( 'InitLoop' )
61 InitLoop.SetAuthor( '' )
62 InitLoop.SetComment( '' )
63 InitLoop.Coords( 10 , 129 )
64 InitLoop.InPort( 'Index' , 'long' )
65 InitLoop.InPort( 'Min' , 'long' )
66 InitLoop.InPort( 'Max' , 'long' )
67 InitLoop.OutPort( 'Index' , 'long' )
68 InitLoop.OutPort( 'Min' , 'long' )
69 InitLoop.OutPort( 'Max' , 'long' )
73 PyMoreInitLoop_1.append( '' )
75 PyNextInitLoop_1.append( '' )
76 InitLoop_1,EndOfInitLoop_1 = GraphPyFunctions.LNode( 'InitLoop' , PyInitLoop_1 , 'MoreLoop' , PyMoreInitLoop_1 , 'NextLoop' , PyNextInitLoop_1 )
77 EndOfInitLoop_1.SetName( 'EndOfInitLoop_1' )
78 EndOfInitLoop_1.SetAuthor( '' )
79 EndOfInitLoop_1.SetComment( '' )
80 EndOfInitLoop_1.Coords( 784 , 361 )
81 PyEndOfInitLoop_1 = []
82 EndOfInitLoop_1.SetPyFunction( 'EndInitLoop' , PyEndOfInitLoop_1 )
83 InitLoop_1.SetName( 'InitLoop_1' )
84 InitLoop_1.SetAuthor( '' )
85 InitLoop_1.SetComment( '' )
86 InitLoop_1.Coords( 12 , 369 )
87 InitLoop_1.InPort( 'Index' , 'long' )
88 InitLoop_1.InPort( 'Min' , 'long' )
89 InitLoop_1.InPort( 'Max' , 'long' )
90 InitLoop_1.OutPort( 'Index' , 'long' )
91 InitLoop_1.OutPort( 'Min' , 'long' )
92 InitLoop_1.OutPort( 'Max' , 'long' )
94 # Creation of Switch Nodes
96 Switch,EndOfSwitch = GraphPyFunctions.SNode( 'Switch' , PySwitch )
97 EndOfSwitch.SetName( 'EndOfSwitch' )
98 EndOfSwitch.SetAuthor( '' )
99 EndOfSwitch.SetComment( '' )
100 EndOfSwitch.Coords( 587 , 126 )
102 EndOfSwitch.SetPyFunction( 'EndOfSwitch_1' , PyEndOfSwitch )
103 EndOfSwitch.InPort( 'a' , 'long' )
104 EndOfSwitch.OutPort( 'a' , 'long' )
105 Switch.SetName( 'Switch' )
106 Switch.SetAuthor( '' )
107 Switch.SetComment( '' )
108 Switch.Coords( 186 , 130 )
109 Switch.InPort( 'a' , 'long' )
110 Switch.OutPort( 'Odd' , 'long' )
111 Switch.OutPort( 'Even' , 'int' )
112 Switch.OutPort( 'a' , 'int' )
115 PySwitch_1.append( 'from time import * ' )
116 PySwitch_1.append( 'def Switch(a) : ' )
117 PySwitch_1.append( ' if ( a & 1 ) == 0 : ' )
118 PySwitch_1.append( ' sleep(1) ' )
119 PySwitch_1.append( ' return a & 1,1-(a&1),a ' )
120 Switch_1,EndOfSwitch_1 = GraphPyFunctions.SNode( 'Switch' , PySwitch_1 )
121 EndOfSwitch_1.SetName( 'EndOfSwitch_1' )
122 EndOfSwitch_1.SetAuthor( '' )
123 EndOfSwitch_1.SetComment( '' )
124 EndOfSwitch_1.Coords( 594 , 362 )
126 EndOfSwitch_1.SetPyFunction( 'EndOfSwitch_1' , PyEndOfSwitch_1 )
127 EndOfSwitch_1.InPort( 'a' , 'long' )
128 EndOfSwitch_1.OutPort( 'a' , 'long' )
129 Switch_1.SetName( 'Switch_1' )
130 Switch_1.SetAuthor( '' )
131 Switch_1.SetComment( '' )
132 Switch_1.Coords( 185 , 368 )
133 Switch_1.InPort( 'a' , 'long' )
134 Switch_1.OutPort( 'Odd' , 'long' )
135 Switch_1.OutPort( 'Even' , 'int' )
136 Switch_1.OutPort( 'a' , 'int' )
139 IsOdda = IsOdd.Port( 'a' )
140 EndOfSwitcha = GraphPyFunctions.Link( IsOdda , EndOfSwitch.Port( 'a' ) )
141 EndOfSwitcha.AddCoord( 1 , 571 , 160 )
142 EndOfSwitcha.AddCoord( 2 , 571 , 129 )
144 InitLoopIndex = InitLoop.Port( 'Index' )
145 Switcha = GraphPyFunctions.Link( InitLoopIndex , Switch.Port( 'a' ) )
147 InitLoopMin = InitLoop.Port( 'Min' )
148 EndOfInitLoopMin = GraphPyFunctions.Link( InitLoopMin , EndOfInitLoop.Port( 'Min' ) )
150 InitLoopMax = InitLoop.Port( 'Max' )
151 EndOfInitLoopMax = GraphPyFunctions.Link( InitLoopMax , EndOfInitLoop.Port( 'Max' ) )
153 SwitchOdd = Switch.Port( 'Odd' )
154 IsOddInGate = GraphPyFunctions.Link( SwitchOdd , IsOdd.Port( 'InGate' ) )
156 Switcha = Switch.Port( 'a' )
157 IsOdda = GraphPyFunctions.Link( Switcha , IsOdd.Port( 'a' ) )
158 IsOdda.AddCoord( 1 , 366 , 131 )
159 IsOdda.AddCoord( 2 , 365 , 223 )
161 SwitchDefault = Switch.Port( 'Default' )
162 EndOfSwitchDefault = GraphPyFunctions.Link( SwitchDefault , EndOfSwitch.Port( 'Default' ) )
163 EndOfSwitchDefault.AddCoord( 1 , 572 , 194 )
164 EndOfSwitchDefault.AddCoord( 2 , 571 , 257 )
166 EndOfSwitcha = EndOfSwitch.Port( 'a' )
167 EndOfInitLoopIndex = GraphPyFunctions.Link( EndOfSwitcha , EndOfInitLoop.Port( 'Index' ) )
169 IsOdd_1a = IsOdd_1.Port( 'a' )
170 EndOfSwitch_1a = GraphPyFunctions.Link( IsOdd_1a , EndOfSwitch_1.Port( 'a' ) )
171 EndOfSwitch_1a.AddCoord( 1 , 580 , 396 )
172 EndOfSwitch_1a.AddCoord( 2 , 580 , 368 )
174 InitLoop_1Index = InitLoop_1.Port( 'Index' )
175 Switch_1a = GraphPyFunctions.Link( InitLoop_1Index , Switch_1.Port( 'a' ) )
177 InitLoop_1Min = InitLoop_1.Port( 'Min' )
178 EndOfInitLoop_1Min = GraphPyFunctions.Link( InitLoop_1Min , EndOfInitLoop_1.Port( 'Min' ) )
180 InitLoop_1Max = InitLoop_1.Port( 'Max' )
181 EndOfInitLoop_1Max = GraphPyFunctions.Link( InitLoop_1Max , EndOfInitLoop_1.Port( 'Max' ) )
183 Switch_1Odd = Switch_1.Port( 'Odd' )
184 IsOdd_1InGate = GraphPyFunctions.Link( Switch_1Odd , IsOdd_1.Port( 'InGate' ) )
186 Switch_1Even = Switch_1.Port( 'Even' )
187 EndOfSwitch_1Default = GraphPyFunctions.Link( Switch_1Even , EndOfSwitch_1.Port( 'Default' ) )
189 Switch_1a = Switch_1.Port( 'a' )
190 IsOdd_1a = GraphPyFunctions.Link( Switch_1a , IsOdd_1.Port( 'a' ) )
191 IsOdd_1a.AddCoord( 1 , 368 , 368 )
192 IsOdd_1a.AddCoord( 2 , 367 , 460 )
194 EndOfSwitch_1a = EndOfSwitch_1.Port( 'a' )
195 EndOfInitLoop_1Index = GraphPyFunctions.Link( EndOfSwitch_1a , EndOfInitLoop_1.Port( 'Index' ) )
197 # Creation of Input datas
198 InitLoopIndex = InitLoop.Input( 'Index' , 0)
199 InitLoopMin = InitLoop.Input( 'Min' , 0)
200 InitLoopMax = InitLoop.Input( 'Max' , 100)
201 InitLoop_1Index = InitLoop_1.Input( 'Index' , 0)
202 InitLoop_1Min = InitLoop_1.Input( 'Min' , 0)
203 InitLoop_1Max = InitLoop_1.Input( 'Max' , 100)
205 # Creation of Output variables
206 EndOfInitLoopIndex = EndOfInitLoop.Port( 'Index' )
207 EndOfInitLoopMin = EndOfInitLoop.Port( 'Min' )
208 EndOfInitLoopMax = EndOfInitLoop.Port( 'Max' )
209 SwitchEven = Switch.Port( 'Even' )
210 EndOfInitLoop_1Index = EndOfInitLoop_1.Port( 'Index' )
211 EndOfInitLoop_1Min = EndOfInitLoop_1.Port( 'Min' )
212 EndOfInitLoop_1Max = EndOfInitLoop_1.Port( 'Max' )
214 GraphPyFunctions.Run()
215 GraphPyFunctions.DoneW()
216 GraphPyFunctions.State()
217 GraphPyFunctions.PrintPorts()