Salome HOME
Merge with version on tag OCC-V2_1_0d
[modules/superv.git] / examples / GraphSyrControlDefault.py
1
2 # Generated python file of Graph GraphSyrControlDefault
3
4 from SuperV import *
5 # Graph creation 
6 GraphSyrControlDefault = Graph( 'GraphSyrControlDefault' )
7 GraphSyrControlDefault.SetName( 'GraphSyrControlDefault' )
8 GraphSyrControlDefault.SetAuthor( 'JR' )
9 GraphSyrControlDefault.SetComment( 'Syracuse algorithm' )
10 GraphSyrControlDefault.Coords( 0 , 0 )
11
12 # Creation of Factory Nodes
13
14 test_ISEVEN = GraphSyrControlDefault.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( 204 , 444 )
20
21 test_ISONE = GraphSyrControlDefault.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 , 52 )
27
28 m3p1 = GraphSyrControlDefault.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( 806 , 19 )
34
35 div2 = GraphSyrControlDefault.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( 803 , 451 )
41
42 incr = GraphSyrControlDefault.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( 802 , 170 )
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 = GraphSyrControlDefault.INode( 'label_begin' , Pylabel_begin )
55 label_begin.SetName( 'label_begin' )
56 label_begin.SetAuthor( '' )
57 label_begin.SetComment( 'Python function' )
58 label_begin.Coords( 12 , 264 )
59 label_begin.InPort( 'NB' , 'long' )
60 label_begin.InPort( 'KB' , 'long' )
61
62 Pylabel_test = []
63 Pylabel_test.append( 'def label_test( ValEven , ValOne , NB , KB ):' )
64 Pylabel_test.append( '    print "label_begin",ValEven,ValOne,NB,KB' )
65 Pylabel_test.append( '    return ValEven,ValOne,NB,KB' )
66 label_test = GraphSyrControlDefault.INode( 'label_test' , Pylabel_test )
67 label_test.SetName( 'label_test' )
68 label_test.SetAuthor( '' )
69 label_test.SetComment( 'Python function' )
70 label_test.Coords( 415 , 206 )
71 label_test.InPort( 'ValEven' , 'long' )
72 label_test.InPort( 'ValOne' , 'long' )
73 label_test.InPort( 'NT' , 'long' )
74 label_test.InPort( 'KT' , 'long' )
75
76 # Creation of Switch Nodes
77 Pytest = []
78 Pytest.append( 'def Switch_OneEven( ValOne , ValEven , NT , KT ) :' )
79 Pytest.append( '    Finished = ValOne' )
80 Pytest.append( '    if Finished == 0 :' )
81 Pytest.append( '        Incr = 1' )
82 Pytest.append( '        Even = ValEven' )
83 Pytest.append( '        if Even == 0 :' )
84 Pytest.append( '            Odd = 1' )
85 Pytest.append( '        else :' )
86 Pytest.append( '            Odd = 0' )
87 Pytest.append( '    else :' )
88 Pytest.append( '        Incr = 0' )
89 Pytest.append( '        Even = 0' )
90 Pytest.append( '        Odd = 0' )
91 Pytest.append( '    Even = ValEven' )
92 Pytest.append( '    return Incr,Even,Odd,NT,KT' )
93 test,EndSwitch_OneEven = GraphSyrControlDefault.SNode( 'Switch_OneEven' , Pytest )
94 EndSwitch_OneEven.SetName( 'EndSwitch_OneEven' )
95 EndSwitch_OneEven.SetAuthor( '' )
96 EndSwitch_OneEven.SetComment( '' )
97 EndSwitch_OneEven.Coords( 1074 , 367 )
98 PyEndSwitch_OneEven = []
99 EndSwitch_OneEven.SetPyFunction( 'EndSwitch_OneEven' , PyEndSwitch_OneEven )
100 EndSwitch_OneEven.InPort( 'K' , 'long' )
101 EndSwitch_OneEven.OutPort( 'K' , 'long' )
102 test.SetName( 'test' )
103 test.SetAuthor( '' )
104 test.SetComment( '' )
105 test.Coords( 597 , 251 )
106 test.InPort( 'ValOne' , 'long' )
107 test.InPort( 'ValEven' , 'long' )
108 test.InPort( 'NT' , 'long' )
109 test.InPort( 'KT' , 'long' )
110
111 # Creation of GOTO Nodes
112 Pycontrol_m3p1 = []
113 Pycontrol_m3p1.append( 'def control_m3p1( N , K ):' )
114 Pycontrol_m3p1.append( '    return 0,1,N,K' )
115 control_m3p1 = GraphSyrControlDefault.GNode( 'control_m3p1' , Pycontrol_m3p1 , 'label_test' )
116 control_m3p1.SetName( 'control_m3p1' )
117 control_m3p1.SetAuthor( '' )
118 control_m3p1.SetComment( '' )
119 control_m3p1.Coords( 1002 , 64 )
120 control_m3p1.InPort( 'N' , 'long' )
121 control_m3p1.InPort( 'K' , 'long' )
122
123 Pycontrol_div2 = []
124 Pycontrol_div2.append( 'def control_div2( N , NB ) :' )
125 Pycontrol_div2.append( '    return N,NB' )
126 control_div2 = GraphSyrControlDefault.GNode( 'control_div2' , Pycontrol_div2 , 'label_begin' )
127 control_div2.SetName( 'control_div2' )
128 control_div2.SetAuthor( '' )
129 control_div2.SetComment( '' )
130 control_div2.Coords( 1013 , 496 )
131 control_div2.InPort( 'N' , 'long' )
132 control_div2.InPort( 'K' , 'long' )
133
134 # Creation of Links
135 test_ISEVENBoolEven = test_ISEVEN.Port( 'BoolEven' )
136 label_testValEven = GraphSyrControlDefault.Link( test_ISEVENBoolEven , label_test.Port( 'ValEven' ) )
137 label_testValEven.AddCoord( 1 , 381 , 286 )
138 label_testValEven.AddCoord( 2 , 382 , 524 )
139
140 test_ISONEBoolOne = test_ISONE.Port( 'BoolOne' )
141 label_testValOne = GraphSyrControlDefault.Link( test_ISONEBoolOne , label_test.Port( 'ValOne' ) )
142 label_testValOne.AddCoord( 1 , 393 , 314 )
143 label_testValOne.AddCoord( 2 , 393 , 133 )
144
145 m3p1anEvenInteger = m3p1.Port( 'anEvenInteger' )
146 control_m3p1N = GraphSyrControlDefault.Link( m3p1anEvenInteger , control_m3p1.Port( 'N' ) )
147
148 div2anInteger = div2.Port( 'anInteger' )
149 control_div2N = GraphSyrControlDefault.Link( div2anInteger , control_div2.Port( 'N' ) )
150
151 incraNewCount = incr.Port( 'aNewCount' )
152 control_m3p1K = GraphSyrControlDefault.Link( incraNewCount , control_m3p1.Port( 'K' ) )
153 control_m3p1K.AddCoord( 1 , 985 , 128 )
154 control_m3p1K.AddCoord( 2 , 985 , 250 )
155
156 control_div2K = GraphSyrControlDefault.Link( incraNewCount , control_div2.Port( 'K' ) )
157 control_div2K.AddCoord( 1 , 987 , 559 )
158 control_div2K.AddCoord( 2 , 985 , 250 )
159
160 label_beginNT = label_begin.Port( 'NT' )
161 label_testNT = GraphSyrControlDefault.Link( label_beginNT , label_test.Port( 'NT' ) )
162
163 test_ISEVENanInteger = GraphSyrControlDefault.Link( label_beginNT , test_ISEVEN.Port( 'anInteger' ) )
164 test_ISEVENanInteger.AddCoord( 1 , 191 , 524 )
165 test_ISEVENanInteger.AddCoord( 2 , 192 , 345 )
166
167 test_ISONEanInteger = GraphSyrControlDefault.Link( label_beginNT , test_ISONE.Port( 'anInteger' ) )
168 test_ISONEanInteger.AddCoord( 1 , 192 , 131 )
169 test_ISONEanInteger.AddCoord( 2 , 193 , 345 )
170
171 label_beginKT = label_begin.Port( 'KT' )
172 label_testKT = GraphSyrControlDefault.Link( label_beginKT , label_test.Port( 'KT' ) )
173
174 label_testValEven = label_test.Port( 'ValEven' )
175 testValEven = GraphSyrControlDefault.Link( label_testValEven , test.Port( 'ValEven' ) )
176
177 label_testValOne = label_test.Port( 'ValOne' )
178 testValOne = GraphSyrControlDefault.Link( label_testValOne , test.Port( 'ValOne' ) )
179
180 label_testNT = label_test.Port( 'NT' )
181 testNT = GraphSyrControlDefault.Link( label_testNT , test.Port( 'NT' ) )
182
183 label_testKT = label_test.Port( 'KT' )
184 testKT = GraphSyrControlDefault.Link( label_testKT , test.Port( 'KT' ) )
185
186 testIncr = test.Port( 'Incr' )
187 incrInGate = GraphSyrControlDefault.Link( testIncr , incr.Port( 'InGate' ) )
188
189 testEven = test.Port( 'Even' )
190 div2InGate = GraphSyrControlDefault.Link( testEven , div2.Port( 'InGate' ) )
191 div2InGate.AddCoord( 1 , 793 , 567 )
192 div2InGate.AddCoord( 2 , 792 , 314 )
193
194 testOdd = test.Port( 'Odd' )
195 m3p1InGate = GraphSyrControlDefault.Link( testOdd , m3p1.Port( 'InGate' ) )
196 m3p1InGate.AddCoord( 1 , 786 , 132 )
197 m3p1InGate.AddCoord( 2 , 785 , 343 )
198
199 testN = test.Port( 'N' )
200 m3p1anOddInteger = GraphSyrControlDefault.Link( testN , m3p1.Port( 'anOddInteger' ) )
201 m3p1anOddInteger.AddCoord( 1 , 767 , 100 )
202 m3p1anOddInteger.AddCoord( 2 , 767 , 371 )
203
204 div2anEvenInteger = GraphSyrControlDefault.Link( testN , div2.Port( 'anEvenInteger' ) )
205 div2anEvenInteger.AddCoord( 1 , 768 , 531 )
206 div2anEvenInteger.AddCoord( 2 , 767 , 371 )
207
208 testK = test.Port( 'K' )
209 EndSwitch_OneEvenK = GraphSyrControlDefault.Link( testK , EndSwitch_OneEven.Port( 'K' ) )
210
211 incraCount = GraphSyrControlDefault.Link( testK , incr.Port( 'aCount' ) )
212 incraCount.AddCoord( 1 , 773 , 251 )
213 incraCount.AddCoord( 2 , 774 , 400 )
214
215 testDefault = test.Port( 'Default' )
216 EndSwitch_OneEvenDefault = GraphSyrControlDefault.Link( testDefault , EndSwitch_OneEven.Port( 'Default' ) )
217
218 control_m3p1OutGate = control_m3p1.Port( 'OutGate' )
219 label_testInGate = GraphSyrControlDefault.Link( control_m3p1OutGate , label_test.Port( 'InGate' ) )
220 label_testInGate.AddCoord( 1 , 402 , 406 )
221 label_testInGate.AddCoord( 2 , 403 , 4 )
222 label_testInGate.AddCoord( 3 , 1174 , 5 )
223 label_testInGate.AddCoord( 4 , 1175 , 219 )
224
225 control_div2OutGate = control_div2.Port( 'OutGate' )
226 label_beginInGate = GraphSyrControlDefault.Link( control_div2OutGate , label_begin.Port( 'InGate' ) )
227 label_beginInGate.AddCoord( 1 , 3 , 409 )
228 label_beginInGate.AddCoord( 2 , 2 , 671 )
229 label_beginInGate.AddCoord( 3 , 1199 , 670 )
230 label_beginInGate.AddCoord( 4 , 1198 , 592 )
231
232 # Creation of Input datas
233 label_beginNB = label_begin.Input( 'NB' , 7)
234 label_beginKB = label_begin.Input( 'KB' , 0)
235
236 # Creation of Output variables
237 EndSwitch_OneEvenK = EndSwitch_OneEven.Port( 'K' )
238
239 GraphSyrControlDefault.Run()
240 GraphSyrControlDefault.DoneW()
241 print GraphSyrControlDefault.State()
242 GraphSyrControlDefault.PrintPorts()