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