Salome HOME
39e201451efbaa9ba2a596f2919bff91aca0c4a5
[samples/datafiles.git] / Superv / Python / test_superv_basic_loop.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 test_superv_basic_loop
23 #
24 from SuperV import *
25 # Graph creation 
26 test_superv_basic_loop = Graph( 'test_superv_basic_loop' )
27 test_superv_basic_loop.SetName( 'test_superv_basic_loop' )
28 test_superv_basic_loop.SetAuthor( '' )
29 test_superv_basic_loop.SetComment( '' )
30 test_superv_basic_loop.Coords( 0 , 0 )
31
32 # Creation of Factory Nodes
33
34 # Creation of InLine Nodes
35 PyAdd = []
36 PyAdd.append( 'def Sum(sum,incr): ' )
37 PyAdd.append( ' result = sum+incr     ' )
38 PyAdd.append( ' return result,incr     ' )
39 Add = test_superv_basic_loop.INode( 'Sum' , PyAdd )
40 Add.InPort( 'sum' , 'long' )
41 Add.InPort( 'incr' , 'long' )
42 Add.OutPort( 'Sum' , 'long' )
43 Add.OutPort( 'incr' , 'long' )
44 Add.SetName( 'Add' )
45 Add.SetAuthor( '' )
46 Add.SetComment( 'Python function' )
47 Add.Coords( 220 , 40 )
48
49 # Creation of Loop Nodes
50 Pyfori = []
51 Pyfori.append( 'def Init(index,min,max,sum):   ' )
52 Pyfori.append( '        if max > min :   ' )
53 Pyfori.append( '                index = min   ' )
54 Pyfori.append( '        else :   ' )
55 Pyfori.append( '                index = max   ' )
56 Pyfori.append( '        #print index,min,max,sum  ' )
57 Pyfori.append( '        return index,min,max,sum   ' )
58 PyMorefori = []
59 PyMorefori.append( 'def More(index,min,max,sum):   ' )
60 PyMorefori.append( '    OutLoop = 0  ' )
61 PyMorefori.append( '    if max > index :   ' )
62 PyMorefori.append( '            OutLoop = 1  ' )
63 PyMorefori.append( '    #print OutLoop,index,min,max,sum  ' )
64 PyMorefori.append( '    return OutLoop,index,min,max,sum   ' )
65 PyNextfori = []
66 PyNextfori.append( 'def Next(index,min,max,sum):   ' )
67 PyNextfori.append( '    index = index + 1   ' )
68 PyNextfori.append( '    #print index,min,max,sum  ' )
69 PyNextfori.append( '    return index,min,max,sum   ' )
70 fori,Endfori = test_superv_basic_loop.LNode( 'Init' , Pyfori , 'More' , PyMorefori , 'Next' , PyNextfori )
71 Endfori.SetName( 'Endfori' )
72 Endfori.SetAuthor( '' )
73 Endfori.SetComment( '' )
74 Endfori.Coords( 432 , 0 )
75 fori.InPort( 'index' , 'long' )
76 fori.InPort( 'min' , 'long' )
77 fori.InPort( 'max' , 'long' )
78 fori.InPort( 'sum' , 'long' )
79 fori.OutPort( 'index' , 'long' )
80 fori.OutPort( 'min' , 'long' )
81 fori.OutPort( 'max' , 'long' )
82 fori.OutPort( 'sum' , 'long' )
83 fori.SetName( 'fori' )
84 fori.SetAuthor( '' )
85 fori.SetComment( '' )
86 fori.Coords( 12 , 0 )
87
88 # Creation of Links
89 AddSum = Add.Port( 'Sum' )
90 Endforisum = test_superv_basic_loop.Link( AddSum , Endfori.Port( 'sum' ) )
91
92 foriindex = fori.Port( 'index' )
93 Endforiindex = test_superv_basic_loop.Link( foriindex , Endfori.Port( 'index' ) )
94
95 Addincr = test_superv_basic_loop.Link( foriindex , Add.Port( 'incr' ) )
96 Addincr.AddCoord( 1 , 186 , 150 )
97 Addincr.AddCoord( 2 , 187 , 34 )
98
99 forimin = fori.Port( 'min' )
100 Endforimin = test_superv_basic_loop.Link( forimin , Endfori.Port( 'min' ) )
101
102 forimax = fori.Port( 'max' )
103 Endforimax = test_superv_basic_loop.Link( forimax , Endfori.Port( 'max' ) )
104
105 forisum = fori.Port( 'sum' )
106 Addsum = test_superv_basic_loop.Link( forisum , Add.Port( 'sum' ) )
107
108 # Creation of Input datas
109 foriindex = fori.Input( 'index' , 0)
110 forimin = fori.Input( 'min' , 0)
111 forimax = fori.Input( 'max' , 1001)
112 forisum = fori.Input( 'sum' , 0)
113
114 # Creation of Output variables
115 Addincr = Add.Port( 'incr' )
116 Endforiindex = Endfori.Port( 'index' )
117 Endforimin = Endfori.Port( 'min' )
118 Endforimax = Endfori.Port( 'max' )
119 Endforisum = Endfori.Port( 'sum' )
120
121 test_superv_basic_loop.Run()
122 test_superv_basic_loop.DoneW()
123 test_superv_basic_loop.PrintPorts()