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