Salome HOME
Error messages
[modules/superv.git] / examples / GraphStreamInLines.py
1
2 # Generated python file of Graph GraphStreamInLines
3
4 from SuperV import *
5 # Graph creation 
6 GraphStreamInLines = StreamGraph( 'GraphStreamInLines' )
7 GraphStreamInLines.SetStreamParams( 300 , SUPERV.WithoutTrace , 0 )
8 GraphStreamInLines.SetName( 'GraphStreamInLines' )
9 GraphStreamInLines.SetAuthor( '' )
10 GraphStreamInLines.SetComment( '' )
11 GraphStreamInLines.Coords( 0 , 0 )
12
13 # Creation of Factory Nodes
14
15 # Creation of InLine Nodes
16 PyIsOdd = []
17 PyIsOdd.append( 'from time import *    ' )
18 PyIsOdd.append( 'def IsOdd(a,Even) :        ' )
19 PyIsOdd.append( '    print a,"IsOdd (GraphStreamInLines1)"       ' )
20 PyIsOdd.append( '    sleep( 1 )    ' )
21 PyIsOdd.append( '    return a      ' )
22 IsOdd = GraphStreamInLines.INode( 'IsOdd' , PyIsOdd )
23 IsOdd.SetName( 'IsOdd' )
24 IsOdd.SetAuthor( '' )
25 IsOdd.SetComment( 'Python function' )
26 IsOdd.Coords( 394 , 59 )
27 IIsOdda = IsOdd.InPort( 'a' , 'long' )
28 IIsOddEven = IsOdd.InPort( 'Even' , 'boolean' )
29 IIsOddGate = IsOdd.GetInPort( 'Gate' )
30 OIsOdda = IsOdd.OutPort( 'a' , 'long' )
31 OIsOddGate = IsOdd.GetOutPort( 'Gate' )
32 IIsOddistream = IsOdd.InStreamPort( 'istream' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_TEMPORAL )
33 IIsOddistream.SetParams( SUPERV.TI , SUPERV.L1 , SUPERV.EXTRANULL )
34 OIsOddostream = IsOdd.OutStreamPort( 'ostream' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_ITERATIVE )
35 OIsOddostream.SetNumberOfValues( 0 )
36
37 # Creation of Loop Nodes
38 PyInitLoop = []
39 PyMoreInitLoop = []
40 PyMoreInitLoop.append( '' )
41 PyNextInitLoop = []
42 PyNextInitLoop.append( '' )
43 InitLoop,EndOfInitLoop = GraphStreamInLines.LNode( '' , PyInitLoop , '' , PyMoreInitLoop , '' , PyNextInitLoop )
44 EndOfInitLoop.SetName( 'EndOfInitLoop' )
45 EndOfInitLoop.SetAuthor( '' )
46 EndOfInitLoop.SetComment( '' )
47 EndOfInitLoop.Coords( 776 , 105 )
48 PyEndOfInitLoop = []
49 PyEndOfInitLoop.append( 'def EndOfInitLoop( DoLoop , Index , Min , Max ) :' )
50 PyEndOfInitLoop.append( '       Index = Index + 1     ' )
51 PyEndOfInitLoop.append( '       if Index <= Max :   ' )
52 PyEndOfInitLoop.append( '               DoLoop = 1     ' )
53 PyEndOfInitLoop.append( '       else :     ' )
54 PyEndOfInitLoop.append( '               DoLoop = 0     ' )
55 PyEndOfInitLoop.append( '       return DoLoop,Index,Min,Max     ' )
56 EndOfInitLoop.SetPyFunction( 'EndOfInitLoop' , PyEndOfInitLoop )
57 IInitLoopInitLoop = InitLoop.GetInPort( 'DoLoop' )
58 IInitLoopIndex = InitLoop.InPort( 'Index' , 'long' )
59 IInitLoopMin = InitLoop.InPort( 'Min' , 'long' )
60 IInitLoopMax = InitLoop.InPort( 'Max' , 'long' )
61 IInitLoopistream = InitLoop.InStreamPort( 'istream' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_TEMPORAL )
62 IInitLoopistream.SetParams( SUPERV.TI , SUPERV.L1 , SUPERV.EXTRANULL )
63 IInitLoopGate = InitLoop.GetInPort( 'Gate' )
64 OInitLoopDoLoop = InitLoop.GetOutPort( 'DoLoop' )
65 OInitLoopIndex = InitLoop.GetOutPort( 'Index' )
66 OInitLoopMin = InitLoop.GetOutPort( 'Min' )
67 OInitLoopMax = InitLoop.GetOutPort( 'Max' )
68 OInitLoopostream = InitLoop.OutStreamPort( 'ostream' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_ITERATIVE )
69 OInitLoopostream.SetNumberOfValues( 0 )
70 IEndOfInitLoopDoLoop = EndOfInitLoop.GetInPort( 'DoLoop' )
71 IEndOfInitLoopIndex = EndOfInitLoop.GetInPort( 'Index' )
72 IEndOfInitLoopMin = EndOfInitLoop.GetInPort( 'Min' )
73 IEndOfInitLoopMax = EndOfInitLoop.GetInPort( 'Max' )
74 IEndOfInitLoopistream = EndOfInitLoop.InStreamPort( 'istream' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_ITERATIVE )
75 IEndOfInitLoopistream.SetParams( SUPERV.SCHENULL , SUPERV.INTERNULL , SUPERV.EXTRANULL )
76 IEndOfInitLoopGate = EndOfInitLoop.GetInPort( 'Gate' )
77 OEndOfInitLoopDoLoop = EndOfInitLoop.GetOutPort( 'DoLoop' )
78 OEndOfInitLoopIndex = EndOfInitLoop.GetOutPort( 'Index' )
79 OEndOfInitLoopMin = EndOfInitLoop.GetOutPort( 'Min' )
80 OEndOfInitLoopMax = EndOfInitLoop.GetOutPort( 'Max' )
81 OEndOfInitLoopostream = EndOfInitLoop.OutStreamPort( 'ostream' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_TEMPORAL )
82 OEndOfInitLoopostream.SetNumberOfValues( 0 )
83 InitLoop.SetName( 'InitLoop' )
84 InitLoop.SetAuthor( '' )
85 InitLoop.SetComment( '' )
86 InitLoop.Coords( 11 , 119 )
87 IInitLoopistream = InitLoop.InStreamPort( 'istream' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_TEMPORAL )
88 IInitLoopistream.SetParams( SUPERV.TI , SUPERV.L1 , SUPERV.EXTRANULL )
89 OInitLoopostream = InitLoop.OutStreamPort( 'ostream' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_ITERATIVE )
90 OInitLoopostream.SetNumberOfValues( 0 )
91
92 # Creation of Switch Nodes
93 PySwitch = []
94 PySwitch.append( 'from time import *  ' )
95 PySwitch.append( 'def Switch(a) :    ' )
96 PySwitch.append( '    if ( a & 1 ) == 0 :  ' )
97 PySwitch.append( '        sleep(1)  ' )
98 PySwitch.append( '    return a & 1,1-(a&1),a    ' )
99 Switch,EndSwitch = GraphStreamInLines.SNode( 'Switch' , PySwitch )
100 EndSwitch.SetName( 'EndSwitch' )
101 EndSwitch.SetAuthor( '' )
102 EndSwitch.SetComment( '' )
103 EndSwitch.Coords( 587 , 104 )
104 PyEndSwitch = []
105 PyEndSwitch.append( 'def EndOfSwitch(a) :    ' )
106 PyEndSwitch.append( '    if ( a & 1 ) == 0 :  ' )
107 PyEndSwitch.append( '        sleep(1)  ' )
108 PyEndSwitch.append( '    return a    ' )
109 EndSwitch.SetPyFunction( 'EndOfSwitch' , PyEndSwitch )
110 IEndSwitcha = EndSwitch.InPort( 'a' , 'long' )
111 IEndSwitchistream = EndSwitch.InStreamPort( 'istream' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_TEMPORAL )
112 IEndSwitchistream.SetParams( SUPERV.TI , SUPERV.L1 , SUPERV.EXTRANULL )
113 IEndSwitchDefault = EndSwitch.GetInPort( 'Default' )
114 OEndSwitcha = EndSwitch.OutPort( 'a' , 'long' )
115 OEndSwitchostream = EndSwitch.OutStreamPort( 'ostream' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_TEMPORAL )
116 OEndSwitchostream.SetNumberOfValues( 0 )
117 OEndSwitchGate = EndSwitch.GetOutPort( 'Gate' )
118 Switch.SetName( 'Switch' )
119 Switch.SetAuthor( '' )
120 Switch.SetComment( '' )
121 Switch.Coords( 197 , 119 )
122 ISwitcha = Switch.InPort( 'a' , 'long' )
123 ISwitchGate = Switch.GetInPort( 'Gate' )
124 OSwitchOdd = Switch.OutPort( 'Odd' , 'long' )
125 OSwitchEven = Switch.OutPort( 'Even' , 'int' )
126 OSwitcha = Switch.OutPort( 'a' , 'int' )
127 OSwitchDefault = Switch.GetOutPort( 'Default' )
128 ISwitchistream = Switch.InStreamPort( 'istream' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_TEMPORAL )
129 ISwitchistream.SetParams( SUPERV.TI , SUPERV.L1 , SUPERV.EXTRANULL )
130 OSwitchostream = Switch.OutStreamPort( 'ostream' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_ITERATIVE )
131 OSwitchostream.SetNumberOfValues( 0 )
132
133 # Creation of Links
134 LIsOddaEndSwitcha = GraphStreamInLines.Link( OIsOdda , IEndSwitcha )
135
136 LIsOddostreamInitLoopistream = GraphStreamInLines.StreamLink( OIsOddostream , IInitLoopistream )
137 LIsOddostreamInitLoopistream.AddCoord( 1 , 3 , 240 )
138 LIsOddostreamInitLoopistream.AddCoord( 2 , 3 , 395 )
139 LIsOddostreamInitLoopistream.AddCoord( 3 , 571 , 394 )
140 LIsOddostreamInitLoopistream.AddCoord( 4 , 571 , 187 )
141
142 LInitLoopIndexSwitcha = GraphStreamInLines.Link( OInitLoopIndex , ISwitcha )
143
144 LInitLoopMinEndOfInitLoopMin = GraphStreamInLines.Link( OInitLoopMin , IEndOfInitLoopMin )
145
146 LInitLoopMaxEndOfInitLoopMax = GraphStreamInLines.Link( OInitLoopMax , IEndOfInitLoopMax )
147
148 LInitLoopostreamEndSwitchistream = GraphStreamInLines.StreamLink( OInitLoopostream , IEndSwitchistream )
149 LInitLoopostreamEndSwitchistream.AddCoord( 1 , 584 , 167 )
150 LInitLoopostreamEndSwitchistream.AddCoord( 2 , 584 , 369 )
151 LInitLoopostreamEndSwitchistream.AddCoord( 3 , 184 , 368 )
152 LInitLoopostreamEndSwitchistream.AddCoord( 4 , 185 , 240 )
153
154 LSwitchOddIsOddGate = GraphStreamInLines.Link( OSwitchOdd , IIsOddGate )
155 LSwitchOddIsOddGate.AddCoord( 1 , 373 , 222 )
156 LSwitchOddIsOddGate.AddCoord( 2 , 373 , 147 )
157
158 LSwitchEvenEndSwitchDefault = GraphStreamInLines.Link( OSwitchEven , IEndSwitchDefault )
159
160 LSwitchEvenIsOddEven = GraphStreamInLines.Link( OSwitchEven , IIsOddEven )
161 LSwitchEvenIsOddEven.AddCoord( 1 , 363 , 154 )
162 LSwitchEvenIsOddEven.AddCoord( 2 , 362 , 177 )
163
164 LSwitchaIsOdda = GraphStreamInLines.Link( OSwitcha , IIsOdda )
165 LSwitchaIsOdda.AddCoord( 1 , 385 , 123 )
166 LSwitchaIsOdda.AddCoord( 2 , 386 , 206 )
167
168 LSwitchostreamIsOddistream = GraphStreamInLines.StreamLink( OSwitchostream , IIsOddistream )
169 LSwitchostreamIsOddistream.AddCoord( 1 , 360 , 185 )
170 LSwitchostreamIsOddistream.AddCoord( 2 , 361 , 240 )
171
172 LSwitchostreamEndOfInitLoopistream = GraphStreamInLines.StreamLink( OSwitchostream , IEndOfInitLoopistream )
173 LSwitchostreamEndOfInitLoopistream.AddCoord( 1 , 775 , 226 )
174 LSwitchostreamEndOfInitLoopistream.AddCoord( 2 , 775 , 261 )
175 LSwitchostreamEndOfInitLoopistream.AddCoord( 3 , 361 , 261 )
176 LSwitchostreamEndOfInitLoopistream.AddCoord( 4 , 361 , 240 )
177
178 LEndSwitchaEndOfInitLoopIndex = GraphStreamInLines.Link( OEndSwitcha , IEndOfInitLoopIndex )
179
180 LEndSwitchostreamSwitchistream = GraphStreamInLines.StreamLink( OEndSwitchostream , ISwitchistream )
181 LEndSwitchostreamSwitchistream.AddCoord( 1 , 186 , 240 )
182 LEndSwitchostreamSwitchistream.AddCoord( 2 , 186 , 331 )
183 LEndSwitchostreamSwitchistream.AddCoord( 3 , 766 , 330 )
184 LEndSwitchostreamSwitchistream.AddCoord( 4 , 766 , 167 )
185
186 # Input datas
187 IInitLoopIndex.Input( 0 )
188 IInitLoopMin.Input( 0 )
189 IInitLoopMax.Input( 100 )
190
191 # Output Ports of the graph
192 #OEndOfInitLoopIndex = EndOfInitLoop.GetOutPort( 'Index' )
193 #OEndOfInitLoopMin = EndOfInitLoop.GetOutPort( 'Min' )
194 #OEndOfInitLoopMax = EndOfInitLoop.GetOutPort( 'Max' )
195
196
197
198 GraphStreamInLines.Run()
199 GraphStreamInLines.DoneW()
200 print GraphStreamInLines.State()
201
202 GraphStreamInLines.PrintPorts()
203
204
205 subgraphs = GraphStreamInLines.SubGraphsNumber()
206 i = 1
207 while i <= subgraphs :
208     nodes = GraphStreamInLines.SubGraphsNodes( i )
209     j = 0
210     while j < len(nodes) :
211         print 'SubGraph',i,nodes[j].Name()
212         j = j + 1
213     i = i + 1
214
215
216 substreamgraphs = GraphStreamInLines.SubStreamGraphsNumber()
217 i = 1
218 while i <= substreamgraphs :
219     nodes = GraphStreamInLines.SubStreamGraphsNodes( i )
220     j = 0
221     while j < len(nodes) :
222         print 'SubStreamGraph',i,nodes[j].Name()
223         j = j + 1
224     i = i + 1
225
226 GraphStreamInLines.Export('/tmp/GraphStreamInLines.xml')
227
228 from SuperV import *
229 GraphStreamInLines = StreamGraph('/tmp/GraphStreamInLines.xml')
230
231
232 GraphStreamInLines.Run()
233 GraphStreamInLines.DoneW()
234 print GraphStreamInLines.State()
235
236 subgraphs = GraphStreamInLines.SubGraphsNumber()
237 i = 1
238 while i <= subgraphs :
239     nodes = GraphStreamInLines.SubGraphsNodes( i )
240     j = 0
241     while j < len(nodes) :
242         print 'SubGraph',i,nodes[j].Name()
243         j = j + 1
244     i = i + 1
245
246
247 substreamgraphs = GraphStreamInLines.SubStreamGraphsNumber()
248 i = 1
249 while i <= substreamgraphs :
250     nodes = GraphStreamInLines.SubStreamGraphsNodes( i )
251     j = 0
252     while j < len(nodes) :
253         print 'SubStreamGraph',i,nodes[j].Name()
254         j = j + 1
255     i = i + 1
256