Salome HOME
7aeb204bce985ae0ecc112977ac31d0b561fbc2b
[samples/datafiles.git] / Superv / Python / GraphSwitchCheckDefault1.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 GraphSwitchCheckDefault1
24 #
25 from SuperV import *
26
27 # Graph creation of GraphSwitchCheckDefault1
28 def DefGraphSwitchCheckDefault1() :
29     GraphSwitchCheckDefault1 = Graph( 'GraphSwitchCheckDefault1' )
30     GraphSwitchCheckDefault1.SetName( 'GraphSwitchCheckDefault1' )
31     GraphSwitchCheckDefault1.SetAuthor( 'JR' )
32     GraphSwitchCheckDefault1.SetComment( '' )
33     GraphSwitchCheckDefault1.Coords( 0 , 0 )
34     
35     # Creation of Factory Nodes
36     
37     # Creation of InLine Nodes
38     PyIsOdd = []
39     PyIsOdd.append( 'from time import *   ' )
40     PyIsOdd.append( 'def IsOdd(a) :       ' )
41     PyIsOdd.append( '    print a,"IsOdd (GraphSwitch)"      ' )
42     PyIsOdd.append( '    sleep( 1 )   ' )
43     PyIsOdd.append( '    return a     ' )
44     IsOdd = GraphSwitchCheckDefault1.INode( 'IsOdd' , PyIsOdd )
45     IsOdd.SetName( 'IsOdd' )
46     IsOdd.SetAuthor( '' )
47     IsOdd.SetComment( 'Python function' )
48     IsOdd.Coords( 415 , 7 )
49     IIsOdda = IsOdd.InPort( 'a' , 'long' )
50     IIsOddGate = IsOdd.GetInPort( 'Gate' )
51     OIsOdda = IsOdd.OutPort( 'a' , 'long' )
52     OIsOddGate = IsOdd.GetOutPort( 'Gate' )
53     
54     PyIsEven = []
55     PyIsEven.append( 'from time import *    ' )
56     PyIsEven.append( 'def IsEven(a) :        ' )
57     PyIsEven.append( '    print a,"IsEven (GraphSwitch)"       ' )
58     PyIsEven.append( '    sleep( 1 )    ' )
59     PyIsEven.append( '    return a      ' )
60     IsEven = GraphSwitchCheckDefault1.INode( 'IsEven' , PyIsEven )
61     IsEven.SetName( 'IsEven' )
62     IsEven.SetAuthor( '' )
63     IsEven.SetComment( 'Compute Node' )
64     IsEven.Coords( 421 , 438 )
65     IIsEvena = IsEven.InPort( 'a' , 'long' )
66     IIsEvenGate = IsEven.GetInPort( 'Gate' )
67     OIsEvena = IsEven.OutPort( 'a' , 'long' )
68     OIsEvenGate = IsEven.GetOutPort( 'Gate' )
69     
70     PyPrintOdd = []
71     PyPrintOdd.append( 'from time import * ' )
72     PyPrintOdd.append( 'def Print(a,Branch) :     ' )
73     PyPrintOdd.append( '    print "Print ",a,Branch ' )
74     PyPrintOdd.append( '    sleep(1) ' )
75     PyPrintOdd.append( '    return Branch     ' )
76     PrintOdd = GraphSwitchCheckDefault1.INode( 'Print' , PyPrintOdd )
77     PrintOdd.SetName( 'PrintOdd' )
78     PrintOdd.SetAuthor( '' )
79     PrintOdd.SetComment( 'Compute Node' )
80     PrintOdd.Coords( 415 , 130 )
81     IPrintOdda = PrintOdd.InPort( 'a' , 'long' )
82     IPrintOddBranch = PrintOdd.InPort( 'Branch' , 'string' )
83     IPrintOddGate = PrintOdd.GetInPort( 'Gate' )
84     OPrintOddBranch = PrintOdd.OutPort( 'Branch' , 'string' )
85     OPrintOddGate = PrintOdd.GetOutPort( 'Gate' )
86     
87     PyPrintEven = []
88     PyPrintEven.append( 'from time import * ' )
89     PyPrintEven.append( 'def Print_1(a,Branch) :     ' )
90     PyPrintEven.append( '    print "Print ",a,Branch ' )
91     PyPrintEven.append( '    sleep(1) ' )
92     PyPrintEven.append( '    return Branch     ' )
93     PrintEven = GraphSwitchCheckDefault1.INode( 'Print_1' , PyPrintEven )
94     PrintEven.SetName( 'PrintEven' )
95     PrintEven.SetAuthor( '' )
96     PrintEven.SetComment( 'Compute Node' )
97     PrintEven.Coords( 423 , 289 )
98     IPrintEvena = PrintEven.InPort( 'a' , 'long' )
99     IPrintEvenBranch = PrintEven.InPort( 'Branch' , 'string' )
100     IPrintEvenGate = PrintEven.GetInPort( 'Gate' )
101     OPrintEvenBranch = PrintEven.OutPort( 'Branch' , 'string' )
102     OPrintEvenGate = PrintEven.GetOutPort( 'Gate' )
103     
104     PyEmptyNode = []
105     PyEmptyNode.append( 'from time import * ' )
106     PyEmptyNode.append( 'def EmptyNode(a,Branch) : ' )
107     PyEmptyNode.append( '    sleep(1) ' )
108     PyEmptyNode.append( '    return a,Branch  ' )
109     EmptyNode = GraphSwitchCheckDefault1.INode( 'EmptyNode' , PyEmptyNode )
110     EmptyNode.SetName( 'EmptyNode' )
111     EmptyNode.SetAuthor( '' )
112     EmptyNode.SetComment( 'Compute Node' )
113     EmptyNode.Coords( 652 , 110 )
114     IEmptyNodea = EmptyNode.InPort( 'a' , 'long' )
115     IEmptyNodeBranch = EmptyNode.InPort( 'Branch' , 'string' )
116     IEmptyNodeGate = EmptyNode.GetInPort( 'Gate' )
117     OEmptyNodea = EmptyNode.OutPort( 'a' , 'long' )
118     OEmptyNodeBranch = EmptyNode.OutPort( 'Branch' , 'string' )
119     OEmptyNodeGate = EmptyNode.GetOutPort( 'Gate' )
120     
121     PyDefault = []
122     PyDefault.append( 'from time import * ' )
123     PyDefault.append( 'def Default(a,Branch) : ' )
124     PyDefault.append( '    sleep(1) ' )
125     PyDefault.append( '    return a,Branch ' )
126     Default = GraphSwitchCheckDefault1.INode( 'Default' , PyDefault )
127     Default.SetName( 'Default' )
128     Default.SetAuthor( '' )
129     Default.SetComment( 'Compute Node' )
130     Default.Coords( 421 , 592 )
131     IDefaulta = Default.InPort( 'a' , 'long' )
132     IDefaultBranch = Default.InPort( 'Branch' , 'string' )
133     IDefaultGate = Default.GetInPort( 'Gate' )
134     ODefaulta = Default.OutPort( 'a' , 'long' )
135     ODefaultBranch = Default.OutPort( 'Branch' , 'string' )
136     ODefaultGate = Default.GetOutPort( 'Gate' )
137     
138     # Creation of Loop Nodes
139     PyInitLoopSwitch = []
140     PyInitLoopSwitch.append( 'def InitLoop(Index,Min,Max) :        ' )
141     PyInitLoopSwitch.append( '  Index = Max  ' )
142     PyInitLoopSwitch.append( '  return Index,Min,Max       ' )
143     PyMoreInitLoopSwitch = []
144     PyMoreInitLoopSwitch.append( 'from time import * ' )
145     PyMoreInitLoopSwitch.append( 'def MoreLoop(Index,Min,Max) : ' )
146     PyMoreInitLoopSwitch.append( '      sleep(1)  ' )
147     PyMoreInitLoopSwitch.append( '      if Index >= Min :     ' )
148     PyMoreInitLoopSwitch.append( '              DoLoop = 1       ' )
149     PyMoreInitLoopSwitch.append( '      else :       ' )
150     PyMoreInitLoopSwitch.append( '              DoLoop = 0       ' )
151     PyMoreInitLoopSwitch.append( '      return DoLoop,Index,Min,Max       ' )
152     PyNextInitLoopSwitch = []
153     PyNextInitLoopSwitch.append( 'def NextLoop(Index,Min,Max) :       ' )
154     PyNextInitLoopSwitch.append( '      Index = Index - 1       ' )
155     PyNextInitLoopSwitch.append( '      return Index,Min,Max       ' )
156     InitLoopSwitch,EndOfInitLoopSwitch = GraphSwitchCheckDefault1.LNode( 'InitLoop' , PyInitLoopSwitch , 'MoreLoop' , PyMoreInitLoopSwitch , 'NextLoop' , PyNextInitLoopSwitch )
157     EndOfInitLoopSwitch.SetName( 'EndOfInitLoopSwitch' )
158     EndOfInitLoopSwitch.SetAuthor( '' )
159     EndOfInitLoopSwitch.SetComment( 'Compute Node' )
160     EndOfInitLoopSwitch.Coords( 1074 , 194 )
161     PyEndOfInitLoopSwitch = []
162     PyEndOfInitLoopSwitch.append( 'from time import *  ' )
163     PyEndOfInitLoopSwitch.append( 'def EndOfInitLoopSwitch(DoLoop,Index,Min,Max) :  ' )
164     PyEndOfInitLoopSwitch.append( '    sleep(1)  ' )
165     PyEndOfInitLoopSwitch.append( '    return DoLoop,Index,Min,Max  ' )
166     EndOfInitLoopSwitch.SetPyFunction( 'EndOfInitLoopSwitch' , PyEndOfInitLoopSwitch )
167     IInitLoopSwitchDoLoop = InitLoopSwitch.GetInPort( 'DoLoop' )
168     IInitLoopSwitchIndex = InitLoopSwitch.InPort( 'Index' , 'long' )
169     IInitLoopSwitchMin = InitLoopSwitch.InPort( 'Min' , 'long' )
170     IInitLoopSwitchMax = InitLoopSwitch.InPort( 'Max' , 'long' )
171     IInitLoopSwitchGate = InitLoopSwitch.GetInPort( 'Gate' )
172     OInitLoopSwitchDoLoop = InitLoopSwitch.GetOutPort( 'DoLoop' )
173     OInitLoopSwitchIndex = InitLoopSwitch.GetOutPort( 'Index' )
174     OInitLoopSwitchMin = InitLoopSwitch.GetOutPort( 'Min' )
175     OInitLoopSwitchMax = InitLoopSwitch.GetOutPort( 'Max' )
176     IEndOfInitLoopSwitchDoLoop = EndOfInitLoopSwitch.GetInPort( 'DoLoop' )
177     IEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetInPort( 'Index' )
178     IEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetInPort( 'Min' )
179     IEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetInPort( 'Max' )
180     IEndOfInitLoopSwitchGate = EndOfInitLoopSwitch.GetInPort( 'Gate' )
181     OEndOfInitLoopSwitchDoLoop = EndOfInitLoopSwitch.GetOutPort( 'DoLoop' )
182     OEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetOutPort( 'Index' )
183     OEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetOutPort( 'Min' )
184     OEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetOutPort( 'Max' )
185     OEndOfInitLoopSwitchGate = EndOfInitLoopSwitch.GetOutPort( 'Gate' )
186     InitLoopSwitch.SetName( 'InitLoopSwitch' )
187     InitLoopSwitch.SetAuthor( '' )
188     InitLoopSwitch.SetComment( 'Compute Node' )
189     InitLoopSwitch.Coords( 10 , 129 )
190     
191     # Creation of Switch Nodes
192     PySwitch = []
193     PySwitch.append( 'from time import *        ' )
194     PySwitch.append( 'def Switch(a) : ' )
195     PySwitch.append( '    sleep(1) ' )
196     PySwitch.append( '    Branch = "Negative or null"    ' )
197     PySwitch.append( '    if a <= 0 :       ' )
198     PySwitch.append( '        return 0,0,a,Branch,1  ' )
199     PySwitch.append( '    if ( a & 1 ) == 0 :    ' )
200     PySwitch.append( '        Branch = "Even"    ' )
201     PySwitch.append( '    else :    ' )
202     PySwitch.append( '        Branch = "Odd"    ' )
203     PySwitch.append( '    return a & 1,1-(a&1),a,Branch,0  ' )
204     Switch,EndOfSwitch = GraphSwitchCheckDefault1.SNode( 'Switch' , PySwitch )
205     EndOfSwitch.SetName( 'EndOfSwitch' )
206     EndOfSwitch.SetAuthor( '' )
207     EndOfSwitch.SetComment( 'Compute Node' )
208     EndOfSwitch.Coords( 882 , 194 )
209     PyEndOfSwitch = []
210     PyEndOfSwitch.append( 'from time import * ' )
211     PyEndOfSwitch.append( 'def EndOfSwitch(a,Branch) : ' )
212     PyEndOfSwitch.append( '    sleep(1) ' )
213     PyEndOfSwitch.append( '    return a ' )
214     EndOfSwitch.SetPyFunction( 'EndOfSwitch' , PyEndOfSwitch )
215     IEndOfSwitcha = EndOfSwitch.InPort( 'a' , 'long' )
216     IEndOfSwitchBranch = EndOfSwitch.InPort( 'Branch' , 'string' )
217     IEndOfSwitchDefault = EndOfSwitch.GetInPort( 'Default' )
218     OEndOfSwitcha = EndOfSwitch.OutPort( 'a' , 'long' )
219     OEndOfSwitchGate = EndOfSwitch.GetOutPort( 'Gate' )
220     Switch.SetName( 'Switch' )
221     Switch.SetAuthor( '' )
222     Switch.SetComment( 'Compute Node' )
223     Switch.Coords( 190 , 129 )
224     ISwitcha = Switch.InPort( 'a' , 'long' )
225     ISwitchGate = Switch.GetInPort( 'Gate' )
226     OSwitchOdd = Switch.OutPort( 'Odd' , 'long' )
227     OSwitchEven = Switch.OutPort( 'Even' , 'int' )
228     OSwitcha = Switch.OutPort( 'a' , 'int' )
229     OSwitchBranch = Switch.OutPort( 'Branch' , 'string' )
230     OSwitchdefault = Switch.OutPort( 'default' , 'boolean' )
231     OSwitchDefault = Switch.GetOutPort( 'Default' )
232     
233     # Creation of Links
234     LIsOddaEmptyNodea = GraphSwitchCheckDefault1.Link( OIsOdda , IEmptyNodea )
235     LIsOddaEmptyNodea.AddCoord( 1 , 646 , 78 )
236     
237     LIsEvenaEndOfSwitcha = GraphSwitchCheckDefault1.Link( OIsEvena , IEndOfSwitcha )
238     
239     LPrintOddBranchEmptyNodeBranch = GraphSwitchCheckDefault1.Link( OPrintOddBranch , IEmptyNodeBranch )
240     
241     LPrintEvenBranchEndOfSwitchBranch = GraphSwitchCheckDefault1.Link( OPrintEvenBranch , IEndOfSwitchBranch )
242     
243     LEmptyNodeaEndOfSwitcha = GraphSwitchCheckDefault1.Link( OEmptyNodea , IEndOfSwitcha )
244     
245     LEmptyNodeBranchEndOfSwitchBranch = GraphSwitchCheckDefault1.Link( OEmptyNodeBranch , IEndOfSwitchBranch )
246     
247     LDefaultaEndOfSwitcha = GraphSwitchCheckDefault1.Link( ODefaulta , IEndOfSwitcha )
248     
249     LDefaultBranchEndOfSwitchBranch = GraphSwitchCheckDefault1.Link( ODefaultBranch , IEndOfSwitchBranch )
250     
251     LInitLoopSwitchIndexSwitcha = GraphSwitchCheckDefault1.Link( OInitLoopSwitchIndex , ISwitcha )
252     
253     LInitLoopSwitchMinEndOfInitLoopSwitchMin = GraphSwitchCheckDefault1.Link( OInitLoopSwitchMin , IEndOfInitLoopSwitchMin )
254     
255     LInitLoopSwitchMaxEndOfInitLoopSwitchMax = GraphSwitchCheckDefault1.Link( OInitLoopSwitchMax , IEndOfInitLoopSwitchMax )
256     
257     LSwitchOddIsOddGate = GraphSwitchCheckDefault1.Link( OSwitchOdd , IIsOddGate )
258     LSwitchOddIsOddGate.AddCoord( 1 , 401 , 101 )
259     LSwitchOddIsOddGate.AddCoord( 2 , 401 , 160 )
260     
261     LSwitchOddPrintOddGate = GraphSwitchCheckDefault1.Link( OSwitchOdd , IPrintOddGate )
262     LSwitchOddPrintOddGate.AddCoord( 1 , 401 , 245 )
263     LSwitchOddPrintOddGate.AddCoord( 2 , 401 , 159 )
264     
265     LSwitchEvenIsEvenGate = GraphSwitchCheckDefault1.Link( OSwitchEven , IIsEvenGate )
266     LSwitchEvenIsEvenGate.AddCoord( 1 , 392 , 533 )
267     LSwitchEvenIsEvenGate.AddCoord( 2 , 392 , 182 )
268     
269     LSwitchEvenPrintEvenGate = GraphSwitchCheckDefault1.Link( OSwitchEven , IPrintEvenGate )
270     LSwitchEvenPrintEvenGate.AddCoord( 1 , 392 , 403 )
271     LSwitchEvenPrintEvenGate.AddCoord( 2 , 392 , 181 )
272     
273     LSwitchaIsOdda = GraphSwitchCheckDefault1.Link( OSwitcha , IIsOdda )
274     LSwitchaIsOdda.AddCoord( 1 , 382 , 78 )
275     LSwitchaIsOdda.AddCoord( 2 , 382 , 199 )
276     
277     LSwitchaIsEvena = GraphSwitchCheckDefault1.Link( OSwitcha , IIsEvena )
278     LSwitchaIsEvena.AddCoord( 1 , 381 , 509 )
279     LSwitchaIsEvena.AddCoord( 2 , 382 , 200 )
280     
281     LSwitchaPrintOdda = GraphSwitchCheckDefault1.Link( OSwitcha , IPrintOdda )
282     
283     LSwitchaPrintEvena = GraphSwitchCheckDefault1.Link( OSwitcha , IPrintEvena )
284     LSwitchaPrintEvena.AddCoord( 1 , 381 , 361 )
285     LSwitchaPrintEvena.AddCoord( 2 , 382 , 200 )
286     
287     LSwitchaDefaulta = GraphSwitchCheckDefault1.Link( OSwitcha , IDefaulta )
288     LSwitchaDefaulta.AddCoord( 1 , 382 , 663 )
289     LSwitchaDefaulta.AddCoord( 2 , 382 , 199 )
290     
291     LSwitchBranchPrintOddBranch = GraphSwitchCheckDefault1.Link( OSwitchBranch , IPrintOddBranch )
292     
293     LSwitchBranchPrintEvenBranch = GraphSwitchCheckDefault1.Link( OSwitchBranch , IPrintEvenBranch )
294     LSwitchBranchPrintEvenBranch.AddCoord( 1 , 369 , 381 )
295     LSwitchBranchPrintEvenBranch.AddCoord( 2 , 369 , 219 )
296     
297     LSwitchBranchDefaultBranch = GraphSwitchCheckDefault1.Link( OSwitchBranch , IDefaultBranch )
298     LSwitchBranchDefaultBranch.AddCoord( 1 , 370 , 683 )
299     LSwitchBranchDefaultBranch.AddCoord( 2 , 370 , 220 )
300     
301     LSwitchdefaultDefaultGate = GraphSwitchCheckDefault1.Link( OSwitchdefault , IDefaultGate )
302     LSwitchdefaultDefaultGate.AddCoord( 1 , 363 , 707 )
303     LSwitchdefaultDefaultGate.AddCoord( 2 , 362 , 239 )
304     
305     LSwitchDefaultEndOfSwitchDefault = GraphSwitchCheckDefault1.Link( OSwitchDefault , IEndOfSwitchDefault )
306     
307     LEndOfSwitchaEndOfInitLoopSwitchIndex = GraphSwitchCheckDefault1.Link( OEndOfSwitcha , IEndOfInitLoopSwitchIndex )
308     
309     # Input datas
310     IInitLoopSwitchIndex.Input( 0 )
311     IInitLoopSwitchMin.Input( -5 )
312     IInitLoopSwitchMax.Input( 10 )
313     
314     # Output Ports of the graph
315     #OEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetOutPort( 'Index' )
316     #OEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetOutPort( 'Min' )
317     #OEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetOutPort( 'Max' )
318     return GraphSwitchCheckDefault1
319
320
321 GraphSwitchCheckDefault1 = DefGraphSwitchCheckDefault1()