Salome HOME
Merge from V6_main_20120808 08Aug12
[samples/datafiles.git] / Superv / Python / GraphExample.py
1 #! /usr/bin/env python
2 #  Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
3 #
4 #  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 #
7 #  This library is free software; you can redistribute it and/or
8 #  modify it under the terms of the GNU Lesser General Public
9 #  License as published by the Free Software Foundation; either
10 #  version 2.1 of the License.
11 #
12 #  This library is distributed in the hope that it will be useful,
13 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
14 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 #  Lesser General Public License for more details.
16 #
17 #  You should have received a copy of the GNU Lesser General Public
18 #  License along with this library; if not, write to the Free Software
19 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
20 #
21 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #
23 #==============================================================================
24 #  File      : GraphExample.py
25 #  Created   : 18 déc 2001
26 #  Author    : Jean Rahuel
27 #  Project   : SALOME
28 #==============================================================================
29 #from GraphExample import *
30 #
31 from SuperV import *
32
33 myGraph = Graph( "myDataFlow" )
34
35 Add = myGraph.Node( "AddComponent" , "AddInterface" , "Add" )
36 print Add.SetContainer('dm2s0017')
37 Sub = myGraph.Node( "SubComponent" , "SubInterface" , "Sub" )
38 print Sub.SetContainer('dm2s0018')
39 Mul = myGraph.Node( "MulComponent" , "MulInterface" , "Mul" )
40 print Mul.SetContainer('dm2s0019')
41 Div = myGraph.Node( "DivComponent" , "DivInterface" , "Div" )
42 print Div.SetContainer('dm2s0020')
43
44 PAddz = Add.Port("z")
45 PSuby = Sub.Port("y")
46 Suby = myGraph.Link( PAddz , PSuby )
47 Muly = myGraph.Link( Add.Port("z") , Mul.Port("y") )
48 Mulx = myGraph.Link( Sub.Port( "z" ) , Mul.Port("x") )
49 Divx = myGraph.Link( Sub.Port( "z" ) , Div.Port("x") )
50 Divy = myGraph.Link( Mul.Port( "z" ) , Div.Port("y") )
51
52 Addx = Add.Input( "x" , 3 )
53 Addy = Add.Input( "y" , 4.5 )
54 Subx = Sub.Input( "x" , "1.5" )
55
56 print "Add(x) input value : ",Addx.ToString()
57 print "Add(y) input value : ",Addy.ToString()
58 print "Sub(x) input value : ",Subx.ToString()
59
60 Divz = Div.Port("z")
61
62 print Divz.ToString()
63
64 print myGraph.IsValid()
65 print myGraph.IsExecutable()
66
67 print myGraph.Run()
68
69 Addz = Add.Port( "z" )
70 AddFuncValue = Add.Port( "FuncValue" )
71 Subz = Sub.Port( "z" )
72 Mulz = Mul.Port( "z" )
73 Divz = Div.Port( "z" )
74
75 print AddFuncValue.Done()
76 print Addz.Done()
77 print Subz.Done()
78 print Mulz.Done()
79 print Divz.Done()
80 print Add.Done()
81 print Sub.Done()
82 print Mul.Done()
83 print Div.Done()
84 print myGraph.Done()
85 print myGraph.State()
86
87 print AddFuncValue.ToString()
88 print Addz.ToString()
89 print Subz.ToString()
90 print Mulz.ToString()
91 print Divz.ToString()
92 print Divz.ToAny()
93