Salome HOME
Update copyrights 2014.
[samples/datafiles.git] / Superv / Python / GraphStreamTopology.py
1 # Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
2 #
3 # Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 #
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License, or (at your option) any later version.
10 #
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 # Lesser General Public License for more details.
15 #
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 #
20 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #
22
23 # Generated python file of Graph GraphStreamTopology
24 #
25 from SuperV import *
26 # Graph creation 
27 GraphStreamTopology = StreamGraph( 'GraphStreamTopology' )
28 GraphStreamTopology.SetStreamParams( 300 , SUPERV.WithoutTrace , 0 )
29 GraphStreamTopology.SetName( 'GraphStreamTopology' )
30 GraphStreamTopology.SetAuthor( 'JR' )
31 GraphStreamTopology.SetComment( 'Test of SubStreamGraphs of a StreamGraph' )
32 GraphStreamTopology.Coords( 0 , 0 )
33
34 # Creation of Factory Nodes
35
36 # Creation of InLine Nodes
37 PyNode_A_1 = []
38 PyNode_A_1.append( 'def Node_A_1() :        ' )
39 PyNode_A_1.append( '    return 1      ' )
40 Node_A_1 = GraphStreamTopology.INode( 'Node_A_1' , PyNode_A_1 )
41 Node_A_1.SetName( 'Node_A_1' )
42 Node_A_1.SetAuthor( '' )
43 Node_A_1.SetComment( 'Python function' )
44 Node_A_1.Coords( 32 , 65 )
45 INode_A_1Gate = Node_A_1.GetInPort( 'Gate' )
46 ONode_A_1a_1 = Node_A_1.OutPort( 'a_1' , 'long' )
47 ONode_A_1Gate = Node_A_1.GetOutPort( 'Gate' )
48 INode_A_1istream_A_1_1 = Node_A_1.InStreamPort( 'istream_A_1_1' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_TEMPORAL )
49 INode_A_1istream_A_1_1.SetParams( SUPERV.TI , SUPERV.L1 , SUPERV.EXTRANULL )
50 INode_A_1istream_A_1_2 = Node_A_1.InStreamPort( 'istream_A_1_2' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_TEMPORAL )
51 INode_A_1istream_A_1_2.SetParams( SUPERV.TI , SUPERV.L1 , SUPERV.EXTRANULL )
52 INode_A_1istream_A_1_3 = Node_A_1.InStreamPort( 'istream_A_1_3' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_TEMPORAL )
53 INode_A_1istream_A_1_3.SetParams( SUPERV.TI , SUPERV.L1 , SUPERV.EXTRANULL )
54
55 PyNode_A_2 = []
56 PyNode_A_2.append( 'def Node_A_2() :        ' )
57 PyNode_A_2.append( '    return 1      ' )
58 Node_A_2 = GraphStreamTopology.INode( 'Node_A_2' , PyNode_A_2 )
59 Node_A_2.SetName( 'Node_A_2' )
60 Node_A_2.SetAuthor( '' )
61 Node_A_2.SetComment( 'Python function' )
62 Node_A_2.Coords( 31 , 336 )
63 INode_A_2Gate = Node_A_2.GetInPort( 'Gate' )
64 ONode_A_2a_2 = Node_A_2.OutPort( 'a_2' , 'long' )
65 ONode_A_2Gate = Node_A_2.GetOutPort( 'Gate' )
66 INode_A_2istream_A_2_1 = Node_A_2.InStreamPort( 'istream_A_2_1' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_TEMPORAL )
67 INode_A_2istream_A_2_1.SetParams( SUPERV.TI , SUPERV.L1 , SUPERV.EXTRANULL )
68 ONode_A_2ostream_A_2_1 = Node_A_2.OutStreamPort( 'ostream_A_2_1' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_TEMPORAL )
69 ONode_A_2ostream_A_2_1.SetNumberOfValues( 0 )
70
71 PyNode_B_1 = []
72 PyNode_B_1.append( 'def Node_B_1( n ) :        ' )
73 PyNode_B_1.append( '    return n      ' )
74 Node_B_1 = GraphStreamTopology.INode( 'Node_B_1' , PyNode_B_1 )
75 Node_B_1.SetName( 'Node_B_1' )
76 Node_B_1.SetAuthor( '' )
77 Node_B_1.SetComment( 'Python function' )
78 Node_B_1.Coords( 254 , 64 )
79 INode_B_1b_1 = Node_B_1.InPort( 'b_1' , 'long' )
80 INode_B_1Gate = Node_B_1.GetInPort( 'Gate' )
81 ONode_B_1b_1 = Node_B_1.OutPort( 'b_1' , 'long' )
82 ONode_B_1Gate = Node_B_1.GetOutPort( 'Gate' )
83 INode_B_1istream_B_1_1 = Node_B_1.InStreamPort( 'istream_B_1_1' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_TEMPORAL )
84 INode_B_1istream_B_1_1.SetParams( SUPERV.TI , SUPERV.L1 , SUPERV.EXTRANULL )
85
86 PyNode_B_2 = []
87 PyNode_B_2.append( 'def Node_B_2( n ) :        ' )
88 PyNode_B_2.append( '    return n      ' )
89 Node_B_2 = GraphStreamTopology.INode( 'Node_B_2' , PyNode_B_2 )
90 Node_B_2.SetName( 'Node_B_2' )
91 Node_B_2.SetAuthor( '' )
92 Node_B_2.SetComment( 'Python function' )
93 Node_B_2.Coords( 255 , 336 )
94 INode_B_2b_2 = Node_B_2.InPort( 'b_2' , 'long' )
95 INode_B_2Gate = Node_B_2.GetInPort( 'Gate' )
96 ONode_B_2b_2 = Node_B_2.OutPort( 'b_2' , 'long' )
97 ONode_B_2Gate = Node_B_2.GetOutPort( 'Gate' )
98 INode_B_2istream_B_2_1 = Node_B_2.InStreamPort( 'istream_B_2_1' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_TEMPORAL )
99 INode_B_2istream_B_2_1.SetParams( SUPERV.TI , SUPERV.L1 , SUPERV.EXTRANULL )
100 ONode_B_2ostream_B_2_1 = Node_B_2.OutStreamPort( 'ostream_B_2_1' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_TEMPORAL )
101 ONode_B_2ostream_B_2_1.SetNumberOfValues( 0 )
102 ONode_B_2ostream_B_2_2 = Node_B_2.OutStreamPort( 'ostream_B_2_2' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_TEMPORAL )
103 ONode_B_2ostream_B_2_2.SetNumberOfValues( 0 )
104
105 PyNode_C_1 = []
106 PyNode_C_1.append( 'def Node_C_1( n ) :        ' )
107 PyNode_C_1.append( '    return       ' )
108 Node_C_1 = GraphStreamTopology.INode( 'Node_C_1' , PyNode_C_1 )
109 Node_C_1.SetName( 'Node_C_1' )
110 Node_C_1.SetAuthor( '' )
111 Node_C_1.SetComment( 'Python function' )
112 Node_C_1.Coords( 478 , 63 )
113 INode_C_1c_1 = Node_C_1.InPort( 'c_1' , 'long' )
114 INode_C_1Gate = Node_C_1.GetInPort( 'Gate' )
115 ONode_C_1Gate = Node_C_1.GetOutPort( 'Gate' )
116 ONode_C_1ostream_C_1_1 = Node_C_1.OutStreamPort( 'ostream_C_1_1' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_TEMPORAL )
117 ONode_C_1ostream_C_1_1.SetNumberOfValues( 0 )
118
119 PyNode_C_2 = []
120 PyNode_C_2.append( 'def Node_C_2( n ) :        ' )
121 PyNode_C_2.append( '    return n      ' )
122 Node_C_2 = GraphStreamTopology.INode( 'Node_C_2' , PyNode_C_2 )
123 Node_C_2.SetName( 'Node_C_2' )
124 Node_C_2.SetAuthor( '' )
125 Node_C_2.SetComment( 'Python function' )
126 Node_C_2.Coords( 477 , 337 )
127 INode_C_2c_2 = Node_C_2.InPort( 'c_2' , 'long' )
128 INode_C_2Gate = Node_C_2.GetInPort( 'Gate' )
129 ONode_C_2c_2 = Node_C_2.OutPort( 'c_2' , 'long' )
130 ONode_C_2Gate = Node_C_2.GetOutPort( 'Gate' )
131 INode_C_2istream_C_2_1 = Node_C_2.InStreamPort( 'istream_C_2_1' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_TEMPORAL )
132 INode_C_2istream_C_2_1.SetParams( SUPERV.TI , SUPERV.L1 , SUPERV.EXTRANULL )
133
134 PyNode_D_1 = []
135 PyNode_D_1.append( 'def Node_D_1( n ) :        ' )
136 PyNode_D_1.append( '    return       ' )
137 Node_D_1 = GraphStreamTopology.INode( 'Node_D_1' , PyNode_D_1 )
138 Node_D_1.SetName( 'Node_D_1' )
139 Node_D_1.SetAuthor( '' )
140 Node_D_1.SetComment( 'Python function' )
141 Node_D_1.Coords( 702 , 336 )
142 INode_D_1d_1 = Node_D_1.InPort( 'd_1' , 'long' )
143 INode_D_1Gate = Node_D_1.GetInPort( 'Gate' )
144 ONode_D_1Gate = Node_D_1.GetOutPort( 'Gate' )
145 ONode_D_1ostream_D_1_1 = Node_D_1.OutStreamPort( 'ostream_D_1_1' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_TEMPORAL )
146 ONode_D_1ostream_D_1_1.SetNumberOfValues( 0 )
147
148 # Creation of Links
149 LNode_A_1a_1Node_B_1b_1 = GraphStreamTopology.Link( ONode_A_1a_1 , INode_B_1b_1 )
150
151 LNode_A_2a_2Node_B_2b_2 = GraphStreamTopology.Link( ONode_A_2a_2 , INode_B_2b_2 )
152
153 LNode_A_2ostream_A_2_1Node_A_1istream_A_1_1 = GraphStreamTopology.StreamLink( ONode_A_2ostream_A_2_1 , INode_A_1istream_A_1_1 )
154 LNode_A_2ostream_A_2_1Node_A_1istream_A_1_1.AddCoord( 1 , 14 , 162 )
155 LNode_A_2ostream_A_2_1Node_A_1istream_A_1_1.AddCoord( 2 , 13 , 37 )
156 LNode_A_2ostream_A_2_1Node_A_1istream_A_1_1.AddCoord( 3 , 211 , 36 )
157 LNode_A_2ostream_A_2_1Node_A_1istream_A_1_1.AddCoord( 4 , 210 , 435 )
158
159 LNode_B_1b_1Node_C_1c_1 = GraphStreamTopology.Link( ONode_B_1b_1 , INode_C_1c_1 )
160
161 LNode_B_2b_2Node_C_2c_2 = GraphStreamTopology.Link( ONode_B_2b_2 , INode_C_2c_2 )
162
163 LNode_B_2ostream_B_2_1Node_A_1istream_A_1_2 = GraphStreamTopology.StreamLink( ONode_B_2ostream_B_2_1 , INode_A_1istream_A_1_2 )
164 LNode_B_2ostream_B_2_1Node_A_1istream_A_1_2.AddCoord( 1 , 8 , 195 )
165 LNode_B_2ostream_B_2_1Node_A_1istream_A_1_2.AddCoord( 2 , 7 , 324 )
166 LNode_B_2ostream_B_2_1Node_A_1istream_A_1_2.AddCoord( 3 , 443 , 323 )
167 LNode_B_2ostream_B_2_1Node_A_1istream_A_1_2.AddCoord( 4 , 442 , 434 )
168
169 LNode_B_2ostream_B_2_2Node_A_2istream_A_2_1 = GraphStreamTopology.StreamLink( ONode_B_2ostream_B_2_2 , INode_A_2istream_A_2_1 )
170 LNode_B_2ostream_B_2_2Node_A_2istream_A_2_1.AddCoord( 1 , 16 , 433 )
171 LNode_B_2ostream_B_2_2Node_A_2istream_A_2_1.AddCoord( 2 , 15 , 583 )
172 LNode_B_2ostream_B_2_2Node_A_2istream_A_2_1.AddCoord( 3 , 434 , 584 )
173 LNode_B_2ostream_B_2_2Node_A_2istream_A_2_1.AddCoord( 4 , 434 , 467 )
174
175 LNode_C_1ostream_C_1_1Node_A_1istream_A_1_3 = GraphStreamTopology.StreamLink( ONode_C_1ostream_C_1_1 , INode_A_1istream_A_1_3 )
176 LNode_C_1ostream_C_1_1Node_A_1istream_A_1_3.AddCoord( 1 , 21 , 226 )
177 LNode_C_1ostream_C_1_1Node_A_1istream_A_1_3.AddCoord( 2 , 20 , 296 )
178 LNode_C_1ostream_C_1_1Node_A_1istream_A_1_3.AddCoord( 3 , 663 , 295 )
179 LNode_C_1ostream_C_1_1Node_A_1istream_A_1_3.AddCoord( 4 , 662 , 161 )
180
181 LNode_C_2c_2Node_D_1d_1 = GraphStreamTopology.Link( ONode_C_2c_2 , INode_D_1d_1 )
182
183 LNode_D_1ostream_D_1_1Node_B_2istream_B_2_1 = GraphStreamTopology.StreamLink( ONode_D_1ostream_D_1_1 , INode_B_2istream_B_2_1 )
184 LNode_D_1ostream_D_1_1Node_B_2istream_B_2_1.AddCoord( 1 , 232 , 433 )
185 LNode_D_1ostream_D_1_1Node_B_2istream_B_2_1.AddCoord( 2 , 231 , 553 )
186 LNode_D_1ostream_D_1_1Node_B_2istream_B_2_1.AddCoord( 3 , 903 , 553 )
187 LNode_D_1ostream_D_1_1Node_B_2istream_B_2_1.AddCoord( 4 , 902 , 434 )
188
189 LNode_D_1ostream_D_1_1Node_C_2istream_C_2_1 = GraphStreamTopology.StreamLink( ONode_D_1ostream_D_1_1 , INode_C_2istream_C_2_1 )
190 LNode_D_1ostream_D_1_1Node_C_2istream_C_2_1.AddCoord( 1 , 461 , 434 )
191 LNode_D_1ostream_D_1_1Node_C_2istream_C_2_1.AddCoord( 2 , 461 , 524 )
192 LNode_D_1ostream_D_1_1Node_C_2istream_C_2_1.AddCoord( 3 , 889 , 525 )
193 LNode_D_1ostream_D_1_1Node_C_2istream_C_2_1.AddCoord( 4 , 888 , 434 )
194
195 LNode_D_1ostream_D_1_1Node_B_1istream_B_1_1 = GraphStreamTopology.StreamLink( ONode_D_1ostream_D_1_1 , INode_B_1istream_B_1_1 )
196 LNode_D_1ostream_D_1_1Node_B_1istream_B_1_1.AddCoord( 1 , 236 , 162 )
197 LNode_D_1ostream_D_1_1Node_B_1istream_B_1_1.AddCoord( 2 , 236 , 249 )
198 LNode_D_1ostream_D_1_1Node_B_1istream_B_1_1.AddCoord( 3 , 887 , 249 )
199 LNode_D_1ostream_D_1_1Node_B_1istream_B_1_1.AddCoord( 4 , 888 , 432 )
200
201 # Output Ports of the graph
202
203
204
205
206 GraphStreamTopology.Run()
207 GraphStreamTopology.DoneW()
208 print GraphStreamTopology.State()
209
210 GraphStreamTopology.PrintPorts()
211
212 subgraphs = GraphStreamTopology.SubGraphsNumber()
213 i = 1
214 while i <= subgraphs :
215     nodes = GraphStreamTopology.SubGraphsNodes( i )
216     j = 0
217     while j < len(nodes) :
218         print 'SubGraph',i,nodes[j].Name()
219         j = j + 1
220     i = i + 1
221
222
223 substreamgraphs = GraphStreamTopology.SubStreamGraphsNumber()
224 i = 1
225 while i <= substreamgraphs :
226     nodes = GraphStreamTopology.SubStreamGraphsNodes( i )
227     j = 0
228     while j < len(nodes) :
229         print 'SubStreamGraph',i,nodes[j].Name()
230         j = j + 1
231     i = i + 1
232
233
234
235 GraphStreamTopology.Export( '/tmp/GraphStreamTopology.xml' )
236
237 GraphStreamTopology = StreamGraph( '/tmp/GraphStreamTopology.xml' )
238
239 GraphStreamTopology.PrintPorts()
240
241 GraphStreamTopology.Run()
242 GraphStreamTopology.DoneW()
243 GraphStreamTopology.State()
244
245 subgraphs = GraphStreamTopology.SubGraphsNumber()
246 i = 1
247 while i <= subgraphs :
248     nodes = GraphStreamTopology.SubGraphsNodes( i )
249     j = 0
250     while j < len(nodes) :
251         print 'SubGraph',i,nodes[j].Name()
252         j = j + 1
253     i = i + 1
254
255
256 substreamgraphs = GraphStreamTopology.SubStreamGraphsNumber()
257 i = 1
258 while i <= substreamgraphs :
259     nodes = GraphStreamTopology.SubStreamGraphsNodes( i )
260     j = 0
261     while j < len(nodes) :
262         print 'SubStreamGraph',i,nodes[j].Name()
263         j = j + 1
264     i = i + 1
265