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