Salome HOME
3f655964603df4b96d32155ada348f4f3f76eff3
[samples/datafiles.git] / Superv / Python / GraphLoopSwitchOfSwitch.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 GraphLoopSwitchOfSwitch
23 #
24 from SuperV import *
25
26 # Graph creation of GraphLoopSwitchOfSwitch
27 def DefGraphLoopSwitchOfSwitch() :
28     GraphLoopSwitchOfSwitch = Graph( 'GraphLoopSwitchOfSwitch' )
29     GraphLoopSwitchOfSwitch.SetName( 'GraphLoopSwitchOfSwitch' )
30     GraphLoopSwitchOfSwitch.SetAuthor( 'JR' )
31     GraphLoopSwitchOfSwitch.SetComment( '' )
32     GraphLoopSwitchOfSwitch.Coords( 0 , 0 )
33     
34     # Creation of Factory Nodes
35     
36     # Creation of InLine Nodes
37     PyIsEven = []
38     PyIsEven.append( 'from time import *    ' )
39     PyIsEven.append( 'def IsEven(a) :        ' )
40     PyIsEven.append( '    print a,"IsEven (GraphSwitch)"       ' )
41     PyIsEven.append( '    sleep( 1 )    ' )
42     PyIsEven.append( '    return a      ' )
43     IsEven = GraphLoopSwitchOfSwitch.INode( 'IsEven' , PyIsEven )
44     IsEven.SetName( 'IsEven' )
45     IsEven.SetAuthor( '' )
46     IsEven.SetComment( 'Compute Node' )
47     IsEven.Coords( 437 , 520 )
48     IIsEvena = IsEven.InPort( 'a' , 'long' )
49     IIsEvenGate = IsEven.GetInPort( 'Gate' )
50     OIsEvena = IsEven.OutPort( 'a' , 'long' )
51     OIsEvenGate = IsEven.GetOutPort( 'Gate' )
52     
53     PyPseudoPOne = []
54     PyPseudoPOne.append( 'from time import * ' )
55     PyPseudoPOne.append( 'def PseudoPOne(POne) : ' )
56     PyPseudoPOne.append( '    sleep(1) ' )
57     PyPseudoPOne.append( '    return 6*POne+1  ' )
58     PseudoPOne = GraphLoopSwitchOfSwitch.INode( 'PseudoPOne' , PyPseudoPOne )
59     PseudoPOne.SetName( 'PseudoPOne' )
60     PseudoPOne.SetAuthor( '' )
61     PseudoPOne.SetComment( 'Compute Node' )
62     PseudoPOne.Coords( 612 , 5 )
63     IPseudoPOnePOne = PseudoPOne.InPort( 'POne' , 'long' )
64     IPseudoPOneGate = PseudoPOne.GetInPort( 'Gate' )
65     OPseudoPOnea = PseudoPOne.OutPort( 'a' , 'long' )
66     OPseudoPOneGate = PseudoPOne.GetOutPort( 'Gate' )
67     
68     PyPseudoPThree = []
69     PyPseudoPThree.append( 'from time import * ' )
70     PyPseudoPThree.append( 'def PseudoPThree_1(PThree) : ' )
71     PyPseudoPThree.append( '    sleep(1) ' )
72     PyPseudoPThree.append( '    return 6*PThree+3  ' )
73     PseudoPThree = GraphLoopSwitchOfSwitch.INode( 'PseudoPThree_1' , PyPseudoPThree )
74     PseudoPThree.SetName( 'PseudoPThree' )
75     PseudoPThree.SetAuthor( '' )
76     PseudoPThree.SetComment( 'Compute Node' )
77     PseudoPThree.Coords( 620 , 149 )
78     IPseudoPThreePThree = PseudoPThree.InPort( 'PThree' , 'long' )
79     IPseudoPThreeGate = PseudoPThree.GetInPort( 'Gate' )
80     OPseudoPThreea = PseudoPThree.OutPort( 'a' , 'long' )
81     OPseudoPThreeGate = PseudoPThree.GetOutPort( 'Gate' )
82     
83     PyPseudoPFive = []
84     PyPseudoPFive.append( 'from time import * ' )
85     PyPseudoPFive.append( 'def PseudoPFive(PFive) : ' )
86     PyPseudoPFive.append( '    sleep(1) ' )
87     PyPseudoPFive.append( '    return 6*PFive+5  ' )
88     PseudoPFive = GraphLoopSwitchOfSwitch.INode( 'PseudoPFive' , PyPseudoPFive )
89     PseudoPFive.SetName( 'PseudoPFive' )
90     PseudoPFive.SetAuthor( '' )
91     PseudoPFive.SetComment( 'Compute Node' )
92     PseudoPFive.Coords( 625 , 343 )
93     IPseudoPFivePFive = PseudoPFive.InPort( 'PFive' , 'long' )
94     IPseudoPFiveGate = PseudoPFive.GetInPort( 'Gate' )
95     OPseudoPFivea = PseudoPFive.OutPort( 'a' , 'long' )
96     OPseudoPFiveGate = PseudoPFive.GetOutPort( 'Gate' )
97     
98     # Creation of Loop Nodes
99     PyLoopSwitch = []
100     PyLoopSwitch.append( 'def InitLoop(Index,Min,Max) :       ' )
101     PyLoopSwitch.append( '      Index = Max ' )
102     PyLoopSwitch.append( '      return Index,Min,Max      ' )
103     PyMoreLoopSwitch = []
104     PyMoreLoopSwitch.append( 'def MoreLoop(Index,Min,Max) :      ' )
105     PyMoreLoopSwitch.append( '  if Index >= Min :    ' )
106     PyMoreLoopSwitch.append( '          DoLoop = 1      ' )
107     PyMoreLoopSwitch.append( '  else :      ' )
108     PyMoreLoopSwitch.append( '          DoLoop = 0      ' )
109     PyMoreLoopSwitch.append( '  return DoLoop,Index,Min,Max      ' )
110     PyNextLoopSwitch = []
111     PyNextLoopSwitch.append( 'def NextLoop(Index,Min,Max) :      ' )
112     PyNextLoopSwitch.append( '  Index = Index - 1      ' )
113     PyNextLoopSwitch.append( '  return Index,Min,Max      ' )
114     LoopSwitch,EndOfLoopSwitch = GraphLoopSwitchOfSwitch.LNode( 'InitLoop' , PyLoopSwitch , 'MoreLoop' , PyMoreLoopSwitch , 'NextLoop' , PyNextLoopSwitch )
115     EndOfLoopSwitch.SetName( 'EndOfLoopSwitch' )
116     EndOfLoopSwitch.SetAuthor( '' )
117     EndOfLoopSwitch.SetComment( 'Compute Node' )
118     EndOfLoopSwitch.Coords( 1268 , 210 )
119     PyEndOfLoopSwitch = []
120     EndOfLoopSwitch.SetPyFunction( '' , PyEndOfLoopSwitch )
121     ILoopSwitchDoLoop = LoopSwitch.GetInPort( 'DoLoop' )
122     ILoopSwitchIndex = LoopSwitch.InPort( 'Index' , 'long' )
123     ILoopSwitchMin = LoopSwitch.InPort( 'Min' , 'long' )
124     ILoopSwitchMax = LoopSwitch.InPort( 'Max' , 'long' )
125     ILoopSwitchGate = LoopSwitch.GetInPort( 'Gate' )
126     OLoopSwitchDoLoop = LoopSwitch.GetOutPort( 'DoLoop' )
127     OLoopSwitchIndex = LoopSwitch.GetOutPort( 'Index' )
128     OLoopSwitchMin = LoopSwitch.GetOutPort( 'Min' )
129     OLoopSwitchMax = LoopSwitch.GetOutPort( 'Max' )
130     IEndOfLoopSwitchDoLoop = EndOfLoopSwitch.GetInPort( 'DoLoop' )
131     IEndOfLoopSwitchIndex = EndOfLoopSwitch.GetInPort( 'Index' )
132     IEndOfLoopSwitchMin = EndOfLoopSwitch.GetInPort( 'Min' )
133     IEndOfLoopSwitchMax = EndOfLoopSwitch.GetInPort( 'Max' )
134     IEndOfLoopSwitchGate = EndOfLoopSwitch.GetInPort( 'Gate' )
135     OEndOfLoopSwitchDoLoop = EndOfLoopSwitch.GetOutPort( 'DoLoop' )
136     OEndOfLoopSwitchIndex = EndOfLoopSwitch.GetOutPort( 'Index' )
137     OEndOfLoopSwitchMin = EndOfLoopSwitch.GetOutPort( 'Min' )
138     OEndOfLoopSwitchMax = EndOfLoopSwitch.GetOutPort( 'Max' )
139     OEndOfLoopSwitchGate = EndOfLoopSwitch.GetOutPort( 'Gate' )
140     LoopSwitch.SetName( 'LoopSwitch' )
141     LoopSwitch.SetAuthor( '' )
142     LoopSwitch.SetComment( 'Compute Node' )
143     LoopSwitch.Coords( 6 , 233 )
144     
145     # Creation of Switch Nodes
146     PySwitch = []
147     PySwitch.append( 'from time import *       ' )
148     PySwitch.append( 'def Switch(a) :   ' )
149     PySwitch.append( '    sleep(1)   ' )
150     PySwitch.append( '    if a <= 0 :      ' )
151     PySwitch.append( '        return 0,a,0 ' )
152     PySwitch.append( '    return a & 1,a,1-(a&1)        ' )
153     Switch,EndOfSwitch = GraphLoopSwitchOfSwitch.SNode( 'Switch' , PySwitch )
154     EndOfSwitch.SetName( 'EndOfSwitch' )
155     EndOfSwitch.SetAuthor( '' )
156     EndOfSwitch.SetComment( 'Compute Node' )
157     EndOfSwitch.Coords( 1075 , 210 )
158     PyEndOfSwitch = []
159     EndOfSwitch.SetPyFunction( 'EndSwitch_1' , PyEndOfSwitch )
160     IEndOfSwitcha = EndOfSwitch.InPort( 'a' , 'long' )
161     IEndOfSwitchDefault = EndOfSwitch.GetInPort( 'Default' )
162     OEndOfSwitcha = EndOfSwitch.OutPort( 'a' , 'long' )
163     OEndOfSwitchGate = EndOfSwitch.GetOutPort( 'Gate' )
164     Switch.SetName( 'Switch' )
165     Switch.SetAuthor( '' )
166     Switch.SetComment( 'Compute Node' )
167     Switch.Coords( 201 , 233 )
168     ISwitcha = Switch.InPort( 'a' , 'long' )
169     ISwitchGate = Switch.GetInPort( 'Gate' )
170     OSwitchOdd = Switch.OutPort( 'Odd' , 'long' )
171     OSwitcha = Switch.OutPort( 'a' , 'int' )
172     OSwitchEven = Switch.OutPort( 'Even' , 'boolean' )
173     OSwitchDefault = Switch.GetOutPort( 'Default' )
174     
175     PySwitchOdd = []
176     PySwitchOdd.append( 'def SwitchOdd(a) :   ' )
177     PySwitchOdd.append( '    n = a/6   ' )
178     PySwitchOdd.append( '    r = a%6   ' )
179     PySwitchOdd.append( '    POne = 0   ' )
180     PySwitchOdd.append( '    PThree = 0   ' )
181     PySwitchOdd.append( '    PFive = 0   ' )
182     PySwitchOdd.append( '    if r == 1 :   ' )
183     PySwitchOdd.append( '        POne = 1  ' )
184     PySwitchOdd.append( '    if r == 3 :   ' )
185     PySwitchOdd.append( '        PThree = 1  ' )
186     PySwitchOdd.append( '    if r == 5 :   ' )
187     PySwitchOdd.append( '        PFive = 1  ' )
188     PySwitchOdd.append( '    return POne,PThree,PFive,n ' )
189     SwitchOdd,EndOfSwitchOdd = GraphLoopSwitchOfSwitch.SNode( 'SwitchOdd' , PySwitchOdd )
190     EndOfSwitchOdd.SetName( 'EndOfSwitchOdd' )
191     EndOfSwitchOdd.SetAuthor( '' )
192     EndOfSwitchOdd.SetComment( 'Compute Node' )
193     EndOfSwitchOdd.Coords( 851 , 210 )
194     PyEndOfSwitchOdd = []
195     EndOfSwitchOdd.SetPyFunction( 'EndSwitch' , PyEndOfSwitchOdd )
196     IEndOfSwitchOddn = EndOfSwitchOdd.InPort( 'n' , 'long' )
197     IEndOfSwitchOddDefault = EndOfSwitchOdd.GetInPort( 'Default' )
198     OEndOfSwitchOddn = EndOfSwitchOdd.OutPort( 'n' , 'long' )
199     OEndOfSwitchOddGate = EndOfSwitchOdd.GetOutPort( 'Gate' )
200     SwitchOdd.SetName( 'SwitchOdd' )
201     SwitchOdd.SetAuthor( '' )
202     SwitchOdd.SetComment( 'Compute Node' )
203     SwitchOdd.Coords( 412 , 169 )
204     ISwitchOdda = SwitchOdd.InPort( 'a' , 'long' )
205     ISwitchOddGate = SwitchOdd.GetInPort( 'Gate' )
206     OSwitchOddPOne = SwitchOdd.OutPort( 'POne' , 'boolean' )
207     OSwitchOddPThree = SwitchOdd.OutPort( 'PThree' , 'boolean' )
208     OSwitchOddPFive = SwitchOdd.OutPort( 'PFive' , 'boolean' )
209     OSwitchOddn = SwitchOdd.OutPort( 'n' , 'long' )
210     OSwitchOddDefault = SwitchOdd.GetOutPort( 'Default' )
211     
212     # Creation of Links
213     LLoopSwitchIndexSwitcha = GraphLoopSwitchOfSwitch.Link( OLoopSwitchIndex , ISwitcha )
214     
215     LLoopSwitchMinEndOfLoopSwitchMin = GraphLoopSwitchOfSwitch.Link( OLoopSwitchMin , IEndOfLoopSwitchMin )
216     
217     LLoopSwitchMaxEndOfLoopSwitchMax = GraphLoopSwitchOfSwitch.Link( OLoopSwitchMax , IEndOfLoopSwitchMax )
218     
219     LIsEvenaEndOfSwitcha = GraphLoopSwitchOfSwitch.Link( OIsEvena , IEndOfSwitcha )
220     LIsEvenaEndOfSwitcha.AddCoord( 1 , 719 , 591 )
221     
222     LSwitchOddSwitchOddGate = GraphLoopSwitchOfSwitch.Link( OSwitchOdd , ISwitchOddGate )
223     
224     LSwitchaIsEvena = GraphLoopSwitchOfSwitch.Link( OSwitcha , IIsEvena )
225     
226     LSwitchaSwitchOdda = GraphLoopSwitchOfSwitch.Link( OSwitcha , ISwitchOdda )
227     
228     LSwitchEvenIsEvenGate = GraphLoopSwitchOfSwitch.Link( OSwitchEven , IIsEvenGate )
229     
230     LSwitchDefaultEndOfSwitchDefault = GraphLoopSwitchOfSwitch.Link( OSwitchDefault , IEndOfSwitchDefault )
231     LSwitchDefaultEndOfSwitchDefault.AddCoord( 1 , 1057 , 267 )
232     LSwitchDefaultEndOfSwitchDefault.AddCoord( 2 , 1079 , 669 )
233     LSwitchDefaultEndOfSwitchDefault.AddCoord( 3 , 383 , 666 )
234     
235     LEndOfSwitchaEndOfLoopSwitchIndex = GraphLoopSwitchOfSwitch.Link( OEndOfSwitcha , IEndOfLoopSwitchIndex )
236     
237     LSwitchOddPOnePseudoPOneGate = GraphLoopSwitchOfSwitch.Link( OSwitchOddPOne , IPseudoPOneGate )
238     
239     LSwitchOddPThreePseudoPThreeGate = GraphLoopSwitchOfSwitch.Link( OSwitchOddPThree , IPseudoPThreeGate )
240     
241     LSwitchOddPFivePseudoPFiveGate = GraphLoopSwitchOfSwitch.Link( OSwitchOddPFive , IPseudoPFiveGate )
242     
243     LSwitchOddnPseudoPOnePOne = GraphLoopSwitchOfSwitch.Link( OSwitchOddn , IPseudoPOnePOne )
244     
245     LSwitchOddnPseudoPThreePThree = GraphLoopSwitchOfSwitch.Link( OSwitchOddn , IPseudoPThreePThree )
246     
247     LSwitchOddnPseudoPFivePFive = GraphLoopSwitchOfSwitch.Link( OSwitchOddn , IPseudoPFivePFive )
248     
249     LSwitchOddDefaultEndOfSwitchOddDefault = GraphLoopSwitchOfSwitch.Link( OSwitchOddDefault , IEndOfSwitchOddDefault )
250     
251     LEndOfSwitchOddnEndOfSwitcha = GraphLoopSwitchOfSwitch.Link( OEndOfSwitchOddn , IEndOfSwitcha )
252     
253     LPseudoPOneaEndOfSwitchOddn = GraphLoopSwitchOfSwitch.Link( OPseudoPOnea , IEndOfSwitchOddn )
254     
255     LPseudoPThreeaEndOfSwitchOddn = GraphLoopSwitchOfSwitch.Link( OPseudoPThreea , IEndOfSwitchOddn )
256     
257     LPseudoPFiveaEndOfSwitchOddn = GraphLoopSwitchOfSwitch.Link( OPseudoPFivea , IEndOfSwitchOddn )
258     
259     # Input datas
260     ILoopSwitchIndex.Input( 0 )
261     ILoopSwitchMin.Input( -5 )
262     ILoopSwitchMax.Input( 17 )
263     
264     # Output Ports of the graph
265     #OEndOfLoopSwitchIndex = EndOfLoopSwitch.GetOutPort( 'Index' )
266     #OEndOfLoopSwitchMin = EndOfLoopSwitch.GetOutPort( 'Min' )
267     #OEndOfLoopSwitchMax = EndOfLoopSwitch.GetOutPort( 'Max' )
268     return GraphLoopSwitchOfSwitch
269
270
271 GraphLoopSwitchOfSwitch = DefGraphLoopSwitchOfSwitch()