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