Salome HOME
721d3951f07c9e136f064428d84e18afffce150f
[samples/datafiles.git] / Superv / Python / GraphLoop1.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 GraphLoop1
23 #
24 from SuperV import *
25
26 # Graph creation of GraphLoop1
27 def DefGraphLoop1() :
28     GraphLoop1 = Graph( 'GraphLoop1' )
29     GraphLoop1.SetName( 'GraphLoop1' )
30     GraphLoop1.SetAuthor( '' )
31     GraphLoop1.SetComment( '' )
32     GraphLoop1.Coords( 0 , 0 )
33     
34     # Creation of Factory Nodes
35     
36     # Creation of InLine Nodes
37     PyNodeIndex = []
38     NodeIndex = GraphLoop1.INode( '' , PyNodeIndex )
39     NodeIndex.SetName( 'NodeIndex' )
40     NodeIndex.SetAuthor( '' )
41     NodeIndex.SetComment( 'Compute Node' )
42     NodeIndex.Coords( 281 , 215 )
43     INodeIndexIndex = NodeIndex.InPort( 'Index' , 'long' )
44     INodeIndexGate = NodeIndex.GetInPort( 'Gate' )
45     ONodeIndexIndex = NodeIndex.OutPort( 'Index' , 'long' )
46     ONodeIndexGate = NodeIndex.GetOutPort( 'Gate' )
47     
48     PyNodeIncr = []
49     NodeIncr = GraphLoop1.INode( '' , PyNodeIncr )
50     NodeIncr.SetName( 'NodeIncr' )
51     NodeIncr.SetAuthor( '' )
52     NodeIncr.SetComment( 'Compute Node' )
53     NodeIncr.Coords( 278 , 372 )
54     INodeIncrIncr = NodeIncr.InPort( 'Incr' , 'long' )
55     INodeIncrGate = NodeIncr.GetInPort( 'Gate' )
56     ONodeIncrIncr = NodeIncr.OutPort( 'Incr' , 'long' )
57     ONodeIncrGate = NodeIncr.GetOutPort( 'Gate' )
58     
59     # Creation of Loop Nodes
60     PyInit = []
61     PyInit.append( 'def Init(Index,Min,Max,Incr) :   ' )
62     PyInit.append( '    if Min <= Max :   ' )
63     PyInit.append( '        Index = Min   ' )
64     PyInit.append( '    else :   ' )
65     PyInit.append( '        Index = Max   ' )
66     PyInit.append( '    return Index,Min,Max,Incr   ' )
67     PyMoreInit = []
68     PyMoreInit.append( 'import time ' )
69     PyMoreInit.append( 'def More(Index,Min,Max,Incr) :   ' )
70     PyMoreInit.append( '    time.sleep(2) ' )
71     PyMoreInit.append( '    if Index < Max :   ' )
72     PyMoreInit.append( '        DoLoop = 1   ' )
73     PyMoreInit.append( '    else :   ' )
74     PyMoreInit.append( '        DoLoop = 0   ' )
75     PyMoreInit.append( '    return DoLoop,Index,Min,Max,Incr   ' )
76     PyNextInit = []
77     PyNextInit.append( 'def Next(Index,Min,Max,Incr) :   ' )
78     PyNextInit.append( '    Index = Index + Incr   ' )
79     PyNextInit.append( '    return Index,Min,Max,Incr  ' )
80     Init,EndInit = GraphLoop1.LNode( 'Init' , PyInit , 'More' , PyMoreInit , 'Next' , PyNextInit )
81     EndInit.SetName( 'EndInit' )
82     EndInit.SetAuthor( '' )
83     EndInit.SetComment( 'Compute Node' )
84     EndInit.Coords( 555 , 255 )
85     PyEndInit = []
86     EndInit.SetPyFunction( '' , PyEndInit )
87     IInitDoLoop = Init.GetInPort( 'DoLoop' )
88     IInitIndex = Init.InPort( 'Index' , 'long' )
89     IInitMin = Init.InPort( 'Min' , 'long' )
90     IInitMax = Init.InPort( 'Max' , 'long' )
91     IInitIncr = Init.InPort( 'Incr' , 'long' )
92     IInitGate = Init.GetInPort( 'Gate' )
93     OInitDoLoop = Init.GetOutPort( 'DoLoop' )
94     OInitIndex = Init.GetOutPort( 'Index' )
95     OInitMin = Init.GetOutPort( 'Min' )
96     OInitMax = Init.GetOutPort( 'Max' )
97     OInitIncr = Init.GetOutPort( 'Incr' )
98     IEndInitDoLoop = EndInit.GetInPort( 'DoLoop' )
99     IEndInitIndex = EndInit.GetInPort( 'Index' )
100     IEndInitMin = EndInit.GetInPort( 'Min' )
101     IEndInitMax = EndInit.GetInPort( 'Max' )
102     IEndInitIncr = EndInit.GetInPort( 'Incr' )
103     IEndInitGate = EndInit.GetInPort( 'Gate' )
104     OEndInitDoLoop = EndInit.GetOutPort( 'DoLoop' )
105     OEndInitIndex = EndInit.GetOutPort( 'Index' )
106     OEndInitMin = EndInit.GetOutPort( 'Min' )
107     OEndInitMax = EndInit.GetOutPort( 'Max' )
108     OEndInitIncr = EndInit.GetOutPort( 'Incr' )
109     OEndInitGate = EndInit.GetOutPort( 'Gate' )
110     Init.SetName( 'Init' )
111     Init.SetAuthor( '' )
112     Init.SetComment( 'Compute Node' )
113     Init.Coords( 17 , 257 )
114     
115     # Creation of Links
116     LInitIndexNodeIndexIndex = GraphLoop1.Link( OInitIndex , INodeIndexIndex )
117     
118     LInitMinEndInitMin = GraphLoop1.Link( OInitMin , IEndInitMin )
119     
120     LInitMaxEndInitMax = GraphLoop1.Link( OInitMax , IEndInitMax )
121     
122     LInitIncrNodeIncrIncr = GraphLoop1.Link( OInitIncr , INodeIncrIncr )
123     
124     LNodeIndexIndexEndInitIndex = GraphLoop1.Link( ONodeIndexIndex , IEndInitIndex )
125     
126     LNodeIncrIncrEndInitIncr = GraphLoop1.Link( ONodeIncrIncr , IEndInitIncr )
127     
128     # Input datas
129     IInitIndex.Input( 0 )
130     IInitMin.Input( 5 )
131     IInitMax.Input( 10 )
132     IInitIncr.Input( 1 )
133     
134     # Output Ports of the graph
135     #OEndInitIndex = EndInit.GetOutPort( 'Index' )
136     #OEndInitMin = EndInit.GetOutPort( 'Min' )
137     #OEndInitMax = EndInit.GetOutPort( 'Max' )
138     #OEndInitIncr = EndInit.GetOutPort( 'Incr' )
139     return GraphLoop1
140
141
142 GraphLoop1 = DefGraphLoop1()