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