Salome HOME
NRI : Add documentation.
[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 test_ISEVEN = GraphSyrControl.FNode( 'SyrComponent' , 'SyrComponent' , 'C_ISEVEN' )
14 test_ISEVEN.SetName( 'test_ISEVEN' )
15 test_ISEVEN.SetAuthor( '' )
16 test_ISEVEN.SetContainer( 'localhost/FactoryServer' )
17 test_ISEVEN.SetComment( 'C_ISEVEN from SyrComponent' )
18 test_ISEVEN.Coords( 190 , 338 )
19 test_ISONE = GraphSyrControl.FNode( 'SyrComponent' , 'SyrComponent' , 'C_ISONE' )
20 test_ISONE.SetName( 'test_ISONE' )
21 test_ISONE.SetAuthor( '' )
22 test_ISONE.SetContainer( 'localhost/FactoryServer' )
23 test_ISONE.SetComment( 'C_ISONE from SyrComponent' )
24 test_ISONE.Coords( 196 , 131 )
25 m3p1 = GraphSyrControl.FNode( 'SyrComponent' , 'SyrComponent' , 'C_M3P1' )
26 m3p1.SetName( 'm3p1' )
27 m3p1.SetAuthor( '' )
28 m3p1.SetContainer( 'localhost/FactoryServer' )
29 m3p1.SetComment( 'C_M3P1 from SyrComponent' )
30 m3p1.Coords( 621 , 14 )
31 div2 = GraphSyrControl.FNode( 'SyrComponent' , 'SyrComponent' , 'C_DIV2' )
32 div2.SetName( 'div2' )
33 div2.SetAuthor( '' )
34 div2.SetContainer( 'localhost/FactoryServer' )
35 div2.SetComment( 'C_DIV2 from SyrComponent' )
36 div2.Coords( 624 , 391 )
37 incr = GraphSyrControl.FNode( 'SyrComponent' , 'SyrComponent' , 'C_INCR' )
38 incr.SetName( 'incr' )
39 incr.SetAuthor( '' )
40 incr.SetContainer( 'localhost/FactoryServer' )
41 incr.SetComment( 'C_INCR from SyrComponent' )
42 incr.Coords( 622 , 199 )
43
44 # Creation of InLine Nodes
45 Pylabel_begin = []
46 Pylabel_begin.append( 'def label_begin( NB , KB ):' )
47 Pylabel_begin.append( '    print "label_begin",NB,KB' )
48 Pylabel_begin.append( '    return NB,KB' )
49 label_begin = GraphSyrControl.INode( 'label_begin' , Pylabel_begin )
50 label_begin.InPort( 'NB' , 'long' )
51 label_begin.InPort( 'KB' , 'long' )
52 label_begin.OutPort( 'NT' , 'long' )
53 label_begin.OutPort( 'KT' , 'long' )
54 label_begin.SetName( 'label_begin' )
55 label_begin.SetAuthor( '' )
56 label_begin.SetComment( 'Python function' )
57 label_begin.Coords( 7 , 216 )
58 Pylabel_test = []
59 Pylabel_test.append( 'def label_test( ValEven , ValOne , NB , KB ):' )
60 Pylabel_test.append( '    print "label_begin",ValEven,ValOne,NB,KB' )
61 Pylabel_test.append( '    return ValEven,ValOne,NB,KB' )
62 label_test = GraphSyrControl.INode( 'label_test' , Pylabel_test )
63 label_test.InPort( 'ValEven' , 'long' )
64 label_test.InPort( 'ValOne' , 'long' )
65 label_test.InPort( 'NT' , 'long' )
66 label_test.InPort( 'KT' , 'long' )
67 label_test.OutPort( 'ValEven' , 'long' )
68 label_test.OutPort( 'ValOne' , 'long' )
69 label_test.OutPort( 'NT' , 'long' )
70 label_test.OutPort( 'KT' , 'long' )
71 label_test.SetName( 'label_test' )
72 label_test.SetAuthor( '' )
73 label_test.SetComment( 'Python function' )
74 label_test.Coords( 7 , 216 )
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 Finished,Incr,Even,Odd,NT,KT' )
93 test,EndSwitch_OneEven = GraphSyrControl.SNode( 'Switch_OneEven' , Pytest )
94 EndSwitch_OneEven.SetName( 'EndSwitch_OneEven' )
95 EndSwitch_OneEven.SetAuthor( '' )
96 EndSwitch_OneEven.SetComment( '' )
97 EndSwitch_OneEven.Coords( 0 , 0 )
98 PyEndSwitch_OneEven = []
99 PyEndSwitch_OneEven.append( 'def EndSwitch_OneEven( Finished , K ):' )
100 PyEndSwitch_OneEven.append( '    print "label_begin",Finished,K' )
101 PyEndSwitch_OneEven.append( '    return Finished,K' )
102 EndSwitch_OneEven.SetPyFunction( 'EndSwitch_OneEven' , PyEndSwitch_OneEven )
103 EndSwitch_OneEven.InPort( 'Finished' , 'long' )
104 EndSwitch_OneEven.InPort( 'K' , 'long' )
105 EndSwitch_OneEven.OutPort( 'Finished' , 'long' )
106 EndSwitch_OneEven.OutPort( 'K' , 'long' )
107 test.InPort( 'ValOne' , 'long' )
108 test.InPort( 'ValEven' , 'long' )
109 test.InPort( 'NT' , 'long' )
110 test.InPort( 'KT' , 'long' )
111 test.OutPort( 'Finished' , 'long' )
112 test.OutPort( 'Incr' , 'long' )
113 test.OutPort( 'Even' , 'long' )
114 test.OutPort( 'Odd' , 'long' )
115 test.OutPort( 'N' , 'long' )
116 test.OutPort( 'K' , 'long' )
117 test.SetName( 'test' )
118 test.SetAuthor( '' )
119 test.SetComment( '' )
120 test.Coords( 399 , 176 )
121
122 # Creation of GOTO Nodes
123 Pycontrol_m3p1 = []
124 Pycontrol_m3p1.append( 'def control_m3p1( N , K ):' )
125 Pycontrol_m3p1.append( '    return 0,1,N,K' )
126 control_m3p1 = GraphSyrControl.GNode( 'control_m3p1' , Pycontrol_m3p1 , 'label_test' )
127 control_m3p1.InPort( 'N' , 'long' )
128 control_m3p1.InPort( 'K' , 'long' )
129 control_m3p1.OutPort( 'ValOne' , 'long' )
130 control_m3p1.OutPort( 'ValEven' , 'long' )
131 control_m3p1.OutPort( 'NT' , 'long' )
132 control_m3p1.OutPort( 'KT' , 'long' )
133 control_m3p1.SetName( 'control_m3p1' )
134 control_m3p1.SetAuthor( '' )
135 control_m3p1.SetComment( '' )
136 control_m3p1.Coords( 814 , 13 )
137 Pycontrol_div2 = []
138 Pycontrol_div2.append( 'def control_div2( N , NB ) :' )
139 Pycontrol_div2.append( '    return N,NB' )
140 control_div2 = GraphSyrControl.GNode( 'control_div2' , Pycontrol_div2 , 'label_begin' )
141 control_div2.InPort( 'N' , 'long' )
142 control_div2.InPort( 'K' , 'long' )
143 control_div2.OutPort( 'NB' , 'long' )
144 control_div2.OutPort( 'KB' , 'long' )
145 control_div2.SetName( 'control_div2' )
146 control_div2.SetAuthor( '' )
147 control_div2.SetComment( '' )
148 control_div2.Coords( 812 , 414 )
149
150 # Creation of intermediate Output variables and of Control Links
151 test_ISEVENBoolEven = test_ISEVEN.Port( 'BoolEven' )
152 label_testValEven = GraphSyrControl.Link( test_ISEVENBoolEven , label_test.Port( 'ValEven' ) )
153 test_ISONEBoolOne = test_ISONE.Port( 'BoolOne' )
154 label_testValOne = GraphSyrControl.Link( test_ISONEBoolOne , label_test.Port( 'ValOne' ) )
155 m3p1anEvenInteger = m3p1.Port( 'anEvenInteger' )
156 control_m3p1N = GraphSyrControl.Link( m3p1anEvenInteger , control_m3p1.Port( 'N' ) )
157 div2anInteger = div2.Port( 'anInteger' )
158 control_div2N = GraphSyrControl.Link( div2anInteger , control_div2.Port( 'N' ) )
159 incraNewCount = incr.Port( 'aNewCount' )
160 control_m3p1K = GraphSyrControl.Link( incraNewCount , control_m3p1.Port( 'K' ) )
161 control_div2K = GraphSyrControl.Link( incraNewCount , control_div2.Port( 'K' ) )
162 label_beginNT = label_begin.Port( 'NT' )
163 label_testNT = GraphSyrControl.Link( label_beginNT , label_test.Port( 'NT' ) )
164 test_ISEVENanInteger = GraphSyrControl.Link( label_beginNT , test_ISEVEN.Port( 'anInteger' ) )
165 test_ISONEanInteger = GraphSyrControl.Link( label_beginNT , test_ISONE.Port( 'anInteger' ) )
166 label_beginKT = label_begin.Port( 'KT' )
167 label_testKT = GraphSyrControl.Link( label_beginKT , label_test.Port( 'KT' ) )
168 label_testValEven = label_test.Port( 'ValEven' )
169 testValEven = GraphSyrControl.Link( label_testValEven , test.Port( 'ValEven' ) )
170 label_testValOne = label_test.Port( 'ValOne' )
171 testValOne = GraphSyrControl.Link( label_testValOne , test.Port( 'ValOne' ) )
172 label_testNT = label_test.Port( 'NT' )
173 testNT = GraphSyrControl.Link( label_testNT , test.Port( 'NT' ) )
174 label_testKT = label_test.Port( 'KT' )
175 testKT = GraphSyrControl.Link( label_testKT , test.Port( 'KT' ) )
176 testDefault = test.Port( 'Default' )
177 EndSwitch_OneEvenDefault = GraphSyrControl.Link( testDefault , EndSwitch_OneEven.Port( 'Default' ) )
178 testFinished = test.Port( 'Finished' )
179 EndSwitch_OneEvenFinished = GraphSyrControl.Link( testFinished , EndSwitch_OneEven.Port( 'Finished' ) )
180 testIncr = test.Port( 'Incr' )
181 incrInGate = GraphSyrControl.Link( testIncr , incr.Port( 'InGate' ) )
182 testEven = test.Port( 'Even' )
183 div2InGate = GraphSyrControl.Link( testEven , div2.Port( 'InGate' ) )
184 testOdd = test.Port( 'Odd' )
185 m3p1InGate = GraphSyrControl.Link( testOdd , m3p1.Port( 'InGate' ) )
186 testN = test.Port( 'N' )
187 m3p1anOddInteger = GraphSyrControl.Link( testN , m3p1.Port( 'anOddInteger' ) )
188 div2anEvenInteger = GraphSyrControl.Link( testN , div2.Port( 'anEvenInteger' ) )
189 testK = test.Port( 'K' )
190 EndSwitch_OneEvenK = GraphSyrControl.Link( testK , EndSwitch_OneEven.Port( 'K' ) )
191 incraCount = GraphSyrControl.Link( testK , incr.Port( 'aCount' ) )
192
193 # Creation of intermediate Output variables and of Loop Links
194 control_m3p1OutGate = control_m3p1.Port( 'OutGate' )
195 label_testInGate = GraphSyrControl.Link( control_m3p1OutGate , label_test.Port( 'InGate' ) )
196 control_div2OutGate = control_div2.Port( 'OutGate' )
197 label_beginInGate = GraphSyrControl.Link( control_div2OutGate , label_begin.Port( 'InGate' ) )
198
199 # Creation of Input datas
200 label_beginNB = label_begin.Input( 'NB' , 7)
201 label_beginKB = label_begin.Input( 'KB' , 0)
202
203 # Creation of Output variables
204 EndSwitch_OneEvenFinished = EndSwitch_OneEven.Port( 'Finished' )
205 EndSwitch_OneEvenK = EndSwitch_OneEven.Port( 'K' )
206
207 GraphSyrControl.Run( 7 )
208
209 GraphSyrControl.DoneW()
210
211 GraphSyrControl.State()
212
213 GraphSyrControl.PrintPorts()
214
215 label_begin.EPyFunc()
216