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