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