Salome HOME
Merge from V6_main_20120808 08Aug12
[samples/datafiles.git] / Superv / Python / GraphInLinesParall.py
1 #  Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
2 #
3 #  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 #
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.
10 #
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.
15 #
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
19 #
20 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #
22 # Generated python file of Graph GraphInLines
23 #
24 from SuperV import *
25 # Graph creation 
26 GraphInLinesParall = Graph( 'GraphInLinesParall' )
27 GraphInLinesParall.SetName( 'GraphInLinesParall' )
28 GraphInLinesParall.SetAuthor( '' )
29 GraphInLinesParall.SetComment( '' )
30 GraphInLinesParall.Coords( 0 , 0 )
31
32 # Creation of Factory Nodes
33
34 # Creation of InLine Nodes
35 PyAdd = []
36 PyAdd.append( 'import time ' )
37 PyAdd.append( 'def Add(a,b) :   ' )
38 PyAdd.append( '    print "Add will wait 5 seconds" ' )
39 PyAdd.append( '    time.sleep(5) ' )
40 PyAdd.append( '    print "Add waited" ' )
41 PyAdd.append( '    return a+b   ' )
42 PyAdd.append( '' )
43 Add = GraphInLinesParall.INode( 'Add' , PyAdd )
44 Add.InPort( 'a' , 'long' )
45 Add.InPort( 'b' , 'long' )
46 Add.OutPort( 'f' , 'long' )
47 Add.SetName( 'Add' )
48 Add.SetAuthor( '' )
49 Add.SetComment( 'Python function' )
50 Add.Coords( 351 , 77 )
51
52 PySub = []
53 PySub.append( 'def Sub(a,b) : ' )
54 PySub.append( '    return a-b ' )
55 PySub.append( '' )
56 Sub = GraphInLinesParall.INode( 'Sub' , PySub )
57 Sub.InPort( 'a' , 'long' )
58 Sub.InPort( 'b' , 'long' )
59 Sub.OutPort( 'f' , 'long' )
60 Sub.SetName( 'Sub' )
61 Sub.SetAuthor( '' )
62 Sub.SetComment( 'Python function' )
63 Sub.Coords( 86 , 333 )
64
65 PyMul = []
66 PyMul.append( 'import time  ' )
67 PyMul.append( 'def Mul(a,b) :    ' )
68 PyMul.append( '    print "Mul will wait 5 seconds"  ' )
69 PyMul.append( '    time.sleep(5)  ' )
70 PyMul.append( '    print "Mul waited"  ' )
71 PyMul.append( '    return a*b  ' )
72 Mul = GraphInLinesParall.INode( 'Mul' , PyMul )
73 Mul.InPort( 'a' , 'long' )
74 Mul.InPort( 'b' , 'long' )
75 Mul.OutPort( 'Result' , 'long' )
76 Mul.SetName( 'Mul' )
77 Mul.SetAuthor( '' )
78 Mul.SetComment( 'Python function' )
79 Mul.Coords( 616 , 247 )
80
81 # Creation of Links
82 Subf = Sub.Port( 'f' )
83 Mulb = GraphInLinesParall.Link( Subf , Mul.Port( 'b' ) )
84 Mulb.AddCoord( 1 , 583 , 357 )
85 Mulb.AddCoord( 2 , 583 , 413 )
86 Mulb.AddCoord( 3 , 282 , 413 )
87
88 Addb = GraphInLinesParall.Link( Subf , Add.Port( 'b' ) )
89 Addb.AddCoord( 1 , 282 , 186 )
90 Addb.AddCoord( 2 , 283 , 413 )
91
92 Mula = GraphInLinesParall.Link( Subf , Mul.Port( 'a' ) )
93 Mula.AddCoord( 1 , 583 , 328 )
94 Mula.AddCoord( 2 , 583 , 412 )
95
96 # Creation of Input datas
97 Adda = Add.Input( 'a' , 1)
98 Suba = Sub.Input( 'a' , 3)
99 Subb = Sub.Input( 'b' , 4)
100
101 # Creation of Output variables
102 Addf = Add.Port( 'f' )
103 MulResult = Mul.Port( 'Result' )
104
105 GraphInLinesParall.Run()
106 GraphInLinesParall.DoneW()
107 GraphInLinesParall.PrintPorts()