Salome HOME
Fix for bug IPAL9983 : Object browser is not updated after dataflow run.
[modules/superv.git] / examples / GraphExample.py
1 #! /usr/bin/env python
2
3 #==============================================================================
4 #  File      : GraphExample.py
5 #  Created   : 18 déc 2001
6 #  Author    : Jean Rahuel
7 #  Project   : SALOME
8 #  Copyright : CEA
9 #==============================================================================
10
11 #from GraphExample import *
12
13 from SuperV import *
14
15 myGraph = Graph( "myDataFlow" )
16
17 Add = myGraph.Node( "AddComponent" , "AddInterface" , "Add" )
18 print Add.SetContainer('dm2s0017')
19 Sub = myGraph.Node( "SubComponent" , "SubInterface" , "Sub" )
20 print Sub.SetContainer('dm2s0018')
21 Mul = myGraph.Node( "MulComponent" , "MulInterface" , "Mul" )
22 print Mul.SetContainer('dm2s0019')
23 Div = myGraph.Node( "DivComponent" , "DivInterface" , "Div" )
24 print Div.SetContainer('dm2s0020')
25
26 PAddz = Add.Port("z")
27 PSuby = Sub.Port("y")
28 Suby = myGraph.Link( PAddz , PSuby )
29 Muly = myGraph.Link( Add.Port("z") , Mul.Port("y") )
30 Mulx = myGraph.Link( Sub.Port( "z" ) , Mul.Port("x") )
31 Divx = myGraph.Link( Sub.Port( "z" ) , Div.Port("x") )
32 Divy = myGraph.Link( Mul.Port( "z" ) , Div.Port("y") )
33
34 Addx = Add.Input( "x" , 3 )
35 Addy = Add.Input( "y" , 4.5 )
36 Subx = Sub.Input( "x" , "1.5" )
37
38 print "Add(x) input value : ",Addx.ToString()
39 print "Add(y) input value : ",Addy.ToString()
40 print "Sub(x) input value : ",Subx.ToString()
41
42 Divz = Div.Port("z")
43
44 print Divz.ToString()
45
46 print myGraph.IsValid()
47 print myGraph.IsExecutable()
48
49 print myGraph.Run()
50
51 Addz = Add.Port( "z" )
52 AddFuncValue = Add.Port( "FuncValue" )
53 Subz = Sub.Port( "z" )
54 Mulz = Mul.Port( "z" )
55 Divz = Div.Port( "z" )
56
57 print AddFuncValue.Done()
58 print Addz.Done()
59 print Subz.Done()
60 print Mulz.Done()
61 print Divz.Done()
62 print Add.Done()
63 print Sub.Done()
64 print Mul.Done()
65 print Div.Done()
66 print myGraph.Done()
67 print myGraph.State()
68
69 print AddFuncValue.ToString()
70 print Addz.ToString()
71 print Subz.ToString()
72 print Mulz.ToString()
73 print Divz.ToString()
74 print Divz.ToAny()
75