Salome HOME
Bug fix: don't set "Loading" state for MacroNodes in InitialState() function (called...
[modules/superv.git] / examples / GraphSyrControl.py
1
2 # Generated python file of Graph GraphSyrControl
3
4 from SuperV import *
5 # Graph creation 
6 GraphSyrControl = Graph( 'GraphSyrControl' )
7 GraphSyrControl.SetName( 'GraphSyrControl' )
8 GraphSyrControl.SetAuthor( 'JR' )
9 GraphSyrControl.SetComment( 'Syracuse algorithm' )
10 GraphSyrControl.Coords( 0 , 0 )
11
12 # Creation of Factory Nodes
13
14 test_ISEVEN = GraphSyrControl.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( 190 , 338 )
20
21 test_ISONE = GraphSyrControl.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( 196 , 131 )
27
28 m3p1 = GraphSyrControl.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( 788 , 22 )
34
35 div2 = GraphSyrControl.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( 794 , 427 )
41
42 incr = GraphSyrControl.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( 790 , 158 )
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 = GraphSyrControl.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( 7 , 216 )
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 = GraphSyrControl.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( 385 , 159 )
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 = GraphSyrControl.SNode( 'Switch_OneEven' , Pytest )
100 EndSwitch_OneEven.SetName( 'EndSwitch_OneEven' )
101 EndSwitch_OneEven.SetAuthor( '' )
102 EndSwitch_OneEven.SetComment( '' )
103 EndSwitch_OneEven.Coords( 1065 , 321 )
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( 592 , 205 )
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 = GraphSyrControl.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( 1012 , 68 )
143
144 Pycontrol_div2 = []
145 Pycontrol_div2.append( 'def control_div2( N , NB ) :' )
146 Pycontrol_div2.append( '    return N,NB' )
147 control_div2 = GraphSyrControl.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( 1010 , 473 )
156
157 # Creation of Links
158 test_ISEVENBoolEven = test_ISEVEN.Port( 'BoolEven' )
159 label_testValEven = GraphSyrControl.Link( test_ISEVENBoolEven , label_test.Port( 'ValEven' ) )
160 label_testValEven.AddCoord( 1 , 380 , 236 )
161 label_testValEven.AddCoord( 2 , 379 , 419 )
162
163 test_ISONEBoolOne = test_ISONE.Port( 'BoolOne' )
164 label_testValOne = GraphSyrControl.Link( test_ISONEBoolOne , label_test.Port( 'ValOne' ) )
165 label_testValOne.AddCoord( 1 , 367 , 269 )
166 label_testValOne.AddCoord( 2 , 367 , 213 )
167
168 m3p1anEvenInteger = m3p1.Port( 'anEvenInteger' )
169 control_m3p1N = GraphSyrControl.Link( m3p1anEvenInteger , control_m3p1.Port( 'N' ) )
170
171 div2anInteger = div2.Port( 'anInteger' )
172 control_div2N = GraphSyrControl.Link( div2anInteger , control_div2.Port( 'N' ) )
173
174 incraNewCount = incr.Port( 'aNewCount' )
175 control_m3p1K = GraphSyrControl.Link( incraNewCount , control_m3p1.Port( 'K' ) )
176 control_m3p1K.AddCoord( 1 , 978 , 132 )
177 control_m3p1K.AddCoord( 2 , 978 , 239 )
178
179 control_div2K = GraphSyrControl.Link( incraNewCount , control_div2.Port( 'K' ) )
180 control_div2K.AddCoord( 1 , 979 , 536 )
181 control_div2K.AddCoord( 2 , 978 , 240 )
182
183 label_beginNT = label_begin.Port( 'NT' )
184 label_testNT = GraphSyrControl.Link( label_beginNT , label_test.Port( 'NT' ) )
185
186 test_ISEVENanInteger = GraphSyrControl.Link( label_beginNT , test_ISEVEN.Port( 'anInteger' ) )
187 test_ISEVENanInteger.AddCoord( 1 , 184 , 416 )
188 test_ISEVENanInteger.AddCoord( 2 , 185 , 298 )
189
190 test_ISONEanInteger = GraphSyrControl.Link( label_beginNT , test_ISONE.Port( 'anInteger' ) )
191 test_ISONEanInteger.AddCoord( 1 , 186 , 211 )
192 test_ISONEanInteger.AddCoord( 2 , 185 , 297 )
193
194 label_beginKT = label_begin.Port( 'KT' )
195 label_testKT = GraphSyrControl.Link( label_beginKT , label_test.Port( 'KT' ) )
196
197 label_testValEven = label_test.Port( 'ValEven' )
198 testValEven = GraphSyrControl.Link( label_testValEven , test.Port( 'ValEven' ) )
199
200 label_testValOne = label_test.Port( 'ValOne' )
201 testValOne = GraphSyrControl.Link( label_testValOne , test.Port( 'ValOne' ) )
202
203 label_testNT = label_test.Port( 'NT' )
204 testNT = GraphSyrControl.Link( label_testNT , test.Port( 'NT' ) )
205
206 label_testKT = label_test.Port( 'KT' )
207 testKT = GraphSyrControl.Link( label_testKT , test.Port( 'KT' ) )
208
209 testFinished = test.Port( 'Finished' )
210 EndSwitch_OneEvenFinished = GraphSyrControl.Link( testFinished , EndSwitch_OneEven.Port( 'Finished' ) )
211
212 testIncr = test.Port( 'Incr' )
213 incrInGate = GraphSyrControl.Link( testIncr , incr.Port( 'InGate' ) )
214
215 testEven = test.Port( 'Even' )
216 div2InGate = GraphSyrControl.Link( testEven , div2.Port( 'InGate' ) )
217 div2InGate.AddCoord( 1 , 764 , 536 )
218 div2InGate.AddCoord( 2 , 763 , 297 )
219
220 testOdd = test.Port( 'Odd' )
221 m3p1InGate = GraphSyrControl.Link( testOdd , m3p1.Port( 'InGate' ) )
222 m3p1InGate.AddCoord( 1 , 773 , 133 )
223 m3p1InGate.AddCoord( 2 , 773 , 326 )
224
225 testN = test.Port( 'N' )
226 m3p1anOddInteger = GraphSyrControl.Link( testN , m3p1.Port( 'anOddInteger' ) )
227 m3p1anOddInteger.AddCoord( 1 , 753 , 102 )
228 m3p1anOddInteger.AddCoord( 2 , 752 , 355 )
229
230 div2anEvenInteger = GraphSyrControl.Link( testN , div2.Port( 'anEvenInteger' ) )
231 div2anEvenInteger.AddCoord( 1 , 753 , 508 )
232 div2anEvenInteger.AddCoord( 2 , 752 , 356 )
233
234 testK = test.Port( 'K' )
235 EndSwitch_OneEvenK = GraphSyrControl.Link( testK , EndSwitch_OneEven.Port( 'K' ) )
236
237 incraCount = GraphSyrControl.Link( testK , incr.Port( 'aCount' ) )
238 incraCount.AddCoord( 1 , 779 , 239 )
239 incraCount.AddCoord( 2 , 780 , 385 )
240
241 testDefault = test.Port( 'Default' )
242 EndSwitch_OneEvenDefault = GraphSyrControl.Link( testDefault , EndSwitch_OneEven.Port( 'Default' ) )
243
244 control_m3p1OutGate = control_m3p1.Port( 'OutGate' )
245 label_testInGate = GraphSyrControl.Link( control_m3p1OutGate , label_test.Port( 'InGate' ) )
246 label_testInGate.AddCoord( 1 , 373 , 354 )
247 label_testInGate.AddCoord( 2 , 372 , 10 )
248 label_testInGate.AddCoord( 3 , 1180 , 9 )
249 label_testInGate.AddCoord( 4 , 1181 , 217 )
250
251 control_div2OutGate = control_div2.Port( 'OutGate' )
252 label_beginInGate = GraphSyrControl.Link( control_div2OutGate , label_begin.Port( 'InGate' ) )
253 label_beginInGate.AddCoord( 1 , 5 , 355 )
254 label_beginInGate.AddCoord( 2 , 4 , 608 )
255 label_beginInGate.AddCoord( 3 , 1177 , 608 )
256 label_beginInGate.AddCoord( 4 , 1177 , 563 )
257
258 # Creation of Input datas
259 label_beginNB = label_begin.Input( 'NB' , 7)
260 label_beginKB = label_begin.Input( 'KB' , 0)
261
262 # Creation of Output variables
263 EndSwitch_OneEvenFinished = EndSwitch_OneEven.Port( 'Finished' )
264 EndSwitch_OneEvenK = EndSwitch_OneEven.Port( 'K' )
265
266 GraphSyrControl.Run( 7 )
267
268 GraphSyrControl.DoneW()
269
270 print GraphSyrControl.State()
271
272 GraphSyrControl.PrintPorts()
273
274 label_begin.EPyFunc()
275