Salome HOME
Merge from BR_V5_DEV 17Feb09
[samples/datafiles.git] / Superv / Python / GraphSwitchOutput.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 GraphSwitch_1_1_2
23 #
24 from SuperV import *
25
26 # Graph creation of GraphSwitch_1_1_2
27 def DefGraphSwitch_1_1_2() :
28     GraphSwitch_1_1_2 = Graph( 'GraphSwitch_1_1_2' )
29     GraphSwitch_1_1_2.SetName( 'GraphSwitch_1_1_2' )
30     GraphSwitch_1_1_2.SetAuthor( '' )
31     GraphSwitch_1_1_2.SetComment( '' )
32     GraphSwitch_1_1_2.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,Branch) :        ' )
40     PyIsOdd.append( '    print a,"IsOdd (GraphSwitch)"       ' )
41     PyIsOdd.append( '    sleep( 1 )    ' )
42     PyIsOdd.append( '    return a,Branch ' )
43     IsOdd = GraphSwitch_1_1_2.INode( 'IsOdd' , PyIsOdd )
44     IsOdd.SetName( 'IsOdd' )
45     IsOdd.SetAuthor( '' )
46     IsOdd.SetComment( 'Python function' )
47     IsOdd.Coords( 388 , 50 )
48     IIsOdda = IsOdd.InPort( 'a' , 'long' )
49     IIsOddBranch = IsOdd.InPort( 'Branch' , 'string' )
50     IIsOddGate = IsOdd.GetInPort( 'Gate' )
51     OIsOdda = IsOdd.OutPort( 'a' , 'long' )
52     OIsOddBranch = IsOdd.OutPort( 'Branch' , 'string' )
53     OIsOddGate = IsOdd.GetOutPort( 'Gate' )
54     
55     PyIsEven = []
56     PyIsEven.append( 'from time import *     ' )
57     PyIsEven.append( 'def IsEven(a,Branch) :         ' )
58     PyIsEven.append( '    print a,"IsEven (GraphSwitch)"        ' )
59     PyIsEven.append( '    sleep( 1 )     ' )
60     PyIsEven.append( '    return a,Branch ' )
61     IsEven = GraphSwitch_1_1_2.INode( 'IsEven' , PyIsEven )
62     IsEven.SetName( 'IsEven' )
63     IsEven.SetAuthor( '' )
64     IsEven.SetComment( 'Compute Node' )
65     IsEven.Coords( 395 , 334 )
66     IIsEvena = IsEven.InPort( 'a' , 'long' )
67     IIsEvenBranch = IsEven.InPort( 'Branch' , 'string' )
68     IIsEvenGate = IsEven.GetInPort( 'Gate' )
69     OIsEvena = IsEven.OutPort( 'a' , 'long' )
70     OIsEvenBranch = IsEven.OutPort( 'Branch' , 'string' )
71     OIsEvenGate = IsEven.GetOutPort( 'Gate' )
72     
73     PyPrint = []
74     PyPrint.append( 'def Print(a,Branch) :   ' )
75     PyPrint.append( '    print "Print ",Branch   ' )
76     PyPrint.append( '    return a,Branch   ' )
77     Print = GraphSwitch_1_1_2.INode( 'Print' , PyPrint )
78     Print.SetName( 'Print' )
79     Print.SetAuthor( '' )
80     Print.SetComment( 'Compute Node' )
81     Print.Coords( 639 , 63 )
82     IPrinta = Print.InPort( 'a' , 'long' )
83     IPrintBranch = Print.InPort( 'Branch' , 'string' )
84     IPrintGate = Print.GetInPort( 'Gate' )
85     OPrinta = Print.OutPort( 'a' , 'long' )
86     OPrintBranch = Print.OutPort( 'Branch' , 'string' )
87     OPrintGate = Print.GetOutPort( 'Gate' )
88     
89     PyPrint_1 = []
90     PyPrint_1.append( 'def Print_1(a,Branch) :   ' )
91     PyPrint_1.append( '    print "Print ",Branch   ' )
92     PyPrint_1.append( '    return a,Branch   ' )
93     Print_1 = GraphSwitch_1_1_2.INode( 'Print_1' , PyPrint_1 )
94     Print_1.SetName( 'Print_1' )
95     Print_1.SetAuthor( '' )
96     Print_1.SetComment( 'Compute Node' )
97     Print_1.Coords( 639 , 263 )
98     IPrint_1a = Print_1.InPort( 'a' , 'long' )
99     IPrint_1Branch = Print_1.InPort( 'Branch' , 'string' )
100     IPrint_1Gate = Print_1.GetInPort( 'Gate' )
101     OPrint_1a = Print_1.OutPort( 'a' , 'long' )
102     OPrint_1Branch = Print_1.OutPort( 'Branch' , 'string' )
103     OPrint_1Gate = Print_1.GetOutPort( 'Gate' )
104     
105     # Creation of Loop Nodes
106     PyInitLoopSwitch = []
107     PyInitLoopSwitch.append( 'def InitLoop(Index,Min,Max) :       ' )
108     PyInitLoopSwitch.append( '  Index = Max ' )
109     PyInitLoopSwitch.append( '  return Index,Min,Max      ' )
110     PyMoreInitLoopSwitch = []
111     PyMoreInitLoopSwitch.append( 'def MoreLoop(Index,Min,Max) :      ' )
112     PyMoreInitLoopSwitch.append( '      if Index >= Min :    ' )
113     PyMoreInitLoopSwitch.append( '              DoLoop = 1      ' )
114     PyMoreInitLoopSwitch.append( '      else :      ' )
115     PyMoreInitLoopSwitch.append( '              DoLoop = 0      ' )
116     PyMoreInitLoopSwitch.append( '      return DoLoop,Index,Min,Max      ' )
117     PyNextInitLoopSwitch = []
118     PyNextInitLoopSwitch.append( 'def NextLoop(Index,Min,Max) :      ' )
119     PyNextInitLoopSwitch.append( '      Index = Index - 1      ' )
120     PyNextInitLoopSwitch.append( '      return Index,Min,Max      ' )
121     InitLoopSwitch,EndOfInitLoopSwitch = GraphSwitch_1_1_2.LNode( 'InitLoop' , PyInitLoopSwitch , 'MoreLoop' , PyMoreInitLoopSwitch , 'NextLoop' , PyNextInitLoopSwitch )
122     EndOfInitLoopSwitch.SetName( 'EndOfInitLoopSwitch' )
123     EndOfInitLoopSwitch.SetAuthor( '' )
124     EndOfInitLoopSwitch.SetComment( 'Compute Node' )
125     EndOfInitLoopSwitch.Coords( 1082 , 150 )
126     PyEndOfInitLoopSwitch = []
127     EndOfInitLoopSwitch.SetPyFunction( '' , PyEndOfInitLoopSwitch )
128     IInitLoopSwitchDoLoop = InitLoopSwitch.GetInPort( 'DoLoop' )
129     IInitLoopSwitchIndex = InitLoopSwitch.InPort( 'Index' , 'long' )
130     IInitLoopSwitchMin = InitLoopSwitch.InPort( 'Min' , 'long' )
131     IInitLoopSwitchMax = InitLoopSwitch.InPort( 'Max' , 'long' )
132     IInitLoopSwitchGate = InitLoopSwitch.GetInPort( 'Gate' )
133     OInitLoopSwitchDoLoop = InitLoopSwitch.GetOutPort( 'DoLoop' )
134     OInitLoopSwitchIndex = InitLoopSwitch.GetOutPort( 'Index' )
135     OInitLoopSwitchMin = InitLoopSwitch.GetOutPort( 'Min' )
136     OInitLoopSwitchMax = InitLoopSwitch.GetOutPort( 'Max' )
137     IEndOfInitLoopSwitchDoLoop = EndOfInitLoopSwitch.GetInPort( 'DoLoop' )
138     IEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetInPort( 'Index' )
139     IEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetInPort( 'Min' )
140     IEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetInPort( 'Max' )
141     IEndOfInitLoopSwitchGate = EndOfInitLoopSwitch.GetInPort( 'Gate' )
142     OEndOfInitLoopSwitchDoLoop = EndOfInitLoopSwitch.GetOutPort( 'DoLoop' )
143     OEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetOutPort( 'Index' )
144     OEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetOutPort( 'Min' )
145     OEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetOutPort( 'Max' )
146     OEndOfInitLoopSwitchGate = EndOfInitLoopSwitch.GetOutPort( 'Gate' )
147     InitLoopSwitch.SetName( 'InitLoopSwitch' )
148     InitLoopSwitch.SetAuthor( '' )
149     InitLoopSwitch.SetComment( 'Compute Node' )
150     InitLoopSwitch.Coords( 10 , 129 )
151     
152     # Creation of Switch Nodes
153     PySwitch = []
154     PySwitch.append( 'from time import *       ' )
155     PySwitch.append( 'def Switch(a) :   ' )
156     PySwitch.append( '    Branch = 'Negative or null'   ' )
157     PySwitch.append( '    if a <= 0 :      ' )
158     PySwitch.append( '        return 0,0,a,Branch,1 ' )
159     PySwitch.append( '    if ( a & 1 ) == 0 :   ' )
160     PySwitch.append( '        Branch = 'Even'   ' )
161     PySwitch.append( '    else :   ' )
162     PySwitch.append( '        Branch = 'Odd'   ' )
163     PySwitch.append( '    sleep(1)   ' )
164     PySwitch.append( '    return a & 1,1-(a&1),a,Branch,0 ' )
165     Switch,EndOfSwitch = GraphSwitch_1_1_2.SNode( 'Switch' , PySwitch )
166     EndOfSwitch.SetName( 'EndOfSwitch' )
167     EndOfSwitch.SetAuthor( '' )
168     EndOfSwitch.SetComment( 'Compute Node' )
169     EndOfSwitch.Coords( 880 , 150 )
170     PyEndOfSwitch = []
171     EndOfSwitch.SetPyFunction( 'EndSwitch_1' , PyEndOfSwitch )
172     IEndOfSwitcha = EndOfSwitch.InPort( 'a' , 'long' )
173     IEndOfSwitchDefault = EndOfSwitch.GetInPort( 'Default' )
174     OEndOfSwitcha = EndOfSwitch.OutPort( 'a' , 'long' )
175     OEndOfSwitchGate = EndOfSwitch.GetOutPort( 'Gate' )
176     Switch.SetName( 'Switch' )
177     Switch.SetAuthor( '' )
178     Switch.SetComment( 'Compute Node' )
179     Switch.Coords( 195 , 129 )
180     ISwitcha = Switch.InPort( 'a' , 'long' )
181     ISwitchGate = Switch.GetInPort( 'Gate' )
182     OSwitchOdd = Switch.OutPort( 'Odd' , 'long' )
183     OSwitchEven = Switch.OutPort( 'Even' , 'int' )
184     OSwitcha = Switch.OutPort( 'a' , 'int' )
185     OSwitchBranch = Switch.OutPort( 'Branch' , 'string' )
186     OSwitchdefault = Switch.OutPort( 'default' , 'boolean' )
187     OSwitchDefault = Switch.GetOutPort( 'Default' )
188     
189     # Creation of Links
190     LIsOddaPrinta = GraphSwitch_1_1_2.Link( OIsOdda , IPrinta )
191     
192     LIsOddBranchPrintBranch = GraphSwitch_1_1_2.Link( OIsOddBranch , IPrintBranch )
193     
194     LInitLoopSwitchIndexSwitcha = GraphSwitch_1_1_2.Link( OInitLoopSwitchIndex , ISwitcha )
195     
196     LInitLoopSwitchMinEndOfInitLoopSwitchMin = GraphSwitch_1_1_2.Link( OInitLoopSwitchMin , IEndOfInitLoopSwitchMin )
197     
198     LInitLoopSwitchMaxEndOfInitLoopSwitchMax = GraphSwitch_1_1_2.Link( OInitLoopSwitchMax , IEndOfInitLoopSwitchMax )
199     
200     LIsEvenaPrint_1a = GraphSwitch_1_1_2.Link( OIsEvena , IPrint_1a )
201     
202     LIsEvenBranchPrint_1Branch = GraphSwitch_1_1_2.Link( OIsEvenBranch , IPrint_1Branch )
203     
204     LSwitchOddIsOddGate = GraphSwitch_1_1_2.Link( OSwitchOdd , IIsOddGate )
205     
206     LSwitchEvenIsEvenGate = GraphSwitch_1_1_2.Link( OSwitchEven , IIsEvenGate )
207     
208     LSwitchaIsOdda = GraphSwitch_1_1_2.Link( OSwitcha , IIsOdda )
209     
210     LSwitchaIsEvena = GraphSwitch_1_1_2.Link( OSwitcha , IIsEvena )
211     
212     LSwitchBranchIsOddBranch = GraphSwitch_1_1_2.Link( OSwitchBranch , IIsOddBranch )
213     
214     LSwitchBranchIsEvenBranch = GraphSwitch_1_1_2.Link( OSwitchBranch , IIsEvenBranch )
215     
216     LSwitchDefaultEndOfSwitchDefault = GraphSwitch_1_1_2.Link( OSwitchDefault , IEndOfSwitchDefault )
217     
218     LEndOfSwitchaEndOfInitLoopSwitchIndex = GraphSwitch_1_1_2.Link( OEndOfSwitcha , IEndOfInitLoopSwitchIndex )
219     
220     LPrintaEndOfSwitcha = GraphSwitch_1_1_2.Link( OPrinta , IEndOfSwitcha )
221     
222     LPrint_1aEndOfSwitcha = GraphSwitch_1_1_2.Link( OPrint_1a , IEndOfSwitcha )
223     
224     # Input datas
225     IInitLoopSwitchIndex.Input( 0 )
226     IInitLoopSwitchMin.Input( -5 )
227     IInitLoopSwitchMax.Input( 10 )
228     
229     # Output Ports of the graph
230     #OEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetOutPort( 'Index' )
231     #OEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetOutPort( 'Min' )
232     #OEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetOutPort( 'Max' )
233     #OSwitchdefault = Switch.GetOutPort( 'default' )
234     #OPrintBranch = Print.GetOutPort( 'Branch' )
235     #OPrint_1Branch = Print_1.GetOutPort( 'Branch' )
236     return GraphSwitch_1_1_2
237
238
239 GraphSwitch_1_1_2 = DefGraphSwitch_1_1_2()