Salome HOME
Copyrights update 2015.
[samples/datafiles.git] / Superv / Python / GraphSwitchCheckDefault.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 GraphSwitchCheckDefault_1
24 #
25 from SuperV import *
26
27 # Graph creation of GraphSwitchCheckDefault_1
28 def DefGraphSwitchCheckDefault_1() :
29     GraphSwitchCheckDefault_1 = Graph( 'GraphSwitchCheckDefault_1' )
30     GraphSwitchCheckDefault_1.SetName( 'GraphSwitchCheckDefault_1' )
31     GraphSwitchCheckDefault_1.SetAuthor( 'JR' )
32     GraphSwitchCheckDefault_1.SetComment( '' )
33     GraphSwitchCheckDefault_1.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 = GraphSwitchCheckDefault_1.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 = GraphSwitchCheckDefault_1.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 = GraphSwitchCheckDefault_1.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 = GraphSwitchCheckDefault_1.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 = GraphSwitchCheckDefault_1.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     # Creation of Loop Nodes
122     PyInitLoopSwitch = []
123     PyInitLoopSwitch.append( 'def InitLoop(Index,Min,Max) :        ' )
124     PyInitLoopSwitch.append( '  Index = Max  ' )
125     PyInitLoopSwitch.append( '  return Index,Min,Max       ' )
126     PyMoreInitLoopSwitch = []
127     PyMoreInitLoopSwitch.append( 'from time import * ' )
128     PyMoreInitLoopSwitch.append( 'def MoreLoop(Index,Min,Max) : ' )
129     PyMoreInitLoopSwitch.append( '      sleep(1)  ' )
130     PyMoreInitLoopSwitch.append( '      if Index >= Min :     ' )
131     PyMoreInitLoopSwitch.append( '              DoLoop = 1       ' )
132     PyMoreInitLoopSwitch.append( '      else :       ' )
133     PyMoreInitLoopSwitch.append( '              DoLoop = 0       ' )
134     PyMoreInitLoopSwitch.append( '      return DoLoop,Index,Min,Max       ' )
135     PyNextInitLoopSwitch = []
136     PyNextInitLoopSwitch.append( 'def NextLoop(Index,Min,Max) :       ' )
137     PyNextInitLoopSwitch.append( '      Index = Index - 1       ' )
138     PyNextInitLoopSwitch.append( '      return Index,Min,Max       ' )
139     InitLoopSwitch,EndOfInitLoopSwitch = GraphSwitchCheckDefault_1.LNode( 'InitLoop' , PyInitLoopSwitch , 'MoreLoop' , PyMoreInitLoopSwitch , 'NextLoop' , PyNextInitLoopSwitch )
140     EndOfInitLoopSwitch.SetName( 'EndOfInitLoopSwitch' )
141     EndOfInitLoopSwitch.SetAuthor( '' )
142     EndOfInitLoopSwitch.SetComment( 'Compute Node' )
143     EndOfInitLoopSwitch.Coords( 1074 , 194 )
144     PyEndOfInitLoopSwitch = []
145     PyEndOfInitLoopSwitch.append( 'from time import *  ' )
146     PyEndOfInitLoopSwitch.append( 'def EndOfInitLoopSwitch(DoLoop,Index,Min,Max) :  ' )
147     PyEndOfInitLoopSwitch.append( '    sleep(1)  ' )
148     PyEndOfInitLoopSwitch.append( '    return DoLoop,Index,Min,Max  ' )
149     EndOfInitLoopSwitch.SetPyFunction( 'EndOfInitLoopSwitch' , PyEndOfInitLoopSwitch )
150     IInitLoopSwitchDoLoop = InitLoopSwitch.GetInPort( 'DoLoop' )
151     IInitLoopSwitchIndex = InitLoopSwitch.InPort( 'Index' , 'long' )
152     IInitLoopSwitchMin = InitLoopSwitch.InPort( 'Min' , 'long' )
153     IInitLoopSwitchMax = InitLoopSwitch.InPort( 'Max' , 'long' )
154     IInitLoopSwitchGate = InitLoopSwitch.GetInPort( 'Gate' )
155     OInitLoopSwitchDoLoop = InitLoopSwitch.GetOutPort( 'DoLoop' )
156     OInitLoopSwitchIndex = InitLoopSwitch.GetOutPort( 'Index' )
157     OInitLoopSwitchMin = InitLoopSwitch.GetOutPort( 'Min' )
158     OInitLoopSwitchMax = InitLoopSwitch.GetOutPort( 'Max' )
159     IEndOfInitLoopSwitchDoLoop = EndOfInitLoopSwitch.GetInPort( 'DoLoop' )
160     IEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetInPort( 'Index' )
161     IEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetInPort( 'Min' )
162     IEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetInPort( 'Max' )
163     IEndOfInitLoopSwitchGate = EndOfInitLoopSwitch.GetInPort( 'Gate' )
164     OEndOfInitLoopSwitchDoLoop = EndOfInitLoopSwitch.GetOutPort( 'DoLoop' )
165     OEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetOutPort( 'Index' )
166     OEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetOutPort( 'Min' )
167     OEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetOutPort( 'Max' )
168     OEndOfInitLoopSwitchGate = EndOfInitLoopSwitch.GetOutPort( 'Gate' )
169     InitLoopSwitch.SetName( 'InitLoopSwitch' )
170     InitLoopSwitch.SetAuthor( '' )
171     InitLoopSwitch.SetComment( 'Compute Node' )
172     InitLoopSwitch.Coords( 10 , 129 )
173     
174     # Creation of Switch Nodes
175     PySwitch = []
176     PySwitch.append( 'from time import *        ' )
177     PySwitch.append( 'def Switch(a) : ' )
178     PySwitch.append( '    sleep(1) ' )
179     PySwitch.append( '    Branch = "Negative or null"    ' )
180     PySwitch.append( '    if a <= 0 :       ' )
181     PySwitch.append( '        return 0,0,a,Branch,1  ' )
182     PySwitch.append( '    if ( a & 1 ) == 0 :    ' )
183     PySwitch.append( '        Branch = "Even"    ' )
184     PySwitch.append( '    else :    ' )
185     PySwitch.append( '        Branch = "Odd"    ' )
186     PySwitch.append( '    return a & 1,1-(a&1),a,Branch,0  ' )
187     Switch,EndOfSwitch = GraphSwitchCheckDefault_1.SNode( 'Switch' , PySwitch )
188     EndOfSwitch.SetName( 'EndOfSwitch' )
189     EndOfSwitch.SetAuthor( '' )
190     EndOfSwitch.SetComment( 'Compute Node' )
191     EndOfSwitch.Coords( 882 , 194 )
192     PyEndOfSwitch = []
193     PyEndOfSwitch.append( 'from time import * ' )
194     PyEndOfSwitch.append( 'def EndOfSwitch(a,Branch) : ' )
195     PyEndOfSwitch.append( '    sleep(1) ' )
196     PyEndOfSwitch.append( '    return a ' )
197     EndOfSwitch.SetPyFunction( 'EndOfSwitch' , PyEndOfSwitch )
198     IEndOfSwitcha = EndOfSwitch.InPort( 'a' , 'long' )
199     IEndOfSwitchBranch = EndOfSwitch.InPort( 'Branch' , 'string' )
200     IEndOfSwitchDefault = EndOfSwitch.GetInPort( 'Default' )
201     OEndOfSwitcha = EndOfSwitch.OutPort( 'a' , 'long' )
202     OEndOfSwitchGate = EndOfSwitch.GetOutPort( 'Gate' )
203     Switch.SetName( 'Switch' )
204     Switch.SetAuthor( '' )
205     Switch.SetComment( 'Compute Node' )
206     Switch.Coords( 190 , 129 )
207     ISwitcha = Switch.InPort( 'a' , 'long' )
208     ISwitchGate = Switch.GetInPort( 'Gate' )
209     OSwitchOdd = Switch.OutPort( 'Odd' , 'long' )
210     OSwitchEven = Switch.OutPort( 'Even' , 'int' )
211     OSwitcha = Switch.OutPort( 'a' , 'int' )
212     OSwitchBranch = Switch.OutPort( 'Branch' , 'string' )
213     OSwitchdefault = Switch.OutPort( 'default' , 'boolean' )
214     OSwitchDefault = Switch.GetOutPort( 'Default' )
215     
216     # Creation of Links
217     LIsOddaEmptyNodea = GraphSwitchCheckDefault_1.Link( OIsOdda , IEmptyNodea )
218     LIsOddaEmptyNodea.AddCoord( 1 , 646 , 78 )
219     
220     LIsEvenaEndOfSwitcha = GraphSwitchCheckDefault_1.Link( OIsEvena , IEndOfSwitcha )
221     
222     LPrintOddBranchEmptyNodeBranch = GraphSwitchCheckDefault_1.Link( OPrintOddBranch , IEmptyNodeBranch )
223     
224     LPrintEvenBranchEndOfSwitchBranch = GraphSwitchCheckDefault_1.Link( OPrintEvenBranch , IEndOfSwitchBranch )
225     
226     LEmptyNodeaEndOfSwitcha = GraphSwitchCheckDefault_1.Link( OEmptyNodea , IEndOfSwitcha )
227     
228     LEmptyNodeBranchEndOfSwitchBranch = GraphSwitchCheckDefault_1.Link( OEmptyNodeBranch , IEndOfSwitchBranch )
229     
230     LInitLoopSwitchIndexSwitcha = GraphSwitchCheckDefault_1.Link( OInitLoopSwitchIndex , ISwitcha )
231     
232     LInitLoopSwitchMinEndOfInitLoopSwitchMin = GraphSwitchCheckDefault_1.Link( OInitLoopSwitchMin , IEndOfInitLoopSwitchMin )
233     
234     LInitLoopSwitchMaxEndOfInitLoopSwitchMax = GraphSwitchCheckDefault_1.Link( OInitLoopSwitchMax , IEndOfInitLoopSwitchMax )
235     
236     LSwitchOddIsOddGate = GraphSwitchCheckDefault_1.Link( OSwitchOdd , IIsOddGate )
237     LSwitchOddIsOddGate.AddCoord( 1 , 401 , 101 )
238     LSwitchOddIsOddGate.AddCoord( 2 , 401 , 160 )
239     
240     LSwitchOddPrintOddGate = GraphSwitchCheckDefault_1.Link( OSwitchOdd , IPrintOddGate )
241     LSwitchOddPrintOddGate.AddCoord( 1 , 401 , 245 )
242     LSwitchOddPrintOddGate.AddCoord( 2 , 401 , 159 )
243     
244     LSwitchEvenIsEvenGate = GraphSwitchCheckDefault_1.Link( OSwitchEven , IIsEvenGate )
245     LSwitchEvenIsEvenGate.AddCoord( 1 , 392 , 533 )
246     LSwitchEvenIsEvenGate.AddCoord( 2 , 392 , 182 )
247     
248     LSwitchEvenPrintEvenGate = GraphSwitchCheckDefault_1.Link( OSwitchEven , IPrintEvenGate )
249     LSwitchEvenPrintEvenGate.AddCoord( 1 , 392 , 403 )
250     LSwitchEvenPrintEvenGate.AddCoord( 2 , 392 , 181 )
251     
252     LSwitchaIsOdda = GraphSwitchCheckDefault_1.Link( OSwitcha , IIsOdda )
253     LSwitchaIsOdda.AddCoord( 1 , 382 , 78 )
254     LSwitchaIsOdda.AddCoord( 2 , 382 , 199 )
255     
256     LSwitchaIsEvena = GraphSwitchCheckDefault_1.Link( OSwitcha , IIsEvena )
257     LSwitchaIsEvena.AddCoord( 1 , 381 , 509 )
258     LSwitchaIsEvena.AddCoord( 2 , 382 , 200 )
259     
260     LSwitchaPrintOdda = GraphSwitchCheckDefault_1.Link( OSwitcha , IPrintOdda )
261     
262     LSwitchaPrintEvena = GraphSwitchCheckDefault_1.Link( OSwitcha , IPrintEvena )
263     LSwitchaPrintEvena.AddCoord( 1 , 381 , 361 )
264     LSwitchaPrintEvena.AddCoord( 2 , 382 , 200 )
265     
266     LSwitchBranchPrintOddBranch = GraphSwitchCheckDefault_1.Link( OSwitchBranch , IPrintOddBranch )
267     
268     LSwitchBranchPrintEvenBranch = GraphSwitchCheckDefault_1.Link( OSwitchBranch , IPrintEvenBranch )
269     LSwitchBranchPrintEvenBranch.AddCoord( 1 , 369 , 381 )
270     LSwitchBranchPrintEvenBranch.AddCoord( 2 , 369 , 219 )
271     
272     LSwitchDefaultEndOfSwitchDefault = GraphSwitchCheckDefault_1.Link( OSwitchDefault , IEndOfSwitchDefault )
273     
274     LEndOfSwitchaEndOfInitLoopSwitchIndex = GraphSwitchCheckDefault_1.Link( OEndOfSwitcha , IEndOfInitLoopSwitchIndex )
275     
276     # Input datas
277     IInitLoopSwitchIndex.Input( 0 )
278     IInitLoopSwitchMin.Input( -5 )
279     IInitLoopSwitchMax.Input( 10 )
280     
281     # Output Ports of the graph
282     #OEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetOutPort( 'Index' )
283     #OEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetOutPort( 'Min' )
284     #OEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetOutPort( 'Max' )
285     #OSwitchdefault = Switch.GetOutPort( 'default' )
286     return GraphSwitchCheckDefault_1
287
288
289 GraphSwitchCheckDefault_1 = DefGraphSwitchCheckDefault_1()