Salome HOME
Merge with version on tag OCC-V2_1_0d
[modules/superv.git] / examples / GraphSwitchs.py
1
2 # Generated python file of Graph GraphSwitch
3
4 from SuperV import *
5 # Graph creation 
6 GraphSwitchs = Graph( 'GraphSwitchs' )
7 GraphSwitchs.SetName( 'GraphSwitchs' )
8 GraphSwitchs.SetAuthor( '' )
9 GraphSwitchs.SetComment( '' )
10 GraphSwitchs.Coords( 0 , 0 )
11
12 # Creation of Factory Nodes
13
14 # Creation of InLine Nodes
15 PyIsOdd = []
16 PyIsOdd.append( 'from time import *   ' )
17 PyIsOdd.append( 'def IsOdd(a) :       ' )
18 PyIsOdd.append( '    print a,"IsOdd (GraphSwitchs)"      ' )
19 PyIsOdd.append( '    sleep( 1 )   ' )
20 PyIsOdd.append( '    return a     ' )
21 IsOdd = GraphSwitchs.INode( 'IsOdd' , PyIsOdd )
22 IsOdd.SetName( 'IsOdd' )
23 IsOdd.SetAuthor( '' )
24 IsOdd.SetComment( 'Python function' )
25 IsOdd.Coords( 388 , 50 )
26 IsOdd.InPort( 'a' , 'long' )
27 IsOdd.OutPort( 'a' , 'long' )
28
29 PyIsOdd_1 = []
30 PyIsOdd_1.append( 'from time import *   ' )
31 PyIsOdd_1.append( 'def IsOdd(a) :       ' )
32 PyIsOdd_1.append( '    print a,"IsOdd_1 (GraphSwitchs)"      ' )
33 PyIsOdd_1.append( '    sleep( 1 )   ' )
34 PyIsOdd_1.append( '    return a     ' )
35 IsOdd_1 = GraphSwitchs.INode( 'IsOdd' , PyIsOdd_1 )
36 IsOdd_1.SetName( 'IsOdd_1' )
37 IsOdd_1.SetAuthor( '' )
38 IsOdd_1.SetComment( 'Python function' )
39 IsOdd_1.Coords( 419 , 308 )
40 IsOdd_1.InPort( 'a' , 'long' )
41 IsOdd_1.OutPort( 'a' , 'long' )
42
43 # Creation of Loop Nodes
44 PyInitLoopSwitch = []
45 PyInitLoopSwitch.append( 'def InitLoop(Index,Min,Max) :      ' )
46 PyInitLoopSwitch.append( '      return Index,Min,Max     ' )
47 PyMoreInitLoopSwitch = []
48 PyMoreInitLoopSwitch.append( 'def MoreLoop(Index,Min,Max) :     ' )
49 PyMoreInitLoopSwitch.append( '  if Index <= Max :   ' )
50 PyMoreInitLoopSwitch.append( '          DoLoop = 1     ' )
51 PyMoreInitLoopSwitch.append( '  else :     ' )
52 PyMoreInitLoopSwitch.append( '          DoLoop = 0     ' )
53 PyMoreInitLoopSwitch.append( '  return DoLoop,Index,Min,Max     ' )
54 PyNextInitLoopSwitch = []
55 PyNextInitLoopSwitch.append( 'def NextLoop(Index,Min,Max) :     ' )
56 PyNextInitLoopSwitch.append( '  Index = Index + 1     ' )
57 PyNextInitLoopSwitch.append( '  return Index,Min,Max     ' )
58 InitLoopSwitch,EndOfInitLoopSwitch = GraphSwitchs.LNode( 'InitLoop' , PyInitLoopSwitch , 'MoreLoop' , PyMoreInitLoopSwitch , 'NextLoop' , PyNextInitLoopSwitch )
59 EndOfInitLoopSwitch.SetName( 'EndOfInitLoopSwitch' )
60 EndOfInitLoopSwitch.SetAuthor( '' )
61 EndOfInitLoopSwitch.SetComment( '' )
62 EndOfInitLoopSwitch.Coords( 766 , 127 )
63 InitLoopSwitch.SetName( 'InitLoopSwitch' )
64 InitLoopSwitch.SetAuthor( '' )
65 InitLoopSwitch.SetComment( '' )
66 InitLoopSwitch.Coords( 10 , 129 )
67 InitLoopSwitch.InPort( 'Index' , 'long' )
68 InitLoopSwitch.InPort( 'Min' , 'long' )
69 InitLoopSwitch.InPort( 'Max' , 'long' )
70 InitLoopSwitch.OutPort( 'Index' , 'long' )
71 InitLoopSwitch.OutPort( 'Min' , 'long' )
72 InitLoopSwitch.OutPort( 'Max' , 'long' )
73
74 PyInitLoop = []
75 PyInitLoop.append( 'def InitLoop(Index,Min,Max) :      ' )
76 PyInitLoop.append( '    return Index,Min,Max     ' )
77 PyMoreInitLoop = []
78 PyMoreInitLoop.append( 'def MoreLoop(Index,Min,Max) :     ' )
79 PyMoreInitLoop.append( '        if Index <= Max :   ' )
80 PyMoreInitLoop.append( '                DoLoop = 1     ' )
81 PyMoreInitLoop.append( '        else :     ' )
82 PyMoreInitLoop.append( '                DoLoop = 0     ' )
83 PyMoreInitLoop.append( '        return DoLoop,Index,Min,Max     ' )
84 PyNextInitLoop = []
85 PyNextInitLoop.append( 'def NextLoop(Index,Min,Max) :     ' )
86 PyNextInitLoop.append( '        Index = Index + 1     ' )
87 PyNextInitLoop.append( '        return Index,Min,Max     ' )
88 InitLoop,EndOfInitLoop = GraphSwitchs.LNode( 'InitLoop' , PyInitLoop , 'MoreLoop' , PyMoreInitLoop , 'NextLoop' , PyNextInitLoop )
89 EndOfInitLoop.SetName( 'EndOfInitLoop' )
90 EndOfInitLoop.SetAuthor( '' )
91 EndOfInitLoop.SetComment( '' )
92 EndOfInitLoop.Coords( 783 , 381 )
93 InitLoop.SetName( 'InitLoop' )
94 InitLoop.SetAuthor( '' )
95 InitLoop.SetComment( '' )
96 InitLoop.Coords( 10 , 388 )
97 InitLoop.InPort( 'Index' , 'long' )
98 InitLoop.InPort( 'Min' , 'long' )
99 InitLoop.InPort( 'Max' , 'long' )
100 InitLoop.OutPort( 'Index' , 'long' )
101 InitLoop.OutPort( 'Min' , 'long' )
102 InitLoop.OutPort( 'Max' , 'long' )
103
104 # Creation of Switch Nodes
105 PySwitch = []
106 PySwitch.append( 'from time import * ' )
107 PySwitch.append( 'def Switch(a) :   ' )
108 PySwitch.append( '    if ( a & 1 ) == 0 : ' )
109 PySwitch.append( '        sleep(1)    ' )
110 PySwitch.append( '    return a & 1,1-(a&1),a    ' )
111 Switch,EndOfSwitch = GraphSwitchs.SNode( 'Switch' , PySwitch )
112 EndOfSwitch.SetName( 'EndOfSwitch' )
113 EndOfSwitch.SetAuthor( '' )
114 EndOfSwitch.SetComment( '' )
115 EndOfSwitch.Coords( 587 , 126 )
116 PyEndOfSwitch = []
117 EndOfSwitch.SetPyFunction( 'EndSwitch' , PyEndOfSwitch )
118 EndOfSwitch.InPort( 'a' , 'long' )
119 EndOfSwitch.OutPort( 'a' , 'long' )
120 Switch.SetName( 'Switch' )
121 Switch.SetAuthor( '' )
122 Switch.SetComment( '' )
123 Switch.Coords( 186 , 130 )
124 Switch.InPort( 'a' , 'long' )
125 Switch.OutPort( 'Odd' , 'long' )
126 Switch.OutPort( 'Even' , 'int' )
127 Switch.OutPort( 'a' , 'int' )
128
129 PySwitch_1 = []
130 PySwitch_1.append( 'from time import *  ' )
131 PySwitch_1.append( 'def Switch(a) :    ' )
132 PySwitch_1.append( '    if ( a & 1 ) == 0 :  ' )
133 PySwitch_1.append( '        sleep(1)  ' )
134 PySwitch_1.append( '    return a & 1,1-(a&1),a    ' )
135 Switch_1,EndSwitch = GraphSwitchs.SNode( 'Switch' , PySwitch_1 )
136 EndSwitch.SetName( 'EndSwitch' )
137 EndSwitch.SetAuthor( '' )
138 EndSwitch.SetComment( '' )
139 EndSwitch.Coords( 605 , 382 )
140 PyEndSwitch = []
141 EndSwitch.SetPyFunction( 'EndSwitch' , PyEndSwitch )
142 EndSwitch.InPort( 'a' , 'long' )
143 EndSwitch.OutPort( 'a' , 'long' )
144 Switch_1.SetName( 'Switch_1' )
145 Switch_1.SetAuthor( '' )
146 Switch_1.SetComment( '' )
147 Switch_1.Coords( 193 , 388 )
148 Switch_1.InPort( 'a' , 'long' )
149 Switch_1.OutPort( 'Odd' , 'long' )
150 Switch_1.OutPort( 'Even' , 'int' )
151 Switch_1.OutPort( 'a' , 'int' )
152
153 # Creation of Links
154 IsOdda = IsOdd.Port( 'a' )
155 EndOfSwitcha = GraphSwitchs.Link( IsOdda , EndOfSwitch.Port( 'a' ) )
156 EndOfSwitcha.AddCoord( 1 , 573 , 160 )
157 EndOfSwitcha.AddCoord( 2 , 572 , 130 )
158
159 InitLoopSwitchIndex = InitLoopSwitch.Port( 'Index' )
160 Switcha = GraphSwitchs.Link( InitLoopSwitchIndex , Switch.Port( 'a' ) )
161
162 InitLoopSwitchMin = InitLoopSwitch.Port( 'Min' )
163 EndOfInitLoopSwitchMin = GraphSwitchs.Link( InitLoopSwitchMin , EndOfInitLoopSwitch.Port( 'Min' ) )
164
165 InitLoopSwitchMax = InitLoopSwitch.Port( 'Max' )
166 EndOfInitLoopSwitchMax = GraphSwitchs.Link( InitLoopSwitchMax , EndOfInitLoopSwitch.Port( 'Max' ) )
167
168 SwitchOdd = Switch.Port( 'Odd' )
169 IsOddInGate = GraphSwitchs.Link( SwitchOdd , IsOdd.Port( 'InGate' ) )
170
171 Switcha = Switch.Port( 'a' )
172 IsOdda = GraphSwitchs.Link( Switcha , IsOdd.Port( 'a' ) )
173 IsOdda.AddCoord( 1 , 365 , 129 )
174 IsOdda.AddCoord( 2 , 365 , 222 )
175
176 SwitchDefault = Switch.Port( 'Default' )
177 EndOfSwitchDefault = GraphSwitchs.Link( SwitchDefault , EndOfSwitch.Port( 'Default' ) )
178 EndOfSwitchDefault.AddCoord( 1 , 572 , 194 )
179 EndOfSwitchDefault.AddCoord( 2 , 571 , 257 )
180
181 EndOfSwitcha = EndOfSwitch.Port( 'a' )
182 EndOfInitLoopSwitchIndex = GraphSwitchs.Link( EndOfSwitcha , EndOfInitLoopSwitch.Port( 'Index' ) )
183
184 IsOdd_1a = IsOdd_1.Port( 'a' )
185 EndSwitcha = GraphSwitchs.Link( IsOdd_1a , EndSwitch.Port( 'a' ) )
186 EndSwitcha.AddCoord( 1 , 599 , 416 )
187 EndSwitcha.AddCoord( 2 , 598 , 389 )
188
189 InitLoopIndex = InitLoop.Port( 'Index' )
190 Switch_1a = GraphSwitchs.Link( InitLoopIndex , Switch_1.Port( 'a' ) )
191
192 InitLoopMin = InitLoop.Port( 'Min' )
193 EndOfInitLoopMin = GraphSwitchs.Link( InitLoopMin , EndOfInitLoop.Port( 'Min' ) )
194
195 InitLoopMax = InitLoop.Port( 'Max' )
196 EndOfInitLoopMax = GraphSwitchs.Link( InitLoopMax , EndOfInitLoop.Port( 'Max' ) )
197
198 Switch_1Odd = Switch_1.Port( 'Odd' )
199 IsOdd_1InGate = GraphSwitchs.Link( Switch_1Odd , IsOdd_1.Port( 'InGate' ) )
200
201 Switch_1Even = Switch_1.Port( 'Even' )
202 EndSwitchDefault = GraphSwitchs.Link( Switch_1Even , EndSwitch.Port( 'Default' ) )
203
204 Switch_1a = Switch_1.Port( 'a' )
205 IsOdd_1a = GraphSwitchs.Link( Switch_1a , IsOdd_1.Port( 'a' ) )
206 IsOdd_1a.AddCoord( 1 , 379 , 387 )
207 IsOdd_1a.AddCoord( 2 , 378 , 481 )
208
209 EndSwitcha = EndSwitch.Port( 'a' )
210 EndOfInitLoopIndex = GraphSwitchs.Link( EndSwitcha , EndOfInitLoop.Port( 'Index' ) )
211
212 # Creation of Input datas
213 InitLoopSwitchIndex = InitLoopSwitch.Input( 'Index' , 0)
214 InitLoopSwitchMin = InitLoopSwitch.Input( 'Min' , 0)
215 InitLoopSwitchMax = InitLoopSwitch.Input( 'Max' , 100)
216 InitLoopIndex = InitLoop.Input( 'Index' , 0)
217 InitLoopMin = InitLoop.Input( 'Min' , 0)
218 InitLoopMax = InitLoop.Input( 'Max' , 100)
219
220 # Creation of Output variables
221 EndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.Port( 'Index' )
222 EndOfInitLoopSwitchMin = EndOfInitLoopSwitch.Port( 'Min' )
223 EndOfInitLoopSwitchMax = EndOfInitLoopSwitch.Port( 'Max' )
224 SwitchEven = Switch.Port( 'Even' )
225 EndOfInitLoopIndex = EndOfInitLoop.Port( 'Index' )
226 EndOfInitLoopMin = EndOfInitLoop.Port( 'Min' )
227 EndOfInitLoopMax = EndOfInitLoop.Port( 'Max' )
228
229 GraphSwitchs.Run()
230 GraphSwitchs.DoneW()
231 print GraphSwitchs.State()
232 GraphSwitchs.PrintPorts()