Salome HOME
9319f43fe3fe1dc62897cfad6f65686e23d7304d
[samples/datafiles.git] / Superv / Python / GraphStreamsXmlTest.py
1 # Copyright (C) 2007-2015  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 from SuperV import *
23
24 FlowGraph = Graph( 'FlowGraph' )
25 Add = FlowGraph.FNode( 'AddComponent' , 'AddComponent' , 'Add' )
26
27 Sub = FlowGraph.FNode( 'SubComponent' , 'SubComponent' , 'Sub' )
28 Addz = Add.GetOutStreamPort( 'z' )
29 if Addz != None :
30     print "Error : GetOutStreamPort of a FlowPort in a FlowGraph"
31 else :
32     print 'None : Ok'
33
34 Addz = Add.Port( 'z' )
35 try :
36     Suby = FlowGraph.StreamLink( Addz , Sub.Port( 'y' ) )
37     print "Error : creation of a StreamLink in a FlowGraph"
38 except :
39     print "Ok"
40
41 links = FlowGraph.StreamLinks()
42 if len(links) != 0 :
43     print "Error : StreamLinks in a FlowGraph"
44
45 ports = FlowGraph.StreamPorts()
46 if len( ports ) != 0 :
47     print "Error : StreamPorts in a FlowGraph"
48
49 links = Add.StreamLinks()
50 if len(links) != 0 :
51     print "Error : StreamLinks in a FlowNode"
52
53 ports = Add.StreamPorts()
54 if len( ports ) != 0 :
55     print "Error : StreamPorts in a FlowNode"
56
57 try :
58     FlowGraph.SetStreamParams( 100 , SUPERV.WithoutTrace , 10. )
59 except :
60     print "No SetStreamParams Ok"
61
62 try :
63     Timeout,DataStreamTrace,DeltaTime = FlowGraph.StreamParams()
64 except :
65     print "No StreamParams Ok"
66
67
68
69
70 from SuperV import *
71
72 anXmlFile = os.getenv('DATA_DIR') + '/Superv/Graphs/GraphStreams.xml'
73 GraphStreams = StreamGraph( anXmlFile )
74
75 GraphStreams.PrintPorts()
76 GraphStreams.PrintLinks()
77
78 exec GraphStreams.ListNodes()
79 Add.PrintPorts()
80 Add.PrintLinks()
81
82 exec Loop.ListPorts()
83 ILoopIndex.Print()
84 OLoopIndex.Print()
85 exec EndLoop.ListPorts()
86 IEndLoopGate.Print()
87 OEndLoopx_Sub.Print()
88 exec Add.ListPorts()
89 IAddx.Print()
90 IAddistream.Print()
91 OAddOStream.Print()
92 exec Sub.ListPorts()
93 exec Mul.ListPorts()
94 exec Div.ListPorts()
95 exec Add_1.ListPorts()
96 exec Sub_1.ListPorts()
97 exec Mul_1.ListPorts()
98 exec Div_1.ListPorts()
99 exec  Add.ListLinks()
100 LLoopIndexAddx.Print()
101 LAddzMuly.Print()
102 LDiv_1ostreamAddistream.Print()
103 LAddOStreamSubIstream.Print()
104
105
106 GraphStreams.IsExecutable()
107
108 GraphStreams.Run()
109 GraphStreams.DoneW()
110 GraphStreams.PrintPorts()
111
112
113
114 subgraphs = GraphStreams.SubGraphsNumber()
115 i = 1
116 while i <= subgraphs :
117     nodes = GraphStreams.SubGraphsNodes( i )
118     j = 0
119     while j < len(nodes) :
120         print 'SubGraph',i,nodes[j].Name()
121         j = j + 1
122     i = i + 1
123
124
125 substreamgraphs = GraphStreams.SubStreamGraphsNumber()
126 i = 1
127 while i <= substreamgraphs :
128     nodes = GraphStreams.SubStreamGraphsNodes( i )
129     j = 0
130     while j < len(nodes) :
131         print 'SubStreamGraph',i,nodes[j].Name()
132         j = j + 1
133     i = i + 1
134