Salome HOME
Merge from BR_V5_DEV 17Feb09
[samples/datafiles.git] / Superv / Python / GraphSwitchManyCases.py
1 #  Copyright (C) 2007-2008  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 GraphSwitchManyCases
23 #
24 from SuperV import *
25
26 # Graph creation of GraphSwitchManyCases
27 def DefGraphSwitchManyCases() :
28     GraphSwitchManyCases = Graph( 'GraphSwitchManyCases' )
29     GraphSwitchManyCases.SetName( 'GraphSwitchManyCases' )
30     GraphSwitchManyCases.SetAuthor( 'JR' )
31     GraphSwitchManyCases.SetComment( '' )
32     GraphSwitchManyCases.Coords( 0 , 0 )
33     
34     # Creation of Factory Nodes
35     
36     # Creation of InLine Nodes
37     PyCase1 = []
38     PyCase1.append( 'from time import *  ' )
39     PyCase1.append( 'def Case1(a) :  ' )
40     PyCase1.append( '    sleep(1)  ' )
41     PyCase1.append( '    return a ' )
42     Case1 = GraphSwitchManyCases.INode( 'Case1' , PyCase1 )
43     Case1.SetName( 'Case1' )
44     Case1.SetAuthor( '' )
45     Case1.SetComment( 'Compute Node' )
46     Case1.Coords( 448 , 13 )
47     ICase1a = Case1.InPort( 'a' , 'long' )
48     ICase1Gate = Case1.GetInPort( 'Gate' )
49     OCase1a = Case1.OutPort( 'a' , 'long' )
50     OCase1Gate = Case1.GetOutPort( 'Gate' )
51     
52     PyCase3 = []
53     PyCase3.append( 'from time import *  ' )
54     PyCase3.append( 'def Case3(b) :  ' )
55     PyCase3.append( '    sleep(1)  ' )
56     PyCase3.append( '    return b  ' )
57     Case3 = GraphSwitchManyCases.INode( 'Case3' , PyCase3 )
58     Case3.SetName( 'Case3' )
59     Case3.SetAuthor( '' )
60     Case3.SetComment( 'Compute Node' )
61     Case3.Coords( 458 , 286 )
62     ICase3b = Case3.InPort( 'b' , 'long' )
63     ICase3Gate = Case3.GetInPort( 'Gate' )
64     OCase3b = Case3.OutPort( 'b' , 'long' )
65     OCase3Gate = Case3.GetOutPort( 'Gate' )
66     
67     PyCase4 = []
68     PyCase4.append( 'from time import *  ' )
69     PyCase4.append( 'def Case4(c) :  ' )
70     PyCase4.append( '    sleep(1)  ' )
71     PyCase4.append( '    return   ' )
72     Case4 = GraphSwitchManyCases.INode( 'Case4' , PyCase4 )
73     Case4.SetName( 'Case4' )
74     Case4.SetAuthor( '' )
75     Case4.SetComment( 'Compute Node' )
76     Case4.Coords( 459 , 493 )
77     ICase4c = Case4.InPort( 'c' , 'long' )
78     ICase4Gate = Case4.GetInPort( 'Gate' )
79     OCase4Gate = Case4.GetOutPort( 'Gate' )
80     
81     PyCase2a = []
82     PyCase2a.append( 'from time import *  ' )
83     PyCase2a.append( 'def Case2a(a) :  ' )
84     PyCase2a.append( '    sleep(1)  ' )
85     PyCase2a.append( '    return a  ' )
86     Case2a = GraphSwitchManyCases.INode( 'Case2a' , PyCase2a )
87     Case2a.SetName( 'Case2a' )
88     Case2a.SetAuthor( '' )
89     Case2a.SetComment( 'Compute Node' )
90     Case2a.Coords( 453 , 154 )
91     ICase2aa = Case2a.InPort( 'a' , 'long' )
92     ICase2aGate = Case2a.GetInPort( 'Gate' )
93     OCase2aa = Case2a.OutPort( 'a' , 'long' )
94     OCase2aGate = Case2a.GetOutPort( 'Gate' )
95     
96     # Creation of Loop Nodes
97     PyLoop = []
98     PyLoop.append( 'def Init(Index,Max,Min) : ' )
99     PyLoop.append( '    Index = Max ' )
100     PyLoop.append( '    return Index,Max,Min ' )
101     PyMoreLoop = []
102     PyMoreLoop.append( 'def More(Index,Max,Min) : ' )
103     PyMoreLoop.append( '    if Index >= Min : ' )
104     PyMoreLoop.append( '        DoLoop = 1 ' )
105     PyMoreLoop.append( '    else : ' )
106     PyMoreLoop.append( '        DoLoop = 0 ' )
107     PyMoreLoop.append( '    return DoLoop,Index,Max,Min ' )
108     PyNextLoop = []
109     PyNextLoop.append( 'def Next(Index,Max,Min) : ' )
110     PyNextLoop.append( '    Index = Index - 1 ' )
111     PyNextLoop.append( '    return Index,Max,Min ' )
112     Loop,EndLoop = GraphSwitchManyCases.LNode( 'Init' , PyLoop , 'More' , PyMoreLoop , 'Next' , PyNextLoop )
113     EndLoop.SetName( 'EndLoop' )
114     EndLoop.SetAuthor( '' )
115     EndLoop.SetComment( 'Compute Node' )
116     EndLoop.Coords( 972 , 344 )
117     PyEndLoop = []
118     EndLoop.SetPyFunction( 'EndLoop' , PyEndLoop )
119     ILoopDoLoop = Loop.GetInPort( 'DoLoop' )
120     ILoopIndex = Loop.InPort( 'Index' , 'long' )
121     ILoopMax = Loop.InPort( 'Max' , 'long' )
122     ILoopMin = Loop.InPort( 'Min' , 'long' )
123     ILoopGate = Loop.GetInPort( 'Gate' )
124     OLoopDoLoop = Loop.GetOutPort( 'DoLoop' )
125     OLoopIndex = Loop.GetOutPort( 'Index' )
126     OLoopMax = Loop.GetOutPort( 'Max' )
127     OLoopMin = Loop.GetOutPort( 'Min' )
128     IEndLoopDoLoop = EndLoop.GetInPort( 'DoLoop' )
129     IEndLoopIndex = EndLoop.GetInPort( 'Index' )
130     IEndLoopMax = EndLoop.GetInPort( 'Max' )
131     IEndLoopMin = EndLoop.GetInPort( 'Min' )
132     IEndLoopGate = EndLoop.GetInPort( 'Gate' )
133     OEndLoopDoLoop = EndLoop.GetOutPort( 'DoLoop' )
134     OEndLoopIndex = EndLoop.GetOutPort( 'Index' )
135     OEndLoopMax = EndLoop.GetOutPort( 'Max' )
136     OEndLoopMin = EndLoop.GetOutPort( 'Min' )
137     OEndLoopGate = EndLoop.GetOutPort( 'Gate' )
138     Loop.SetName( 'Loop' )
139     Loop.SetAuthor( '' )
140     Loop.SetComment( 'Compute Node' )
141     Loop.Coords( 15 , 336 )
142     
143     # Creation of Switch Nodes
144     PySwitch = []
145     PySwitch.append( 'from time import *    ' )
146     PySwitch.append( 'def Switch(Index) :    ' )
147     PySwitch.append( '    sleep(1)   ' )
148     PySwitch.append( '    SB1 = 0   ' )
149     PySwitch.append( '    SB2 = 0   ' )
150     PySwitch.append( '    if (Index & 3) == 3 :     ' )
151     PySwitch.append( '        SB1 = 1   ' )
152     PySwitch.append( '    elif (Index & 3) == 0 :     ' )
153     PySwitch.append( '        SB2 = 1   ' )
154     PySwitch.append( '    return SB1,SB2,Index,Index+1,Index+2,Index+3,Index+4,Index+5     ' )
155     Switch,EndSwitch = GraphSwitchManyCases.SNode( 'Switch' , PySwitch )
156     EndSwitch.SetName( 'EndSwitch' )
157     EndSwitch.SetAuthor( '' )
158     EndSwitch.SetComment( 'Compute Node' )
159     EndSwitch.Coords( 732 , 344 )
160     PyEndSwitch = []
161     PyEndSwitch.append( 'from time import *   ' )
162     PyEndSwitch.append( 'def EndSwitch(a,b,dd,e,f) :   ' )
163     PyEndSwitch.append( '    sleep(1)   ' )
164     PyEndSwitch.append( '    if b != (a+1) :  ' )
165     PyEndSwitch.append( '        print 'EndSwitch ERROR' ' )
166     PyEndSwitch.append( '        pass  ' )
167     PyEndSwitch.append( '    if dd != (a+3) :  ' )
168     PyEndSwitch.append( '        print 'EndSwitch ERROR' ' )
169     PyEndSwitch.append( '        pass  ' )
170     PyEndSwitch.append( '    if e != (a+4) :  ' )
171     PyEndSwitch.append( '        print 'EndSwitch ERROR' ' )
172     PyEndSwitch.append( '        pass  ' )
173     PyEndSwitch.append( '    if f != (a+5) :  ' )
174     PyEndSwitch.append( '        print 'EndSwitch ERROR' ' )
175     PyEndSwitch.append( '        pass  ' )
176     PyEndSwitch.append( '    return a    ' )
177     EndSwitch.SetPyFunction( 'EndSwitch' , PyEndSwitch )
178     IEndSwitcha = EndSwitch.InPort( 'a' , 'long' )
179     IEndSwitchb = EndSwitch.InPort( 'b' , 'long' )
180     IEndSwitchdd = EndSwitch.InPort( 'dd' , 'long' )
181     IEndSwitche = EndSwitch.InPort( 'e' , 'long' )
182     IEndSwitchf = EndSwitch.InPort( 'f' , 'long' )
183     IEndSwitchDefault = EndSwitch.GetInPort( 'Default' )
184     OEndSwitchIndex = EndSwitch.OutPort( 'Index' , 'long' )
185     OEndSwitchGate = EndSwitch.GetOutPort( 'Gate' )
186     Switch.SetName( 'Switch' )
187     Switch.SetAuthor( '' )
188     Switch.SetComment( 'Compute Node' )
189     Switch.Coords( 232 , 285 )
190     ISwitchIndex = Switch.InPort( 'Index' , 'long' )
191     ISwitchGate = Switch.GetInPort( 'Gate' )
192     OSwitchSB1 = Switch.OutPort( 'SB1' , 'long' )
193     OSwitchSB2 = Switch.OutPort( 'SB2' , 'long' )
194     OSwitcha = Switch.OutPort( 'a' , 'long' )
195     OSwitchb = Switch.OutPort( 'b' , 'long' )
196     OSwitchc = Switch.OutPort( 'c' , 'long' )
197     OSwitchd = Switch.OutPort( 'd' , 'long' )
198     OSwitche = Switch.OutPort( 'e' , 'long' )
199     OSwitchf = Switch.OutPort( 'f' , 'long' )
200     OSwitchDefault = Switch.GetOutPort( 'Default' )
201     
202     # Creation of Links
203     LLoopIndexSwitchIndex = GraphSwitchManyCases.Link( OLoopIndex , ISwitchIndex )
204     
205     LLoopMaxEndLoopMax = GraphSwitchManyCases.Link( OLoopMax , IEndLoopMax )
206     
207     LLoopMinEndLoopMin = GraphSwitchManyCases.Link( OLoopMin , IEndLoopMin )
208     
209     LSwitchSB1Case1Gate = GraphSwitchManyCases.Link( OSwitchSB1 , ICase1Gate )
210     
211     LSwitchSB2Case2aGate = GraphSwitchManyCases.Link( OSwitchSB2 , ICase2aGate )
212     
213     LSwitchaCase1a = GraphSwitchManyCases.Link( OSwitcha , ICase1a )
214     
215     LSwitchaCase2aa = GraphSwitchManyCases.Link( OSwitcha , ICase2aa )
216     
217     LSwitchbCase3b = GraphSwitchManyCases.Link( OSwitchb , ICase3b )
218     
219     LSwitchcCase4c = GraphSwitchManyCases.Link( OSwitchc , ICase4c )
220     
221     LSwitchdEndSwitchdd = GraphSwitchManyCases.Link( OSwitchd , IEndSwitchdd )
222     
223     LSwitcheEndSwitche = GraphSwitchManyCases.Link( OSwitche , IEndSwitche )
224     
225     LSwitchDefaultEndSwitchDefault = GraphSwitchManyCases.Link( OSwitchDefault , IEndSwitchDefault )
226     
227     LEndSwitchIndexEndLoopIndex = GraphSwitchManyCases.Link( OEndSwitchIndex , IEndLoopIndex )
228     
229     LCase1aEndSwitcha = GraphSwitchManyCases.Link( OCase1a , IEndSwitcha )
230     
231     LCase3bEndSwitchb = GraphSwitchManyCases.Link( OCase3b , IEndSwitchb )
232     
233     LCase4GateEndSwitchDefault = GraphSwitchManyCases.Link( OCase4Gate , IEndSwitchDefault )
234     
235     LCase2aaEndSwitcha = GraphSwitchManyCases.Link( OCase2aa , IEndSwitcha )
236     
237     # Input datas
238     ILoopIndex.Input( 0 )
239     ILoopMax.Input( 23 )
240     ILoopMin.Input( -7 )
241     
242     # Input Ports of the graph
243     #IEndSwitchf = EndSwitch.GetInPort( 'f' )
244     
245     # Output Ports of the graph
246     #OEndLoopIndex = EndLoop.GetOutPort( 'Index' )
247     #OEndLoopMax = EndLoop.GetOutPort( 'Max' )
248     #OEndLoopMin = EndLoop.GetOutPort( 'Min' )
249     #OSwitchf = Switch.GetOutPort( 'f' )
250     return GraphSwitchManyCases
251
252
253 GraphSwitchManyCases = DefGraphSwitchManyCases()