Salome HOME
Merge from BR_V5_DEV 17Feb09
[samples/datafiles.git] / Superv / Python / GraphStreamTopology.py
1 #  Copyright (C) 2007-2008  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.
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 # Generated python file of Graph GraphStreamTopology
23 #
24 from SuperV import *
25 # Graph creation 
26 GraphStreamTopology = StreamGraph( 'GraphStreamTopology' )
27 GraphStreamTopology.SetStreamParams( 300 , SUPERV.WithoutTrace , 0 )
28 GraphStreamTopology.SetName( 'GraphStreamTopology' )
29 GraphStreamTopology.SetAuthor( 'JR' )
30 GraphStreamTopology.SetComment( 'Test of SubStreamGraphs of a StreamGraph' )
31 GraphStreamTopology.Coords( 0 , 0 )
32
33 # Creation of Factory Nodes
34
35 # Creation of InLine Nodes
36 PyNode_A_1 = []
37 PyNode_A_1.append( 'def Node_A_1() :        ' )
38 PyNode_A_1.append( '    return 1      ' )
39 Node_A_1 = GraphStreamTopology.INode( 'Node_A_1' , PyNode_A_1 )
40 Node_A_1.SetName( 'Node_A_1' )
41 Node_A_1.SetAuthor( '' )
42 Node_A_1.SetComment( 'Python function' )
43 Node_A_1.Coords( 32 , 65 )
44 INode_A_1Gate = Node_A_1.GetInPort( 'Gate' )
45 ONode_A_1a_1 = Node_A_1.OutPort( 'a_1' , 'long' )
46 ONode_A_1Gate = Node_A_1.GetOutPort( 'Gate' )
47 INode_A_1istream_A_1_1 = Node_A_1.InStreamPort( 'istream_A_1_1' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_TEMPORAL )
48 INode_A_1istream_A_1_1.SetParams( SUPERV.TI , SUPERV.L1 , SUPERV.EXTRANULL )
49 INode_A_1istream_A_1_2 = Node_A_1.InStreamPort( 'istream_A_1_2' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_TEMPORAL )
50 INode_A_1istream_A_1_2.SetParams( SUPERV.TI , SUPERV.L1 , SUPERV.EXTRANULL )
51 INode_A_1istream_A_1_3 = Node_A_1.InStreamPort( 'istream_A_1_3' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_TEMPORAL )
52 INode_A_1istream_A_1_3.SetParams( SUPERV.TI , SUPERV.L1 , SUPERV.EXTRANULL )
53
54 PyNode_A_2 = []
55 PyNode_A_2.append( 'def Node_A_2() :        ' )
56 PyNode_A_2.append( '    return 1      ' )
57 Node_A_2 = GraphStreamTopology.INode( 'Node_A_2' , PyNode_A_2 )
58 Node_A_2.SetName( 'Node_A_2' )
59 Node_A_2.SetAuthor( '' )
60 Node_A_2.SetComment( 'Python function' )
61 Node_A_2.Coords( 31 , 336 )
62 INode_A_2Gate = Node_A_2.GetInPort( 'Gate' )
63 ONode_A_2a_2 = Node_A_2.OutPort( 'a_2' , 'long' )
64 ONode_A_2Gate = Node_A_2.GetOutPort( 'Gate' )
65 INode_A_2istream_A_2_1 = Node_A_2.InStreamPort( 'istream_A_2_1' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_TEMPORAL )
66 INode_A_2istream_A_2_1.SetParams( SUPERV.TI , SUPERV.L1 , SUPERV.EXTRANULL )
67 ONode_A_2ostream_A_2_1 = Node_A_2.OutStreamPort( 'ostream_A_2_1' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_TEMPORAL )
68 ONode_A_2ostream_A_2_1.SetNumberOfValues( 0 )
69
70 PyNode_B_1 = []
71 PyNode_B_1.append( 'def Node_B_1( n ) :        ' )
72 PyNode_B_1.append( '    return n      ' )
73 Node_B_1 = GraphStreamTopology.INode( 'Node_B_1' , PyNode_B_1 )
74 Node_B_1.SetName( 'Node_B_1' )
75 Node_B_1.SetAuthor( '' )
76 Node_B_1.SetComment( 'Python function' )
77 Node_B_1.Coords( 254 , 64 )
78 INode_B_1b_1 = Node_B_1.InPort( 'b_1' , 'long' )
79 INode_B_1Gate = Node_B_1.GetInPort( 'Gate' )
80 ONode_B_1b_1 = Node_B_1.OutPort( 'b_1' , 'long' )
81 ONode_B_1Gate = Node_B_1.GetOutPort( 'Gate' )
82 INode_B_1istream_B_1_1 = Node_B_1.InStreamPort( 'istream_B_1_1' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_TEMPORAL )
83 INode_B_1istream_B_1_1.SetParams( SUPERV.TI , SUPERV.L1 , SUPERV.EXTRANULL )
84
85 PyNode_B_2 = []
86 PyNode_B_2.append( 'def Node_B_2( n ) :        ' )
87 PyNode_B_2.append( '    return n      ' )
88 Node_B_2 = GraphStreamTopology.INode( 'Node_B_2' , PyNode_B_2 )
89 Node_B_2.SetName( 'Node_B_2' )
90 Node_B_2.SetAuthor( '' )
91 Node_B_2.SetComment( 'Python function' )
92 Node_B_2.Coords( 255 , 336 )
93 INode_B_2b_2 = Node_B_2.InPort( 'b_2' , 'long' )
94 INode_B_2Gate = Node_B_2.GetInPort( 'Gate' )
95 ONode_B_2b_2 = Node_B_2.OutPort( 'b_2' , 'long' )
96 ONode_B_2Gate = Node_B_2.GetOutPort( 'Gate' )
97 INode_B_2istream_B_2_1 = Node_B_2.InStreamPort( 'istream_B_2_1' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_TEMPORAL )
98 INode_B_2istream_B_2_1.SetParams( SUPERV.TI , SUPERV.L1 , SUPERV.EXTRANULL )
99 ONode_B_2ostream_B_2_1 = Node_B_2.OutStreamPort( 'ostream_B_2_1' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_TEMPORAL )
100 ONode_B_2ostream_B_2_1.SetNumberOfValues( 0 )
101 ONode_B_2ostream_B_2_2 = Node_B_2.OutStreamPort( 'ostream_B_2_2' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_TEMPORAL )
102 ONode_B_2ostream_B_2_2.SetNumberOfValues( 0 )
103
104 PyNode_C_1 = []
105 PyNode_C_1.append( 'def Node_C_1( n ) :        ' )
106 PyNode_C_1.append( '    return       ' )
107 Node_C_1 = GraphStreamTopology.INode( 'Node_C_1' , PyNode_C_1 )
108 Node_C_1.SetName( 'Node_C_1' )
109 Node_C_1.SetAuthor( '' )
110 Node_C_1.SetComment( 'Python function' )
111 Node_C_1.Coords( 478 , 63 )
112 INode_C_1c_1 = Node_C_1.InPort( 'c_1' , 'long' )
113 INode_C_1Gate = Node_C_1.GetInPort( 'Gate' )
114 ONode_C_1Gate = Node_C_1.GetOutPort( 'Gate' )
115 ONode_C_1ostream_C_1_1 = Node_C_1.OutStreamPort( 'ostream_C_1_1' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_TEMPORAL )
116 ONode_C_1ostream_C_1_1.SetNumberOfValues( 0 )
117
118 PyNode_C_2 = []
119 PyNode_C_2.append( 'def Node_C_2( n ) :        ' )
120 PyNode_C_2.append( '    return n      ' )
121 Node_C_2 = GraphStreamTopology.INode( 'Node_C_2' , PyNode_C_2 )
122 Node_C_2.SetName( 'Node_C_2' )
123 Node_C_2.SetAuthor( '' )
124 Node_C_2.SetComment( 'Python function' )
125 Node_C_2.Coords( 477 , 337 )
126 INode_C_2c_2 = Node_C_2.InPort( 'c_2' , 'long' )
127 INode_C_2Gate = Node_C_2.GetInPort( 'Gate' )
128 ONode_C_2c_2 = Node_C_2.OutPort( 'c_2' , 'long' )
129 ONode_C_2Gate = Node_C_2.GetOutPort( 'Gate' )
130 INode_C_2istream_C_2_1 = Node_C_2.InStreamPort( 'istream_C_2_1' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_TEMPORAL )
131 INode_C_2istream_C_2_1.SetParams( SUPERV.TI , SUPERV.L1 , SUPERV.EXTRANULL )
132
133 PyNode_D_1 = []
134 PyNode_D_1.append( 'def Node_D_1( n ) :        ' )
135 PyNode_D_1.append( '    return       ' )
136 Node_D_1 = GraphStreamTopology.INode( 'Node_D_1' , PyNode_D_1 )
137 Node_D_1.SetName( 'Node_D_1' )
138 Node_D_1.SetAuthor( '' )
139 Node_D_1.SetComment( 'Python function' )
140 Node_D_1.Coords( 702 , 336 )
141 INode_D_1d_1 = Node_D_1.InPort( 'd_1' , 'long' )
142 INode_D_1Gate = Node_D_1.GetInPort( 'Gate' )
143 ONode_D_1Gate = Node_D_1.GetOutPort( 'Gate' )
144 ONode_D_1ostream_D_1_1 = Node_D_1.OutStreamPort( 'ostream_D_1_1' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_TEMPORAL )
145 ONode_D_1ostream_D_1_1.SetNumberOfValues( 0 )
146
147 # Creation of Links
148 LNode_A_1a_1Node_B_1b_1 = GraphStreamTopology.Link( ONode_A_1a_1 , INode_B_1b_1 )
149
150 LNode_A_2a_2Node_B_2b_2 = GraphStreamTopology.Link( ONode_A_2a_2 , INode_B_2b_2 )
151
152 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 )
153 LNode_A_2ostream_A_2_1Node_A_1istream_A_1_1.AddCoord( 1 , 14 , 162 )
154 LNode_A_2ostream_A_2_1Node_A_1istream_A_1_1.AddCoord( 2 , 13 , 37 )
155 LNode_A_2ostream_A_2_1Node_A_1istream_A_1_1.AddCoord( 3 , 211 , 36 )
156 LNode_A_2ostream_A_2_1Node_A_1istream_A_1_1.AddCoord( 4 , 210 , 435 )
157
158 LNode_B_1b_1Node_C_1c_1 = GraphStreamTopology.Link( ONode_B_1b_1 , INode_C_1c_1 )
159
160 LNode_B_2b_2Node_C_2c_2 = GraphStreamTopology.Link( ONode_B_2b_2 , INode_C_2c_2 )
161
162 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 )
163 LNode_B_2ostream_B_2_1Node_A_1istream_A_1_2.AddCoord( 1 , 8 , 195 )
164 LNode_B_2ostream_B_2_1Node_A_1istream_A_1_2.AddCoord( 2 , 7 , 324 )
165 LNode_B_2ostream_B_2_1Node_A_1istream_A_1_2.AddCoord( 3 , 443 , 323 )
166 LNode_B_2ostream_B_2_1Node_A_1istream_A_1_2.AddCoord( 4 , 442 , 434 )
167
168 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 )
169 LNode_B_2ostream_B_2_2Node_A_2istream_A_2_1.AddCoord( 1 , 16 , 433 )
170 LNode_B_2ostream_B_2_2Node_A_2istream_A_2_1.AddCoord( 2 , 15 , 583 )
171 LNode_B_2ostream_B_2_2Node_A_2istream_A_2_1.AddCoord( 3 , 434 , 584 )
172 LNode_B_2ostream_B_2_2Node_A_2istream_A_2_1.AddCoord( 4 , 434 , 467 )
173
174 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 )
175 LNode_C_1ostream_C_1_1Node_A_1istream_A_1_3.AddCoord( 1 , 21 , 226 )
176 LNode_C_1ostream_C_1_1Node_A_1istream_A_1_3.AddCoord( 2 , 20 , 296 )
177 LNode_C_1ostream_C_1_1Node_A_1istream_A_1_3.AddCoord( 3 , 663 , 295 )
178 LNode_C_1ostream_C_1_1Node_A_1istream_A_1_3.AddCoord( 4 , 662 , 161 )
179
180 LNode_C_2c_2Node_D_1d_1 = GraphStreamTopology.Link( ONode_C_2c_2 , INode_D_1d_1 )
181
182 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 )
183 LNode_D_1ostream_D_1_1Node_B_2istream_B_2_1.AddCoord( 1 , 232 , 433 )
184 LNode_D_1ostream_D_1_1Node_B_2istream_B_2_1.AddCoord( 2 , 231 , 553 )
185 LNode_D_1ostream_D_1_1Node_B_2istream_B_2_1.AddCoord( 3 , 903 , 553 )
186 LNode_D_1ostream_D_1_1Node_B_2istream_B_2_1.AddCoord( 4 , 902 , 434 )
187
188 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 )
189 LNode_D_1ostream_D_1_1Node_C_2istream_C_2_1.AddCoord( 1 , 461 , 434 )
190 LNode_D_1ostream_D_1_1Node_C_2istream_C_2_1.AddCoord( 2 , 461 , 524 )
191 LNode_D_1ostream_D_1_1Node_C_2istream_C_2_1.AddCoord( 3 , 889 , 525 )
192 LNode_D_1ostream_D_1_1Node_C_2istream_C_2_1.AddCoord( 4 , 888 , 434 )
193
194 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 )
195 LNode_D_1ostream_D_1_1Node_B_1istream_B_1_1.AddCoord( 1 , 236 , 162 )
196 LNode_D_1ostream_D_1_1Node_B_1istream_B_1_1.AddCoord( 2 , 236 , 249 )
197 LNode_D_1ostream_D_1_1Node_B_1istream_B_1_1.AddCoord( 3 , 887 , 249 )
198 LNode_D_1ostream_D_1_1Node_B_1istream_B_1_1.AddCoord( 4 , 888 , 432 )
199
200 # Output Ports of the graph
201
202
203
204
205 GraphStreamTopology.Run()
206 GraphStreamTopology.DoneW()
207 print GraphStreamTopology.State()
208
209 GraphStreamTopology.PrintPorts()
210
211 subgraphs = GraphStreamTopology.SubGraphsNumber()
212 i = 1
213 while i <= subgraphs :
214     nodes = GraphStreamTopology.SubGraphsNodes( i )
215     j = 0
216     while j < len(nodes) :
217         print 'SubGraph',i,nodes[j].Name()
218         j = j + 1
219     i = i + 1
220
221
222 substreamgraphs = GraphStreamTopology.SubStreamGraphsNumber()
223 i = 1
224 while i <= substreamgraphs :
225     nodes = GraphStreamTopology.SubStreamGraphsNodes( i )
226     j = 0
227     while j < len(nodes) :
228         print 'SubStreamGraph',i,nodes[j].Name()
229         j = j + 1
230     i = i + 1
231
232
233
234 GraphStreamTopology.Export( '/tmp/GraphStreamTopology.xml' )
235
236 GraphStreamTopology = StreamGraph( '/tmp/GraphStreamTopology.xml' )
237
238 GraphStreamTopology.PrintPorts()
239
240 GraphStreamTopology.Run()
241 GraphStreamTopology.DoneW()
242 GraphStreamTopology.State()
243
244 subgraphs = GraphStreamTopology.SubGraphsNumber()
245 i = 1
246 while i <= subgraphs :
247     nodes = GraphStreamTopology.SubGraphsNodes( i )
248     j = 0
249     while j < len(nodes) :
250         print 'SubGraph',i,nodes[j].Name()
251         j = j + 1
252     i = i + 1
253
254
255 substreamgraphs = GraphStreamTopology.SubStreamGraphsNumber()
256 i = 1
257 while i <= substreamgraphs :
258     nodes = GraphStreamTopology.SubStreamGraphsNodes( i )
259     j = 0
260     while j < len(nodes) :
261         print 'SubStreamGraph',i,nodes[j].Name()
262         j = j + 1
263     i = i + 1
264