1 # Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #==============================================================================
24 # File : supervisionexample.py
25 # Created : 23 nov 2001
26 # Author : Jean Rahuel
28 #==============================================================================
34 # load this object with Nodes, Links and Datas stored in GraphEssai.xml
35 # (GraphEssai.xml was created with python in SuperVisionTest and GraphEssai.py)
36 myGraph = Graph("@ROOT_BUILDDIR@/share/salome/resources/superv/GraphEssai.xml")
38 #myGraph = Graph("/home/data/jr_HEAD/build/share/salome/resources/superv/GraphEssai.xml")
39 # This DataFlow is "valid" : no loop, correct links between Nodes etc...
41 print myGraph.IsValid()
45 Add,Sub,Mul,Div = myGraph.Nodes()
48 Addx = Add.Input("x",3.)
49 Addy = Add.Input("y",4.5)
50 Subx = Sub.Input("x",1.5)
58 # This DataFlow is "executable" : all pending Ports are defined with Datas
59 print myGraph.IsExecutable()
61 # Starts only execution of that DataFlow and gets control immediatly
64 # That DataFlow is running ==> 0 (false)
65 print myGraph.IsDone()
67 # Events of execution :
68 aStatus,aNode,anEvent,aState = myGraph.Event()
70 print aNode.Thread(),aNode.SubGraph(),aNode.Name(),anEvent,aState
71 aStatus,aNode,anEvent,aState = myGraph.Event()
72 print myGraph.IsDone()
74 # Wait for Completion (but it is already done after event loop ...)
75 print "Done : ",myGraph.DoneW()
78 print "Result : ",Divz.ToString()
80 # Intermediate results :
81 print "Intermediate Result Add\z : ",Addz.ToString()
82 print "Intermediate Result Sub\z : ",Subz.ToString()
83 print "Intermediate Result Mul\z : ",Mulz.ToString()
86 print "Type : print myGraph.IsDone()"
87 print " If execution is finished ==> 1 (true)"
89 print "Type : print Divz.ToString()"
90 print " You will get the result"
92 print "Type : myGraph.PrintPorts()"
93 print " to see input and output values of the graph"
95 print "Type : Add.PrintPorts()"
96 print "Type : Sub.PrintPorts()"
97 print "Type : Mul.PrintPorts()"
98 print "Type : Div.PrintPorts()"
99 print " to see input and output values of nodes"
101 # Export will create newsupervisionexample.xml and the corresponding .py file
102 print myGraph.Export("@ROOT_BUILDDIR@/share/salome/resources/superv/newsupervisionexample.xml")
105 print "See file @ROOT_BUILDDIR@/share/salome/resources/superv/newsupervisionexample.xml"
106 print "See file @ROOT_BUILDDIR@/share/salome/resources/superv/newsupervisionexample.py"