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