Salome HOME
Copyrights update 2015.
[samples/datafiles.git] / Superv / Python / GraphExample.py
1 #! /usr/bin/env python
2 # Copyright (C) 2007-2015  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, or (at your option) any later version.
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 #==============================================================================
25 #  File      : GraphExample.py
26 #  Created   : 18 d?c 2001
27 #  Author    : Jean Rahuel
28 #  Project   : SALOME
29 #==============================================================================
30 #from GraphExample import *
31 #
32 from SuperV import *
33
34 myGraph = Graph( "myDataFlow" )
35
36 Add = myGraph.Node( "AddComponent" , "AddInterface" , "Add" )
37 print Add.SetContainer('dm2s0017')
38 Sub = myGraph.Node( "SubComponent" , "SubInterface" , "Sub" )
39 print Sub.SetContainer('dm2s0018')
40 Mul = myGraph.Node( "MulComponent" , "MulInterface" , "Mul" )
41 print Mul.SetContainer('dm2s0019')
42 Div = myGraph.Node( "DivComponent" , "DivInterface" , "Div" )
43 print Div.SetContainer('dm2s0020')
44
45 PAddz = Add.Port("z")
46 PSuby = Sub.Port("y")
47 Suby = myGraph.Link( PAddz , PSuby )
48 Muly = myGraph.Link( Add.Port("z") , Mul.Port("y") )
49 Mulx = myGraph.Link( Sub.Port( "z" ) , Mul.Port("x") )
50 Divx = myGraph.Link( Sub.Port( "z" ) , Div.Port("x") )
51 Divy = myGraph.Link( Mul.Port( "z" ) , Div.Port("y") )
52
53 Addx = Add.Input( "x" , 3 )
54 Addy = Add.Input( "y" , 4.5 )
55 Subx = Sub.Input( "x" , "1.5" )
56
57 print "Add(x) input value : ",Addx.ToString()
58 print "Add(y) input value : ",Addy.ToString()
59 print "Sub(x) input value : ",Subx.ToString()
60
61 Divz = Div.Port("z")
62
63 print Divz.ToString()
64
65 print myGraph.IsValid()
66 print myGraph.IsExecutable()
67
68 print myGraph.Run()
69
70 Addz = Add.Port( "z" )
71 AddFuncValue = Add.Port( "FuncValue" )
72 Subz = Sub.Port( "z" )
73 Mulz = Mul.Port( "z" )
74 Divz = Div.Port( "z" )
75
76 print AddFuncValue.Done()
77 print Addz.Done()
78 print Subz.Done()
79 print Mulz.Done()
80 print Divz.Done()
81 print Add.Done()
82 print Sub.Done()
83 print Mul.Done()
84 print Div.Done()
85 print myGraph.Done()
86 print myGraph.State()
87
88 print AddFuncValue.ToString()
89 print Addz.ToString()
90 print Subz.ToString()
91 print Mulz.ToString()
92 print Divz.ToString()
93 print Divz.ToAny()
94