Salome HOME
00b741454fd40d147f9c97d9570a2464946d533e
[modules/superv.git] / examples / GraphGOTO.py
1
2 # Generated python file of Graph GraphGOTO
3
4 from SuperV import *
5 # Graph creation 
6 GraphGOTO = Graph( 'GraphGOTO' )
7 GraphGOTO.SetName( 'GraphGOTO' )
8 GraphGOTO.SetAuthor( 'JR' )
9 GraphGOTO.SetComment( 'Syracuse algorithm' )
10 GraphGOTO.Coords( 0 , 0 )
11
12 # Creation of Factory Nodes
13
14 test_ISEVEN = GraphGOTO.FNode( 'SyrComponent' , 'SyrComponent' , 'C_ISEVEN' )
15 test_ISEVEN.SetName( 'test_ISEVEN' )
16 test_ISEVEN.SetAuthor( '' )
17 test_ISEVEN.SetContainer( 'localhost/FactoryServer' )
18 test_ISEVEN.SetComment( 'C_ISEVEN from SyrComponent' )
19 test_ISEVEN.Coords( 195 , 417 )
20
21 test_ISONE = GraphGOTO.FNode( 'SyrComponent' , 'SyrComponent' , 'C_ISONE' )
22 test_ISONE.SetName( 'test_ISONE' )
23 test_ISONE.SetAuthor( '' )
24 test_ISONE.SetContainer( 'localhost/FactoryServer' )
25 test_ISONE.SetComment( 'C_ISONE from SyrComponent' )
26 test_ISONE.Coords( 201 , 145 )
27
28 m3p1 = GraphGOTO.FNode( 'SyrComponent' , 'SyrComponent' , 'C_M3P1' )
29 m3p1.SetName( 'm3p1' )
30 m3p1.SetAuthor( '' )
31 m3p1.SetContainer( 'localhost/FactoryServer' )
32 m3p1.SetComment( 'C_M3P1 from SyrComponent' )
33 m3p1.Coords( 784 , 36 )
34
35 div2 = GraphGOTO.FNode( 'SyrComponent' , 'SyrComponent' , 'C_DIV2' )
36 div2.SetName( 'div2' )
37 div2.SetAuthor( '' )
38 div2.SetContainer( 'localhost/FactoryServer' )
39 div2.SetComment( 'C_DIV2 from SyrComponent' )
40 div2.Coords( 788 , 409 )
41
42 incr = GraphGOTO.FNode( 'SyrComponent' , 'SyrComponent' , 'C_INCR' )
43 incr.SetName( 'incr' )
44 incr.SetAuthor( '' )
45 incr.SetContainer( 'localhost/FactoryServer' )
46 incr.SetComment( 'C_INCR from SyrComponent' )
47 incr.Coords( 788 , 230 )
48
49 # Creation of InLine Nodes
50 Pylabel_begin = []
51 Pylabel_begin.append( 'def label_begin( NB , KB ):' )
52 Pylabel_begin.append( '    print "label_begin",NB,KB' )
53 Pylabel_begin.append( '    return NB,KB' )
54 label_begin = GraphGOTO.INode( 'label_begin' , Pylabel_begin )
55 label_begin.InPort( 'NB' , 'long' )
56 label_begin.InPort( 'KB' , 'long' )
57 label_begin.OutPort( 'NT' , 'long' )
58 label_begin.OutPort( 'KT' , 'long' )
59 label_begin.SetName( 'label_begin' )
60 label_begin.SetAuthor( '' )
61 label_begin.SetComment( 'Python function' )
62 label_begin.Coords( 9 , 250 )
63
64 Pylabel_test = []
65 Pylabel_test.append( 'def label_test( ValEven , ValOne , NB , KB ):' )
66 Pylabel_test.append( '    print "label_begin",ValEven,ValOne,NB,KB' )
67 Pylabel_test.append( '    return ValEven,ValOne,NB,KB' )
68 label_test = GraphGOTO.INode( 'label_test' , Pylabel_test )
69 label_test.InPort( 'ValEven' , 'long' )
70 label_test.InPort( 'ValOne' , 'long' )
71 label_test.InPort( 'NT' , 'long' )
72 label_test.InPort( 'KT' , 'long' )
73 label_test.OutPort( 'ValEven' , 'long' )
74 label_test.OutPort( 'ValOne' , 'long' )
75 label_test.OutPort( 'NT' , 'long' )
76 label_test.OutPort( 'KT' , 'long' )
77 label_test.SetName( 'label_test' )
78 label_test.SetAuthor( '' )
79 label_test.SetComment( 'Python function' )
80 label_test.Coords( 396 , 193 )
81
82 # Creation of Switch Nodes
83 Pytest = []
84 Pytest.append( 'def Switch_OneEven( ValOne , ValEven , NT , KT ) :' )
85 Pytest.append( '    Finished = ValOne' )
86 Pytest.append( '    if Finished == 0 :' )
87 Pytest.append( '        Incr = 1' )
88 Pytest.append( '        Even = ValEven' )
89 Pytest.append( '        if Even == 0 :' )
90 Pytest.append( '            Odd = 1' )
91 Pytest.append( '        else :' )
92 Pytest.append( '            Odd = 0' )
93 Pytest.append( '    else :' )
94 Pytest.append( '        Incr = 0' )
95 Pytest.append( '        Even = 0' )
96 Pytest.append( '        Odd = 0' )
97 Pytest.append( '    Even = ValEven' )
98 Pytest.append( '    return Finished,Incr,Even,Odd,NT,KT' )
99 test,EndSwitch_OneEven = GraphGOTO.SNode( 'Switch_OneEven' , Pytest )
100 EndSwitch_OneEven.SetName( 'EndSwitch_OneEven' )
101 EndSwitch_OneEven.SetAuthor( '' )
102 EndSwitch_OneEven.SetComment( '' )
103 EndSwitch_OneEven.Coords( 1152 , 292 )
104 PyEndSwitch_OneEven = []
105 PyEndSwitch_OneEven.append( 'def EndSwitch_OneEven( Finished , K ):' )
106 PyEndSwitch_OneEven.append( '    print "label_begin",Finished,K' )
107 PyEndSwitch_OneEven.append( '    return Finished,K' )
108 EndSwitch_OneEven.SetPyFunction( 'EndSwitch_OneEven' , PyEndSwitch_OneEven )
109 EndSwitch_OneEven.InPort( 'Finished' , 'long' )
110 EndSwitch_OneEven.InPort( 'K' , 'long' )
111 EndSwitch_OneEven.OutPort( 'Finished' , 'long' )
112 EndSwitch_OneEven.OutPort( 'K' , 'long' )
113 test.InPort( 'ValOne' , 'long' )
114 test.InPort( 'ValEven' , 'long' )
115 test.InPort( 'NT' , 'long' )
116 test.InPort( 'KT' , 'long' )
117 test.OutPort( 'Finished' , 'long' )
118 test.OutPort( 'Incr' , 'long' )
119 test.OutPort( 'Even' , 'long' )
120 test.OutPort( 'Odd' , 'long' )
121 test.OutPort( 'N' , 'long' )
122 test.OutPort( 'K' , 'long' )
123 test.SetName( 'test' )
124 test.SetAuthor( '' )
125 test.SetComment( '' )
126 test.Coords( 595 , 239 )
127
128 # Creation of GOTO Nodes
129 Pycontrol_m3p1 = []
130 Pycontrol_m3p1.append( 'def control_m3p1( N , K ):' )
131 Pycontrol_m3p1.append( '    return 0,1,N,K' )
132 control_m3p1 = GraphGOTO.GNode( 'control_m3p1' , Pycontrol_m3p1 , 'label_test' )
133 control_m3p1.InPort( 'N' , 'long' )
134 control_m3p1.InPort( 'K' , 'long' )
135 control_m3p1.OutPort( 'ValOne' , 'long' )
136 control_m3p1.OutPort( 'ValEven' , 'long' )
137 control_m3p1.OutPort( 'NT' , 'long' )
138 control_m3p1.OutPort( 'KT' , 'long' )
139 control_m3p1.SetName( 'control_m3p1' )
140 control_m3p1.SetAuthor( '' )
141 control_m3p1.SetComment( '' )
142 control_m3p1.Coords( 980 , 81 )
143
144 Pycontrol_div2 = []
145 Pycontrol_div2.append( 'def control_div2( N , NB ) :' )
146 Pycontrol_div2.append( '    return N,NB' )
147 control_div2 = GraphGOTO.GNode( 'control_div2' , Pycontrol_div2 , 'label_begin' )
148 control_div2.InPort( 'N' , 'long' )
149 control_div2.InPort( 'K' , 'long' )
150 control_div2.OutPort( 'NB' , 'long' )
151 control_div2.OutPort( 'KB' , 'long' )
152 control_div2.SetName( 'control_div2' )
153 control_div2.SetAuthor( '' )
154 control_div2.SetComment( '' )
155 control_div2.Coords( 1039 , 454 )
156
157 # Creation of Links
158 test_ISEVENBoolEven = test_ISEVEN.Port( 'BoolEven' )
159 label_testValEven = GraphGOTO.Link( test_ISEVENBoolEven , label_test.Port( 'ValEven' ) )
160 label_testValEven.AddCoord( 1 , 369 , 273 )
161 label_testValEven.AddCoord( 2 , 370 , 498 )
162
163 test_ISONEBoolOne = test_ISONE.Port( 'BoolOne' )
164 label_testValOne = GraphGOTO.Link( test_ISONEBoolOne , label_test.Port( 'ValOne' ) )
165 label_testValOne.AddCoord( 1 , 385 , 303 )
166 label_testValOne.AddCoord( 2 , 384 , 225 )
167
168 m3p1anEvenInteger = m3p1.Port( 'anEvenInteger' )
169 control_m3p1N = GraphGOTO.Link( m3p1anEvenInteger , control_m3p1.Port( 'N' ) )
170
171 div2anInteger = div2.Port( 'anInteger' )
172 control_div2N = GraphGOTO.Link( div2anInteger , control_div2.Port( 'N' ) )
173
174 incraNewCount = incr.Port( 'aNewCount' )
175 control_m3p1K = GraphGOTO.Link( incraNewCount , control_m3p1.Port( 'K' ) )
176 control_m3p1K.AddCoord( 1 , 964 , 145 )
177 control_m3p1K.AddCoord( 2 , 964 , 309 )
178
179 control_div2K = GraphGOTO.Link( incraNewCount , control_div2.Port( 'K' ) )
180 control_div2K.AddCoord( 1 , 963 , 518 )
181 control_div2K.AddCoord( 2 , 964 , 312 )
182
183 label_beginNT = label_begin.Port( 'NT' )
184 label_testNT = GraphGOTO.Link( label_beginNT , label_test.Port( 'NT' ) )
185
186 test_ISONEanInteger = GraphGOTO.Link( label_beginNT , test_ISONE.Port( 'anInteger' ) )
187 test_ISONEanInteger.AddCoord( 1 , 192 , 226 )
188 test_ISONEanInteger.AddCoord( 2 , 191 , 331 )
189
190 test_ISEVENanInteger = GraphGOTO.Link( label_beginNT , test_ISEVEN.Port( 'anInteger' ) )
191 test_ISEVENanInteger.AddCoord( 1 , 191 , 494 )
192 test_ISEVENanInteger.AddCoord( 2 , 192 , 331 )
193
194 label_beginKT = label_begin.Port( 'KT' )
195 label_testKT = GraphGOTO.Link( label_beginKT , label_test.Port( 'KT' ) )
196
197 label_testValEven = label_test.Port( 'ValEven' )
198 testValEven = GraphGOTO.Link( label_testValEven , test.Port( 'ValEven' ) )
199 testValEven.AddCoord( 1 , 587 , 318 )
200 testValEven.AddCoord( 2 , 570 , 318 )
201 testValEven.AddCoord( 3 , 569 , 272 )
202
203 label_testValOne = label_test.Port( 'ValOne' )
204 testValOne = GraphGOTO.Link( label_testValOne , test.Port( 'ValOne' ) )
205 testValOne.AddCoord( 1 , 585 , 273 )
206 testValOne.AddCoord( 2 , 586 , 303 )
207
208 label_testNT = label_test.Port( 'NT' )
209 testNT = GraphGOTO.Link( label_testNT , test.Port( 'NT' ) )
210
211 label_testKT = label_test.Port( 'KT' )
212 testKT = GraphGOTO.Link( label_testKT , test.Port( 'KT' ) )
213
214 testFinished = test.Port( 'Finished' )
215 EndSwitch_OneEvenFinished = GraphGOTO.Link( testFinished , EndSwitch_OneEven.Port( 'Finished' ) )
216
217 testIncr = test.Port( 'Incr' )
218 incrInGate = GraphGOTO.Link( testIncr , incr.Port( 'InGate' ) )
219 incrInGate.AddCoord( 1 , 783 , 341 )
220 incrInGate.AddCoord( 2 , 782 , 302 )
221
222 testEven = test.Port( 'Even' )
223 div2InGate = GraphGOTO.Link( testEven , div2.Port( 'InGate' ) )
224 div2InGate.AddCoord( 1 , 754 , 518 )
225 div2InGate.AddCoord( 2 , 753 , 330 )
226
227 testOdd = test.Port( 'Odd' )
228 m3p1InGate = GraphGOTO.Link( testOdd , m3p1.Port( 'InGate' ) )
229 m3p1InGate.AddCoord( 1 , 758 , 145 )
230 m3p1InGate.AddCoord( 2 , 760 , 359 )
231
232 testN = test.Port( 'N' )
233 m3p1anOddInteger = GraphGOTO.Link( testN , m3p1.Port( 'anOddInteger' ) )
234 m3p1anOddInteger.AddCoord( 1 , 767 , 116 )
235 m3p1anOddInteger.AddCoord( 2 , 767 , 116 )
236 m3p1anOddInteger.AddCoord( 3 , 767 , 390 )
237
238 div2anEvenInteger = GraphGOTO.Link( testN , div2.Port( 'anEvenInteger' ) )
239 div2anEvenInteger.AddCoord( 1 , 767 , 489 )
240 div2anEvenInteger.AddCoord( 2 , 766 , 389 )
241
242 testK = test.Port( 'K' )
243 EndSwitch_OneEvenK = GraphGOTO.Link( testK , EndSwitch_OneEven.Port( 'K' ) )
244
245 incraCount = GraphGOTO.Link( testK , incr.Port( 'aCount' ) )
246 incraCount.AddCoord( 1 , 772 , 311 )
247 incraCount.AddCoord( 2 , 772 , 417 )
248 incraCount.AddCoord( 3 , 772 , 417 )
249
250 testDefault = test.Port( 'Default' )
251 EndSwitch_OneEvenDefault = GraphGOTO.Link( testDefault , EndSwitch_OneEven.Port( 'Default' ) )
252 EndSwitch_OneEvenDefault.AddCoord( 1 , 778 , 384 )
253 EndSwitch_OneEvenDefault.AddCoord( 2 , 778 , 448 )
254
255 control_m3p1OutGate = control_m3p1.Port( 'OutGate' )
256 label_testInGate = GraphGOTO.Link( control_m3p1OutGate , label_test.Port( 'InGate' ) )
257 label_testInGate.AddCoord( 1 , 388 , 388 )
258 label_testInGate.AddCoord( 2 , 389 , 597 )
259 label_testInGate.AddCoord( 3 , 1319 , 597 )
260 label_testInGate.AddCoord( 4 , 1318 , 231 )
261
262 control_div2OutGate = control_div2.Port( 'OutGate' )
263 label_beginInGate = GraphGOTO.Link( control_div2OutGate , label_begin.Port( 'InGate' ) )
264 label_beginInGate.AddCoord( 1 , 4 , 388 )
265 label_beginInGate.AddCoord( 2 , 3 , 587 )
266 label_beginInGate.AddCoord( 3 , 1214 , 588 )
267 label_beginInGate.AddCoord( 4 , 1213 , 546 )
268
269 # Creation of Input datas
270 label_beginNB = label_begin.Input( 'NB' , 7)
271 label_beginKB = label_begin.Input( 'KB' , 0)
272
273 # Creation of Output variables
274 EndSwitch_OneEvenFinished = EndSwitch_OneEven.Port( 'Finished' )
275 EndSwitch_OneEvenK = EndSwitch_OneEven.Port( 'K' )
276
277 GraphGOTO.Run()
278
279 GraphGOTO.DoneW()
280
281 GraphGOTO.PrintPorts()
282