]> SALOME platform Git repositories - modules/gui.git/blob - src/SALOME_SWIG/supervisionexample.py.in
Salome HOME
36a97cc412d2227f365d8dc20ee11b2f5241947f
[modules/gui.git] / src / SALOME_SWIG / supervisionexample.py.in
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 #==============================================================================
23 #  File      : supervisionexample.py
24 #  Created   : 23 nov 2001
25 #  Author    : Jean Rahuel
26 #  Project   : SALOME
27 #==============================================================================
28
29 from SuperV import *
30
31
32
33 # load this object with Nodes, Links and Datas stored in GraphEssai.xml
34 # (GraphEssai.xml was created with python in SuperVisionTest and GraphEssai.py)
35 myGraph = Graph("@ROOT_BUILDDIR@/share/salome/resources/superv/GraphEssai.xml")
36
37 #myGraph = Graph("/home/data/jr_HEAD/build/share/salome/resources/superv/GraphEssai.xml")
38 # This DataFlow is "valid" : no loop, correct links between Nodes etc...
39
40 print myGraph.IsValid()
41
42 # Get Nodes
43 myGraph.PrintNodes()
44 Add,Sub,Mul,Div = myGraph.Nodes()
45
46 # Load Datas
47 Addx = Add.Input("x",3.)
48 Addy = Add.Input("y",4.5)
49 Subx = Sub.Input("x",1.5)
50
51 # Get Output Port
52 Addz = Add.Port('z')
53 Subz = Sub.Port('z')
54 Mulz = Mul.Port('z')
55 Divz = Div.Port('z')
56
57 # This DataFlow is "executable" : all pending Ports are defined with Datas
58 print myGraph.IsExecutable()
59
60 # Starts only execution of that DataFlow and gets control immediatly
61 print myGraph.Run()
62
63 # That DataFlow is running ==> 0 (false)
64 print myGraph.IsDone()
65
66 # Events of execution :
67 aStatus,aNode,anEvent,aState = myGraph.Event()
68 while aStatus :
69     print aNode.Thread(),aNode.SubGraph(),aNode.Name(),anEvent,aState
70     aStatus,aNode,anEvent,aState = myGraph.Event()
71 print myGraph.IsDone()
72
73 # Wait for Completion (but it is already done after event loop ...)
74 print "Done : ",myGraph.DoneW()
75
76 # Get result
77 print "Result : ",Divz.ToString()
78
79 # Intermediate results :
80 print "Intermediate Result Add\z : ",Addz.ToString()
81 print "Intermediate Result Sub\z : ",Subz.ToString()
82 print "Intermediate Result Mul\z : ",Mulz.ToString()
83
84 print " "
85 print "Type : print myGraph.IsDone()"
86 print "       If execution is finished ==> 1 (true)"
87 print " "
88 print "Type : print Divz.ToString()"
89 print "       You will get the result"
90 print " "
91 print "Type : myGraph.PrintPorts()"
92 print "       to see input and output values of the graph"
93 print " "
94 print "Type : Add.PrintPorts()"
95 print "Type : Sub.PrintPorts()"
96 print "Type : Mul.PrintPorts()"
97 print "Type : Div.PrintPorts()"
98 print "       to see input and output values of nodes"
99
100 # Export will create newsupervisionexample.xml and the corresponding .py file
101 print myGraph.Export("@ROOT_BUILDDIR@/share/salome/resources/superv/newsupervisionexample.xml")
102
103 print " "
104 print "See file @ROOT_BUILDDIR@/share/salome/resources/superv/newsupervisionexample.xml"
105 print "See file @ROOT_BUILDDIR@/share/salome/resources/superv/newsupervisionexample.py"