Salome HOME
8ee59d26607db74f4ad3cb1c0634f2303688ded5
[samples/datafiles.git] / Superv / Python / GraphStreamTopologies.py
1 #  Copyright (C) 2007-2011  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 GraphStreamTopologies
23 #
24 from SuperV import *
25 # Graph creation 
26 GraphStreamTopologies = StreamGraph( 'GraphStreamTopologies' )
27 GraphStreamTopologies.SetStreamParams( 300 , SUPERV.WithoutTrace , 0 )
28 GraphStreamTopologies.SetName( 'GraphStreamTopologies' )
29 GraphStreamTopologies.SetAuthor( 'JR' )
30 GraphStreamTopologies.SetComment( 'Test of SubStreamGraphs of a StreamGraph' )
31 GraphStreamTopologies.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 = GraphStreamTopologies.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( 29 , 66 )
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 = GraphStreamTopologies.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( 23 , 309 )
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 = GraphStreamTopologies.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( 249 , 66 )
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 = GraphStreamTopologies.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( 245 , 308 )
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 = GraphStreamTopologies.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( 481 , 67 )
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 = GraphStreamTopologies.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( 476 , 307 )
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 = GraphStreamTopologies.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( 703 , 306 )
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 = GraphStreamTopologies.Link( ONode_A_1a_1 , INode_B_1b_1 )
149
150 LNode_A_2a_2Node_B_2b_2 = GraphStreamTopologies.Link( ONode_A_2a_2 , INode_B_2b_2 )
151
152 LNode_A_2ostream_A_2_1Node_A_1istream_A_1_1 = GraphStreamTopologies.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 , 13 , 164 )
154 LNode_A_2ostream_A_2_1Node_A_1istream_A_1_1.AddCoord( 2 , 13 , 44 )
155 LNode_A_2ostream_A_2_1Node_A_1istream_A_1_1.AddCoord( 3 , 207 , 44 )
156 LNode_A_2ostream_A_2_1Node_A_1istream_A_1_1.AddCoord( 4 , 207 , 409 )
157
158 LNode_B_1b_1Node_C_1c_1 = GraphStreamTopologies.Link( ONode_B_1b_1 , INode_C_1c_1 )
159
160 LNode_B_2b_2Node_C_2c_2 = GraphStreamTopologies.Link( ONode_B_2b_2 , INode_C_2c_2 )
161
162 LNode_B_2ostream_B_2_1Node_A_1istream_A_1_2 = GraphStreamTopologies.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 , 14 , 195 )
164 LNode_B_2ostream_B_2_1Node_A_1istream_A_1_2.AddCoord( 2 , 13 , 299 )
165 LNode_B_2ostream_B_2_1Node_A_1istream_A_1_2.AddCoord( 3 , 428 , 300 )
166 LNode_B_2ostream_B_2_1Node_A_1istream_A_1_2.AddCoord( 4 , 428 , 407 )
167
168 LNode_B_2ostream_B_2_2Node_A_2istream_A_2_1 = GraphStreamTopologies.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 , 12 , 406 )
170 LNode_B_2ostream_B_2_2Node_A_2istream_A_2_1.AddCoord( 2 , 11 , 525 )
171 LNode_B_2ostream_B_2_2Node_A_2istream_A_2_1.AddCoord( 3 , 427 , 525 )
172 LNode_B_2ostream_B_2_2Node_A_2istream_A_2_1.AddCoord( 4 , 426 , 438 )
173
174 LNode_C_1ostream_C_1_1Node_A_1istream_A_1_3 = GraphStreamTopologies.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 , 5 , 227 )
176 LNode_C_1ostream_C_1_1Node_A_1istream_A_1_3.AddCoord( 2 , 5 , 16 )
177 LNode_C_1ostream_C_1_1Node_A_1istream_A_1_3.AddCoord( 3 , 672 , 16 )
178 LNode_C_1ostream_C_1_1Node_A_1istream_A_1_3.AddCoord( 4 , 671 , 166 )
179
180 LNode_C_2c_2Node_D_1d_1 = GraphStreamTopologies.Link( ONode_C_2c_2 , INode_D_1d_1 )
181
182 LNode_D_1ostream_D_1_1Node_C_2istream_C_2_1 = GraphStreamTopologies.StreamLink( ONode_D_1ostream_D_1_1 , INode_C_2istream_C_2_1 )
183 LNode_D_1ostream_D_1_1Node_C_2istream_C_2_1.AddCoord( 1 , 453 , 406 )
184 LNode_D_1ostream_D_1_1Node_C_2istream_C_2_1.AddCoord( 2 , 454 , 499 )
185 LNode_D_1ostream_D_1_1Node_C_2istream_C_2_1.AddCoord( 3 , 903 , 500 )
186 LNode_D_1ostream_D_1_1Node_C_2istream_C_2_1.AddCoord( 4 , 903 , 404 )
187
188 LNode_D_1ostream_D_1_1Node_B_1istream_B_1_1 = GraphStreamTopologies.StreamLink( ONode_D_1ostream_D_1_1 , INode_B_1istream_B_1_1 )
189 LNode_D_1ostream_D_1_1Node_B_1istream_B_1_1.AddCoord( 1 , 229 , 163 )
190 LNode_D_1ostream_D_1_1Node_B_1istream_B_1_1.AddCoord( 2 , 229 , 282 )
191 LNode_D_1ostream_D_1_1Node_B_1istream_B_1_1.AddCoord( 3 , 902 , 282 )
192 LNode_D_1ostream_D_1_1Node_B_1istream_B_1_1.AddCoord( 4 , 903 , 404 )
193
194 # Input datas
195 INode_B_2istream_B_2_1.Input( 1 )
196
197 # Output Ports of the graph
198
199 GraphStreamTopologies.Run()
200 GraphStreamTopologies.DoneW()
201 GraphStreamTopologies.State()
202
203 subgraphs = GraphStreamTopologies.SubGraphsNumber()
204 i = 1
205 while i <= subgraphs :
206     nodes = GraphStreamTopologies.SubGraphsNodes( i )
207     j = 0
208     while j < len(nodes) :
209         print 'SubGraph',i,nodes[j].Name()
210         j = j + 1
211     i = i + 1
212
213
214 substreamgraphs = GraphStreamTopologies.SubStreamGraphsNumber()
215 i = 1
216 while i <= substreamgraphs :
217     nodes = GraphStreamTopologies.SubStreamGraphsNodes( i )
218     j = 0
219     while j < len(nodes) :
220         print 'SubStreamGraph',i,nodes[j].Name()
221         j = j + 1
222     i = i + 1
223
224
225 GraphStreamTopologies.Export( '/tmp/GraphStreamTopologies.xml' )
226
227 GraphStreamTopologies = StreamGraph( '/tmp/GraphStreamTopologies.xml' )
228
229 GraphStreamTopologies.PrintPorts()
230
231 GraphStreamTopologies.Run()
232 GraphStreamTopologies.DoneW()
233 GraphStreamTopologies.State()
234
235 subgraphs = GraphStreamTopologies.SubGraphsNumber()
236 i = 1
237 while i <= subgraphs :
238     nodes = GraphStreamTopologies.SubGraphsNodes( i )
239     j = 0
240     while j < len(nodes) :
241         print 'SubGraph',i,nodes[j].Name()
242         j = j + 1
243     i = i + 1
244
245
246 substreamgraphs = GraphStreamTopologies.SubStreamGraphsNumber()
247 i = 1
248 while i <= substreamgraphs :
249     nodes = GraphStreamTopologies.SubStreamGraphsNodes( i )
250     j = 0
251     while j < len(nodes) :
252         print 'SubStreamGraph',i,nodes[j].Name()
253         j = j + 1
254     i = i + 1
255