1 # Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
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.
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.
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
17 # See http://www.salome-platform.org/
19 #==============================================================================
20 # File : supervisionexample.py
21 # Created : 23 nov 2001
22 # Author : Jean Rahuel
25 #==============================================================================
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")
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...
38 print myGraph.IsValid()
42 Add,Sub,Mul,Div = myGraph.Nodes()
45 Addx = Add.Input("x",3.)
46 Addy = Add.Input("y",4.5)
47 Subx = Sub.Input("x",1.5)
55 # This DataFlow is "executable" : all pending Ports are defined with Datas
56 print myGraph.IsExecutable()
58 # Starts only execution of that DataFlow and gets control immediatly
61 # That DataFlow is running ==> 0 (false)
62 print myGraph.IsDone()
64 # Events of execution :
65 aStatus,aNode,anEvent,aState = myGraph.Event()
67 print aNode.Thread(),aNode.SubGraph(),aNode.Name(),anEvent,aState
68 aStatus,aNode,anEvent,aState = myGraph.Event()
69 print myGraph.IsDone()
71 # Wait for Completion (but it is already done after event loop ...)
72 print "Done : ",myGraph.DoneW()
75 print "Result : ",Divz.ToString()
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()
83 print "Type : print myGraph.IsDone()"
84 print " If execution is finished ==> 1 (true)"
86 print "Type : print Divz.ToString()"
87 print " You will get the result"
89 print "Type : myGraph.PrintPorts()"
90 print " to see input and output values of the graph"
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"
98 # Export will create newsupervisionexample.xml and the corresponding .py file
99 print myGraph.Export("@ROOT_BUILDDIR@/share/salome/resources/newsupervisionexample.xml")
102 print "See file @ROOT_BUILDDIR@/share/salome/resources/newsupervisionexample.xml"
103 print "See file @ROOT_BUILDDIR@/share/salome/resources/newsupervisionexample.py"