Salome HOME
Merge from BR_V5_DEV 17Feb09
[samples/datafiles.git] / Superv / Python / GraphSwitchCheckBranch2NOTValid.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 GraphSwitchCheckBranch2NOTValid
23 #
24 from SuperV import *
25
26 # Graph creation of GraphSwitchCheckBranch2NOTValid
27 def DefGraphSwitchCheckBranch2NOTValid() :
28     GraphSwitchCheckBranch2NOTValid = Graph( 'GraphSwitchCheckBranch2NOTValid' )
29     GraphSwitchCheckBranch2NOTValid.SetName( 'GraphSwitchCheckBranch2NOTValid' )
30     GraphSwitchCheckBranch2NOTValid.SetAuthor( 'JR' )
31     GraphSwitchCheckBranch2NOTValid.SetComment( 'Switch with two SwitchBranches, One NotSwitchBranch and the DefaultBranch
32 Shared Node between Branches' )
33     GraphSwitchCheckBranch2NOTValid.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(aBranch) :        ' )
41     PyIsOdd.append( '    print a,"IsOdd (GraphSwitch)"       ' )
42     PyIsOdd.append( '    sleep( 1 )    ' )
43     PyIsOdd.append( '    return a      ' )
44     IsOdd = GraphSwitchCheckBranch2NOTValid.INode( 'IsOdd' , PyIsOdd )
45     IsOdd.SetName( 'IsOdd' )
46     IsOdd.SetAuthor( '' )
47     IsOdd.SetComment( 'Python function' )
48     IsOdd.Coords( 649 , 6 )
49     IIsOdda = IsOdd.InPort( 'a' , 'long' )
50     IIsOddBranch = IsOdd.InPort( 'Branch' , 'string' )
51     IIsOddGate = IsOdd.GetInPort( 'Gate' )
52     OIsOdda = IsOdd.OutPort( 'a' , 'long' )
53     OIsOddGate = IsOdd.GetOutPort( 'Gate' )
54     
55     PyIsEven = []
56     PyIsEven.append( 'from time import *     ' )
57     PyIsEven.append( 'def IsEven(aBranch) :         ' )
58     PyIsEven.append( '    print a,"IsEven (GraphSwitch)"        ' )
59     PyIsEven.append( '    sleep( 1 )     ' )
60     PyIsEven.append( '    return a       ' )
61     IsEven = GraphSwitchCheckBranch2NOTValid.INode( 'IsEven' , PyIsEven )
62     IsEven.SetName( 'IsEven' )
63     IsEven.SetAuthor( '' )
64     IsEven.SetComment( 'Compute Node' )
65     IsEven.Coords( 657 , 451 )
66     IIsEvena = IsEven.InPort( 'a' , 'long' )
67     IIsEvenBranch = IsEven.InPort( 'Branch' , 'string' )
68     IIsEvenGate = IsEven.GetInPort( 'Gate' )
69     OIsEvena = IsEven.OutPort( 'a' , 'long' )
70     OIsEvenGate = IsEven.GetOutPort( 'Gate' )
71     
72     PyBranchNode = []
73     PyBranchNode.append( 'from time import *  ' )
74     PyBranchNode.append( 'def Print_1(Branch) :      ' )
75     PyBranchNode.append( '    print "Print ",Branch  ' )
76     PyBranchNode.append( '    sleep(1)  ' )
77     PyBranchNode.append( '    return Branch      ' )
78     BranchNode = GraphSwitchCheckBranch2NOTValid.INode( 'Print_1' , PyBranchNode )
79     BranchNode.SetName( 'BranchNode' )
80     BranchNode.SetAuthor( '' )
81     BranchNode.SetComment( 'Compute Node' )
82     BranchNode.Coords( 429 , 177 )
83     IBranchNodeBranch = BranchNode.InPort( 'Branch' , 'string' )
84     IBranchNodeGate = BranchNode.GetInPort( 'Gate' )
85     OBranchNodeBranch = BranchNode.OutPort( 'Branch' , 'string' )
86     OBranchNodeGate = BranchNode.GetOutPort( 'Gate' )
87     
88     Pydefault = []
89     Pydefault.append( 'from time import *  ' )
90     Pydefault.append( 'def default(a,Branch) :  ' )
91     Pydefault.append( '    sleep(1)  ' )
92     Pydefault.append( '    return a   ' )
93     default = GraphSwitchCheckBranch2NOTValid.INode( 'default' , Pydefault )
94     default.SetName( 'default' )
95     default.SetAuthor( '' )
96     default.SetComment( 'Compute Node' )
97     default.Coords( 655 , 306 )
98     Idefaulta = default.InPort( 'a' , 'long' )
99     IdefaultBranch = default.InPort( 'Branch' , 'string' )
100     IdefaultGate = default.GetInPort( 'Gate' )
101     Odefaulta = default.OutPort( 'a' , 'long' )
102     OdefaultGate = default.GetOutPort( 'Gate' )
103     
104     # Creation of Loop Nodes
105     PyInitLoopSwitch = []
106     PyInitLoopSwitch.append( 'def InitLoop(Index,Min,Max) :        ' )
107     PyInitLoopSwitch.append( '  Index = Max  ' )
108     PyInitLoopSwitch.append( '  return Index,Min,Max       ' )
109     PyMoreInitLoopSwitch = []
110     PyMoreInitLoopSwitch.append( 'from time import * ' )
111     PyMoreInitLoopSwitch.append( 'def MoreLoop(Index,Min,Max) : ' )
112     PyMoreInitLoopSwitch.append( '      sleep(1)  ' )
113     PyMoreInitLoopSwitch.append( '      if Index >= Min :     ' )
114     PyMoreInitLoopSwitch.append( '              DoLoop = 1       ' )
115     PyMoreInitLoopSwitch.append( '      else :       ' )
116     PyMoreInitLoopSwitch.append( '              DoLoop = 0       ' )
117     PyMoreInitLoopSwitch.append( '      return DoLoop,Index,Min,Max       ' )
118     PyNextInitLoopSwitch = []
119     PyNextInitLoopSwitch.append( 'def NextLoop(Index,Min,Max) :       ' )
120     PyNextInitLoopSwitch.append( '      Index = Index - 1       ' )
121     PyNextInitLoopSwitch.append( '      return Index,Min,Max       ' )
122     InitLoopSwitch,EndOfInitLoopSwitch = GraphSwitchCheckBranch2NOTValid.LNode( 'InitLoop' , PyInitLoopSwitch , 'MoreLoop' , PyMoreInitLoopSwitch , 'NextLoop' , PyNextInitLoopSwitch )
123     EndOfInitLoopSwitch.SetName( 'EndOfInitLoopSwitch' )
124     EndOfInitLoopSwitch.SetAuthor( '' )
125     EndOfInitLoopSwitch.SetComment( 'Compute Node' )
126     EndOfInitLoopSwitch.Coords( 1073 , 216 )
127     PyEndOfInitLoopSwitch = []
128     PyEndOfInitLoopSwitch.append( 'from time import *  ' )
129     PyEndOfInitLoopSwitch.append( 'def EndOfInitLoopSwitch(DoLoop,Index,Min,Max) :  ' )
130     PyEndOfInitLoopSwitch.append( '    sleep(1)  ' )
131     PyEndOfInitLoopSwitch.append( '    return DoLoop,Index,Min,Max  ' )
132     EndOfInitLoopSwitch.SetPyFunction( 'EndOfInitLoopSwitch' , PyEndOfInitLoopSwitch )
133     IInitLoopSwitchDoLoop = InitLoopSwitch.GetInPort( 'DoLoop' )
134     IInitLoopSwitchIndex = InitLoopSwitch.InPort( 'Index' , 'long' )
135     IInitLoopSwitchMin = InitLoopSwitch.InPort( 'Min' , 'long' )
136     IInitLoopSwitchMax = InitLoopSwitch.InPort( 'Max' , 'long' )
137     IInitLoopSwitchGate = InitLoopSwitch.GetInPort( 'Gate' )
138     OInitLoopSwitchDoLoop = InitLoopSwitch.GetOutPort( 'DoLoop' )
139     OInitLoopSwitchIndex = InitLoopSwitch.GetOutPort( 'Index' )
140     OInitLoopSwitchMin = InitLoopSwitch.GetOutPort( 'Min' )
141     OInitLoopSwitchMax = InitLoopSwitch.GetOutPort( 'Max' )
142     IEndOfInitLoopSwitchDoLoop = EndOfInitLoopSwitch.GetInPort( 'DoLoop' )
143     IEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetInPort( 'Index' )
144     IEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetInPort( 'Min' )
145     IEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetInPort( 'Max' )
146     IEndOfInitLoopSwitchGate = EndOfInitLoopSwitch.GetInPort( 'Gate' )
147     OEndOfInitLoopSwitchDoLoop = EndOfInitLoopSwitch.GetOutPort( 'DoLoop' )
148     OEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetOutPort( 'Index' )
149     OEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetOutPort( 'Min' )
150     OEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetOutPort( 'Max' )
151     OEndOfInitLoopSwitchGate = EndOfInitLoopSwitch.GetOutPort( 'Gate' )
152     InitLoopSwitch.SetName( 'InitLoopSwitch' )
153     InitLoopSwitch.SetAuthor( '' )
154     InitLoopSwitch.SetComment( 'Compute Node' )
155     InitLoopSwitch.Coords( 10 , 157 )
156     
157     # Creation of Switch Nodes
158     PySwitch = []
159     PySwitch.append( 'from time import *        ' )
160     PySwitch.append( 'def Switch(a) : ' )
161     PySwitch.append( '    sleep(1) ' )
162     PySwitch.append( '    Branch = "Negative or null"    ' )
163     PySwitch.append( '    if a <= 0 :       ' )
164     PySwitch.append( '        return 0,0,a,Branch,1  ' )
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 = GraphSwitchCheckBranch2NOTValid.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 = GraphSwitchCheckBranch2NOTValid.Link( OIsOdda , IEndOfSwitcha )
201     
202     LIsEvenaEndOfSwitcha = GraphSwitchCheckBranch2NOTValid.Link( OIsEvena , IEndOfSwitcha )
203     
204     LBranchNodeBranchEndOfSwitchBranch = GraphSwitchCheckBranch2NOTValid.Link( OBranchNodeBranch , IEndOfSwitchBranch )
205     
206     LBranchNodeBranchIsOddBranch = GraphSwitchCheckBranch2NOTValid.Link( OBranchNodeBranch , IIsOddBranch )
207     
208     LBranchNodeBranchdefaultBranch = GraphSwitchCheckBranch2NOTValid.Link( OBranchNodeBranch , IdefaultBranch )
209     
210     LBranchNodeBranchIsEvenBranch = GraphSwitchCheckBranch2NOTValid.Link( OBranchNodeBranch , IIsEvenBranch )
211     
212     LInitLoopSwitchIndexSwitcha = GraphSwitchCheckBranch2NOTValid.Link( OInitLoopSwitchIndex , ISwitcha )
213     
214     LInitLoopSwitchMinEndOfInitLoopSwitchMin = GraphSwitchCheckBranch2NOTValid.Link( OInitLoopSwitchMin , IEndOfInitLoopSwitchMin )
215     
216     LInitLoopSwitchMaxEndOfInitLoopSwitchMax = GraphSwitchCheckBranch2NOTValid.Link( OInitLoopSwitchMax , IEndOfInitLoopSwitchMax )
217     
218     LSwitchOddIsOddGate = GraphSwitchCheckBranch2NOTValid.Link( OSwitchOdd , IIsOddGate )
219     LSwitchOddIsOddGate.AddCoord( 1 , 400 , 121 )
220     LSwitchOddIsOddGate.AddCoord( 2 , 401 , 188 )
221     
222     LSwitchEvenIsEvenGate = GraphSwitchCheckBranch2NOTValid.Link( OSwitchEven , IIsEvenGate )
223     LSwitchEvenIsEvenGate.AddCoord( 1 , 391 , 568 )
224     LSwitchEvenIsEvenGate.AddCoord( 2 , 392 , 208 )
225     
226     LSwitchadefaulta = GraphSwitchCheckBranch2NOTValid.Link( OSwitcha , Idefaulta )
227     
228     LSwitchaIsEvena = GraphSwitchCheckBranch2NOTValid.Link( OSwitcha , IIsEvena )
229     
230     LSwitchaIsOdda = GraphSwitchCheckBranch2NOTValid.Link( OSwitcha , IIsOdda )
231     
232     LSwitchBranchBranchNodeBranch = GraphSwitchCheckBranch2NOTValid.Link( OSwitchBranch , IBranchNodeBranch )
233     
234     LSwitchdefaultdefaultGate = GraphSwitchCheckBranch2NOTValid.Link( OSwitchdefault , IdefaultGate )
235     LSwitchdefaultdefaultGate.AddCoord( 1 , 410 , 422 )
236     LSwitchdefaultdefaultGate.AddCoord( 2 , 410 , 269 )
237     LSwitchdefaultdefaultGate.AddCoord( 3 , 410 , 268 )
238     
239     LSwitchDefaultEndOfSwitchDefault = GraphSwitchCheckBranch2NOTValid.Link( OSwitchDefault , IEndOfSwitchDefault )
240     
241     LEndOfSwitchaEndOfInitLoopSwitchIndex = GraphSwitchCheckBranch2NOTValid.Link( OEndOfSwitcha , IEndOfInitLoopSwitchIndex )
242     
243     LdefaultaEndOfSwitcha = GraphSwitchCheckBranch2NOTValid.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 GraphSwitchCheckBranch2NOTValid
255
256
257 GraphSwitchCheckBranch2NOTValid = DefGraphSwitchCheckBranch2NOTValid()