Salome HOME
Copyrights update 2015.
[samples/datafiles.git] / Superv / Python / GraphSwitchCheckBranch1Default.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 GraphSwitchCheckBranch1Default
24 #
25 from SuperV import *
26
27 # Graph creation of GraphSwitchCheckBranch1Default
28 def DefGraphSwitchCheckBranch1Default() :
29     GraphSwitchCheckBranch1Default = Graph( 'GraphSwitchCheckBranch1Default' )
30     GraphSwitchCheckBranch1Default.SetName( 'GraphSwitchCheckBranch1Default' )
31     GraphSwitchCheckBranch1Default.SetAuthor( 'JR' )
32     GraphSwitchCheckBranch1Default.SetComment( 'Switch with two SwitchBranches, One NotSwitchBranch and the DefaultBranch' )
33     GraphSwitchCheckBranch1Default.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 = GraphSwitchCheckBranch1Default.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 = GraphSwitchCheckBranch1Default.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     PyBranchNode = []
71     PyBranchNode.append( 'from time import *  ' )
72     PyBranchNode.append( 'def Print_1(Branch) :      ' )
73     PyBranchNode.append( '    print "Print ",Branch  ' )
74     PyBranchNode.append( '    sleep(1)  ' )
75     PyBranchNode.append( '    return Branch      ' )
76     BranchNode = GraphSwitchCheckBranch1Default.INode( 'Print_1' , PyBranchNode )
77     BranchNode.SetName( 'BranchNode' )
78     BranchNode.SetAuthor( '' )
79     BranchNode.SetComment( 'Compute Node' )
80     BranchNode.Coords( 529 , 177 )
81     IBranchNodeBranch = BranchNode.InPort( 'Branch' , 'string' )
82     IBranchNodeGate = BranchNode.GetInPort( 'Gate' )
83     OBranchNodeBranch = BranchNode.OutPort( 'Branch' , 'string' )
84     OBranchNodeGate = BranchNode.GetOutPort( 'Gate' )
85     
86     Pydefault = []
87     Pydefault.append( 'from time import * ' )
88     Pydefault.append( 'def default(a) : ' )
89     Pydefault.append( '    sleep(1) ' )
90     Pydefault.append( '    return a  ' )
91     default = GraphSwitchCheckBranch1Default.INode( 'default' , Pydefault )
92     default.SetName( 'default' )
93     default.SetAuthor( '' )
94     default.SetComment( 'Compute Node' )
95     default.Coords( 428 , 308 )
96     Idefaulta = default.InPort( 'a' , 'long' )
97     IdefaultGate = default.GetInPort( 'Gate' )
98     Odefaulta = default.OutPort( 'a' , 'long' )
99     OdefaultGate = default.GetOutPort( 'Gate' )
100     
101     # Creation of Loop Nodes
102     PyInitLoopSwitch = []
103     PyInitLoopSwitch.append( 'def InitLoop(Index,Min,Max) :        ' )
104     PyInitLoopSwitch.append( '  Index = Max  ' )
105     PyInitLoopSwitch.append( '  return Index,Min,Max       ' )
106     PyMoreInitLoopSwitch = []
107     PyMoreInitLoopSwitch.append( 'from time import * ' )
108     PyMoreInitLoopSwitch.append( 'def MoreLoop(Index,Min,Max) : ' )
109     PyMoreInitLoopSwitch.append( '      sleep(1)  ' )
110     PyMoreInitLoopSwitch.append( '      if Index >= Min :     ' )
111     PyMoreInitLoopSwitch.append( '              DoLoop = 1       ' )
112     PyMoreInitLoopSwitch.append( '      else :       ' )
113     PyMoreInitLoopSwitch.append( '              DoLoop = 0       ' )
114     PyMoreInitLoopSwitch.append( '      return DoLoop,Index,Min,Max       ' )
115     PyNextInitLoopSwitch = []
116     PyNextInitLoopSwitch.append( 'def NextLoop(Index,Min,Max) :       ' )
117     PyNextInitLoopSwitch.append( '      Index = Index - 1       ' )
118     PyNextInitLoopSwitch.append( '      return Index,Min,Max       ' )
119     InitLoopSwitch,EndOfInitLoopSwitch = GraphSwitchCheckBranch1Default.LNode( 'InitLoop' , PyInitLoopSwitch , 'MoreLoop' , PyMoreInitLoopSwitch , 'NextLoop' , PyNextInitLoopSwitch )
120     EndOfInitLoopSwitch.SetName( 'EndOfInitLoopSwitch' )
121     EndOfInitLoopSwitch.SetAuthor( '' )
122     EndOfInitLoopSwitch.SetComment( 'Compute Node' )
123     EndOfInitLoopSwitch.Coords( 1073 , 216 )
124     PyEndOfInitLoopSwitch = []
125     PyEndOfInitLoopSwitch.append( 'from time import *  ' )
126     PyEndOfInitLoopSwitch.append( 'def EndOfInitLoopSwitch(DoLoop,Index,Min,Max) :  ' )
127     PyEndOfInitLoopSwitch.append( '    sleep(1)  ' )
128     PyEndOfInitLoopSwitch.append( '    return DoLoop,Index,Min,Max  ' )
129     EndOfInitLoopSwitch.SetPyFunction( 'EndOfInitLoopSwitch' , PyEndOfInitLoopSwitch )
130     IInitLoopSwitchDoLoop = InitLoopSwitch.GetInPort( 'DoLoop' )
131     IInitLoopSwitchIndex = InitLoopSwitch.InPort( 'Index' , 'long' )
132     IInitLoopSwitchMin = InitLoopSwitch.InPort( 'Min' , 'long' )
133     IInitLoopSwitchMax = InitLoopSwitch.InPort( 'Max' , 'long' )
134     IInitLoopSwitchGate = InitLoopSwitch.GetInPort( 'Gate' )
135     OInitLoopSwitchDoLoop = InitLoopSwitch.GetOutPort( 'DoLoop' )
136     OInitLoopSwitchIndex = InitLoopSwitch.GetOutPort( 'Index' )
137     OInitLoopSwitchMin = InitLoopSwitch.GetOutPort( 'Min' )
138     OInitLoopSwitchMax = InitLoopSwitch.GetOutPort( 'Max' )
139     IEndOfInitLoopSwitchDoLoop = EndOfInitLoopSwitch.GetInPort( 'DoLoop' )
140     IEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetInPort( 'Index' )
141     IEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetInPort( 'Min' )
142     IEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetInPort( 'Max' )
143     IEndOfInitLoopSwitchGate = EndOfInitLoopSwitch.GetInPort( 'Gate' )
144     OEndOfInitLoopSwitchDoLoop = EndOfInitLoopSwitch.GetOutPort( 'DoLoop' )
145     OEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetOutPort( 'Index' )
146     OEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetOutPort( 'Min' )
147     OEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetOutPort( 'Max' )
148     OEndOfInitLoopSwitchGate = EndOfInitLoopSwitch.GetOutPort( 'Gate' )
149     InitLoopSwitch.SetName( 'InitLoopSwitch' )
150     InitLoopSwitch.SetAuthor( '' )
151     InitLoopSwitch.SetComment( 'Compute Node' )
152     InitLoopSwitch.Coords( 10 , 157 )
153     
154     # Creation of Switch Nodes
155     PySwitch = []
156     PySwitch.append( 'from time import *         ' )
157     PySwitch.append( 'def Switch(a) :  ' )
158     PySwitch.append( '    sleep(1)  ' )
159     PySwitch.append( '    Branch = "Negative or null"     ' )
160     PySwitch.append( '    if a <= 0 : ' )
161     PySwitch.append( '        if ( a & 1 ) == 0 : ' )
162     PySwitch.append( '            return 0,0,a,Branch,1 ' )
163     PySwitch.append( '        else : ' )
164     PySwitch.append( '            return 0,0,a,Branch,0 ' )
165     PySwitch.append( '    if ( a & 1 ) == 0 :     ' )
166     PySwitch.append( '        Branch = "Even"     ' )
167     PySwitch.append( '    else :     ' )
168     PySwitch.append( '        Branch = "Odd"     ' )
169     PySwitch.append( '    return a & 1,1-(a&1),a,Branch,0   ' )
170     Switch,EndOfSwitch = GraphSwitchCheckBranch1Default.SNode( 'Switch' , PySwitch )
171     EndOfSwitch.SetName( 'EndOfSwitch' )
172     EndOfSwitch.SetAuthor( '' )
173     EndOfSwitch.SetComment( 'Compute Node' )
174     EndOfSwitch.Coords( 880 , 216 )
175     PyEndOfSwitch = []
176     PyEndOfSwitch.append( 'from time import * ' )
177     PyEndOfSwitch.append( 'def EndOfSwitch(a,Branch) : ' )
178     PyEndOfSwitch.append( '    sleep(1) ' )
179     PyEndOfSwitch.append( '    return a ' )
180     EndOfSwitch.SetPyFunction( 'EndOfSwitch' , PyEndOfSwitch )
181     IEndOfSwitcha = EndOfSwitch.InPort( 'a' , 'long' )
182     IEndOfSwitchBranch = EndOfSwitch.InPort( 'Branch' , 'string' )
183     IEndOfSwitchDefault = EndOfSwitch.GetInPort( 'Default' )
184     OEndOfSwitcha = EndOfSwitch.OutPort( 'a' , 'long' )
185     OEndOfSwitchGate = EndOfSwitch.GetOutPort( 'Gate' )
186     Switch.SetName( 'Switch' )
187     Switch.SetAuthor( '' )
188     Switch.SetComment( 'Compute Node' )
189     Switch.Coords( 194 , 157 )
190     ISwitcha = Switch.InPort( 'a' , 'long' )
191     ISwitchGate = Switch.GetInPort( 'Gate' )
192     OSwitchOdd = Switch.OutPort( 'Odd' , 'long' )
193     OSwitchEven = Switch.OutPort( 'Even' , 'int' )
194     OSwitcha = Switch.OutPort( 'a' , 'int' )
195     OSwitchBranch = Switch.OutPort( 'Branch' , 'string' )
196     OSwitchdefault = Switch.OutPort( 'default' , 'boolean' )
197     OSwitchDefault = Switch.GetOutPort( 'Default' )
198     
199     # Creation of Links
200     LIsOddaEndOfSwitcha = GraphSwitchCheckBranch1Default.Link( OIsOdda , IEndOfSwitcha )
201     
202     LIsEvenaEndOfSwitcha = GraphSwitchCheckBranch1Default.Link( OIsEvena , IEndOfSwitcha )
203     
204     LBranchNodeBranchEndOfSwitchBranch = GraphSwitchCheckBranch1Default.Link( OBranchNodeBranch , IEndOfSwitchBranch )
205     
206     LInitLoopSwitchIndexSwitcha = GraphSwitchCheckBranch1Default.Link( OInitLoopSwitchIndex , ISwitcha )
207     
208     LInitLoopSwitchMinEndOfInitLoopSwitchMin = GraphSwitchCheckBranch1Default.Link( OInitLoopSwitchMin , IEndOfInitLoopSwitchMin )
209     
210     LInitLoopSwitchMaxEndOfInitLoopSwitchMax = GraphSwitchCheckBranch1Default.Link( OInitLoopSwitchMax , IEndOfInitLoopSwitchMax )
211     
212     LSwitchOddIsOddGate = GraphSwitchCheckBranch1Default.Link( OSwitchOdd , IIsOddGate )
213     LSwitchOddIsOddGate.AddCoord( 1 , 401 , 101 )
214     LSwitchOddIsOddGate.AddCoord( 2 , 401 , 188 )
215     
216     LSwitchEvenIsEvenGate = GraphSwitchCheckBranch1Default.Link( OSwitchEven , IIsEvenGate )
217     LSwitchEvenIsEvenGate.AddCoord( 1 , 392 , 533 )
218     LSwitchEvenIsEvenGate.AddCoord( 2 , 392 , 208 )
219     
220     LSwitchaIsOdda = GraphSwitchCheckBranch1Default.Link( OSwitcha , IIsOdda )
221     LSwitchaIsOdda.AddCoord( 1 , 382 , 78 )
222     LSwitchaIsOdda.AddCoord( 2 , 382 , 229 )
223     
224     LSwitchaIsEvena = GraphSwitchCheckBranch1Default.Link( OSwitcha , IIsEvena )
225     LSwitchaIsEvena.AddCoord( 1 , 381 , 509 )
226     LSwitchaIsEvena.AddCoord( 2 , 381 , 229 )
227     
228     LSwitchadefaulta = GraphSwitchCheckBranch1Default.Link( OSwitcha , Idefaulta )
229     LSwitchadefaulta.AddCoord( 1 , 382 , 377 )
230     LSwitchadefaulta.AddCoord( 2 , 382 , 228 )
231     
232     LSwitchBranchBranchNodeBranch = GraphSwitchCheckBranch1Default.Link( OSwitchBranch , IBranchNodeBranch )
233     
234     LSwitchdefaultdefaultGate = GraphSwitchCheckBranch1Default.Link( OSwitchdefault , IdefaultGate )
235     LSwitchdefaultdefaultGate.AddCoord( 1 , 410 , 403 )
236     LSwitchdefaultdefaultGate.AddCoord( 2 , 410 , 269 )
237     LSwitchdefaultdefaultGate.AddCoord( 3 , 410 , 268 )
238     
239     LSwitchDefaultEndOfSwitchDefault = GraphSwitchCheckBranch1Default.Link( OSwitchDefault , IEndOfSwitchDefault )
240     
241     LEndOfSwitchaEndOfInitLoopSwitchIndex = GraphSwitchCheckBranch1Default.Link( OEndOfSwitcha , IEndOfInitLoopSwitchIndex )
242     
243     LdefaultaEndOfSwitcha = GraphSwitchCheckBranch1Default.Link( Odefaulta , IEndOfSwitcha )
244     
245     # Input datas
246     IInitLoopSwitchIndex.Input( 0 )
247     IInitLoopSwitchMin.Input( -5 )
248     IInitLoopSwitchMax.Input( 10 )
249     
250     # Output Ports of the graph
251     #OEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetOutPort( 'Index' )
252     #OEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetOutPort( 'Min' )
253     #OEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetOutPort( 'Max' )
254     return GraphSwitchCheckBranch1Default
255
256
257 GraphSwitchCheckBranch1Default = DefGraphSwitchCheckBranch1Default()