]> SALOME platform Git repositories - modules/gui.git/blob - src/SALOME_SWIG/supervisionexample.py
Salome HOME
9444eb9c163fc593bc5bd9b6f32bb71f6cf0ed7c
[modules/gui.git] / src / SALOME_SWIG / supervisionexample.py
1 #  Copyright (C) 2005  CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
2 #
3 #  This library is free software; you can redistribute it and/or
4 #  modify it under the terms of the GNU Lesser General Public
5 #  License as published by the Free Software Foundation; either
6 #  version 2.1 of the License.
7 #
8 #  This library is distributed in the hope that it will be useful,
9 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 #  Lesser General Public License for more details.
12 #
13 #  You should have received a copy of the GNU Lesser General Public
14 #  License along with this library; if not, write to the Free Software
15 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 #  See http://www.salome-platform.org/
18 #
19 #==============================================================================
20 #  File      : supervisionexample.py
21 #  Created   : 23 nov 2001
22 #  Author    : Jean Rahuel
23 #  Project   : SALOME
24 #  Copyright : CEA
25 #==============================================================================
26
27 from SuperV import *
28
29
30
31 # load this object with Nodes, Links and Datas stored in GraphEssai.xml
32 # (GraphEssai.xml was created with python in SuperVisionTest and GraphEssai.py)
33 myGraph = Graph("@ROOT_BUILDDIR@/share/salome/resources/GraphEssai.xml")
34
35 #myGraph = Graph("/home/data/jr_HEAD/build/share/salome/resources/GraphEssai.xml")
36 # This DataFlow is "valid" : no loop, correct links between Nodes etc...
37
38 print myGraph.IsValid()
39
40 # Get Nodes
41 myGraph.PrintNodes()
42 Add,Sub,Mul,Div = myGraph.Nodes()
43
44 # Load Datas
45 Addx = Add.Input("x",3.)
46 Addy = Add.Input("y",4.5)
47 Subx = Sub.Input("x",1.5)
48
49 # Get Output Port
50 Addz = Add.Port('z')
51 Subz = Sub.Port('z')
52 Mulz = Mul.Port('z')
53 Divz = Div.Port('z')
54
55 # This DataFlow is "executable" : all pending Ports are defined with Datas
56 print myGraph.IsExecutable()
57
58 # Starts only execution of that DataFlow and gets control immediatly
59 print myGraph.Run()
60
61 # That DataFlow is running ==> 0 (false)
62 print myGraph.IsDone()
63
64 # Events of execution :
65 aStatus,aNode,anEvent,aState = myGraph.Event()
66 while aStatus :
67     print aNode.Thread(),aNode.SubGraph(),aNode.Name(),anEvent,aState
68     aStatus,aNode,anEvent,aState = myGraph.Event()
69 print myGraph.IsDone()
70
71 # Wait for Completion (but it is already done after event loop ...)
72 print "Done : ",myGraph.DoneW()
73
74 # Get result
75 print "Result : ",Divz.ToString()
76
77 # Intermediate results :
78 print "Intermediate Result Add\z : ",Addz.ToString()
79 print "Intermediate Result Sub\z : ",Subz.ToString()
80 print "Intermediate Result Mul\z : ",Mulz.ToString()
81
82 print " "
83 print "Type : print myGraph.IsDone()"
84 print "       If execution is finished ==> 1 (true)"
85 print " "
86 print "Type : print Divz.ToString()"
87 print "       You will get the result"
88 print " "
89 print "Type : myGraph.PrintPorts()"
90 print "       to see input and output values of the graph"
91 print " "
92 print "Type : Add.PrintPorts()"
93 print "Type : Sub.PrintPorts()"
94 print "Type : Mul.PrintPorts()"
95 print "Type : Div.PrintPorts()"
96 print "       to see input and output values of nodes"
97
98 # Export will create newsupervisionexample.xml and the corresponding .py file
99 print myGraph.Export("@ROOT_BUILDDIR@/share/salome/resources/newsupervisionexample.xml")
100
101 print " "
102 print "See file @ROOT_BUILDDIR@/share/salome/resources/newsupervisionexample.xml"
103 print "See file @ROOT_BUILDDIR@/share/salome/resources/newsupervisionexample.py"