Salome HOME
Many new examples specially for test of Switches
[modules/superv.git] / examples / GraphSwitchCheckBranch1Default.py
1
2 # Generated python file of Graph GraphSwitchCheckBranch1Default
3
4 from SuperV import *
5
6 # Graph creation of GraphSwitchCheckBranch1Default
7 def DefGraphSwitchCheckBranch1Default() :
8     GraphSwitchCheckBranch1Default = Graph( 'GraphSwitchCheckBranch1Default' )
9     GraphSwitchCheckBranch1Default.SetName( 'GraphSwitchCheckBranch1Default' )
10     GraphSwitchCheckBranch1Default.SetAuthor( 'JR' )
11     GraphSwitchCheckBranch1Default.SetComment( 'Switch with two SwitchBranches, One NotSwitchBranch and the DefaultBranch' )
12     GraphSwitchCheckBranch1Default.Coords( 0 , 0 )
13     
14     # Creation of Factory Nodes
15     
16     # Creation of InLine Nodes
17     PyIsOdd = []
18     PyIsOdd.append( 'from time import *   ' )
19     PyIsOdd.append( 'def IsOdd(a) :       ' )
20     PyIsOdd.append( '    print a,"IsOdd (GraphSwitch)"      ' )
21     PyIsOdd.append( '    sleep( 1 )   ' )
22     PyIsOdd.append( '    return a     ' )
23     IsOdd = GraphSwitchCheckBranch1Default.INode( 'IsOdd' , PyIsOdd )
24     IsOdd.SetName( 'IsOdd' )
25     IsOdd.SetAuthor( '' )
26     IsOdd.SetComment( 'Python function' )
27     IsOdd.Coords( 415 , 7 )
28     IIsOdda = IsOdd.InPort( 'a' , 'long' )
29     IIsOddGate = IsOdd.GetInPort( 'Gate' )
30     OIsOdda = IsOdd.OutPort( 'a' , 'long' )
31     OIsOddGate = IsOdd.GetOutPort( 'Gate' )
32     
33     PyIsEven = []
34     PyIsEven.append( 'from time import *    ' )
35     PyIsEven.append( 'def IsEven(a) :        ' )
36     PyIsEven.append( '    print a,"IsEven (GraphSwitch)"       ' )
37     PyIsEven.append( '    sleep( 1 )    ' )
38     PyIsEven.append( '    return a      ' )
39     IsEven = GraphSwitchCheckBranch1Default.INode( 'IsEven' , PyIsEven )
40     IsEven.SetName( 'IsEven' )
41     IsEven.SetAuthor( '' )
42     IsEven.SetComment( 'Compute Node' )
43     IsEven.Coords( 421 , 438 )
44     IIsEvena = IsEven.InPort( 'a' , 'long' )
45     IIsEvenGate = IsEven.GetInPort( 'Gate' )
46     OIsEvena = IsEven.OutPort( 'a' , 'long' )
47     OIsEvenGate = IsEven.GetOutPort( 'Gate' )
48     
49     PyBranchNode = []
50     PyBranchNode.append( 'from time import *  ' )
51     PyBranchNode.append( 'def Print_1(Branch) :      ' )
52     PyBranchNode.append( '    print "Print ",Branch  ' )
53     PyBranchNode.append( '    sleep(1)  ' )
54     PyBranchNode.append( '    return Branch      ' )
55     BranchNode = GraphSwitchCheckBranch1Default.INode( 'Print_1' , PyBranchNode )
56     BranchNode.SetName( 'BranchNode' )
57     BranchNode.SetAuthor( '' )
58     BranchNode.SetComment( 'Compute Node' )
59     BranchNode.Coords( 529 , 177 )
60     IBranchNodeBranch = BranchNode.InPort( 'Branch' , 'string' )
61     IBranchNodeGate = BranchNode.GetInPort( 'Gate' )
62     OBranchNodeBranch = BranchNode.OutPort( 'Branch' , 'string' )
63     OBranchNodeGate = BranchNode.GetOutPort( 'Gate' )
64     
65     Pydefault = []
66     Pydefault.append( 'from time import * ' )
67     Pydefault.append( 'def default(a) : ' )
68     Pydefault.append( '    sleep(1) ' )
69     Pydefault.append( '    return a  ' )
70     default = GraphSwitchCheckBranch1Default.INode( 'default' , Pydefault )
71     default.SetName( 'default' )
72     default.SetAuthor( '' )
73     default.SetComment( 'Compute Node' )
74     default.Coords( 428 , 308 )
75     Idefaulta = default.InPort( 'a' , 'long' )
76     IdefaultGate = default.GetInPort( 'Gate' )
77     Odefaulta = default.OutPort( 'a' , 'long' )
78     OdefaultGate = default.GetOutPort( 'Gate' )
79     
80     # Creation of Loop Nodes
81     PyInitLoopSwitch = []
82     PyInitLoopSwitch.append( 'def InitLoop(Index,Min,Max) :        ' )
83     PyInitLoopSwitch.append( '  Index = Max  ' )
84     PyInitLoopSwitch.append( '  return Index,Min,Max       ' )
85     PyMoreInitLoopSwitch = []
86     PyMoreInitLoopSwitch.append( 'from time import * ' )
87     PyMoreInitLoopSwitch.append( 'def MoreLoop(Index,Min,Max) : ' )
88     PyMoreInitLoopSwitch.append( '      sleep(1)  ' )
89     PyMoreInitLoopSwitch.append( '      if Index >= Min :     ' )
90     PyMoreInitLoopSwitch.append( '              DoLoop = 1       ' )
91     PyMoreInitLoopSwitch.append( '      else :       ' )
92     PyMoreInitLoopSwitch.append( '              DoLoop = 0       ' )
93     PyMoreInitLoopSwitch.append( '      return DoLoop,Index,Min,Max       ' )
94     PyNextInitLoopSwitch = []
95     PyNextInitLoopSwitch.append( 'def NextLoop(Index,Min,Max) :       ' )
96     PyNextInitLoopSwitch.append( '      Index = Index - 1       ' )
97     PyNextInitLoopSwitch.append( '      return Index,Min,Max       ' )
98     InitLoopSwitch,EndOfInitLoopSwitch = GraphSwitchCheckBranch1Default.LNode( 'InitLoop' , PyInitLoopSwitch , 'MoreLoop' , PyMoreInitLoopSwitch , 'NextLoop' , PyNextInitLoopSwitch )
99     EndOfInitLoopSwitch.SetName( 'EndOfInitLoopSwitch' )
100     EndOfInitLoopSwitch.SetAuthor( '' )
101     EndOfInitLoopSwitch.SetComment( 'Compute Node' )
102     EndOfInitLoopSwitch.Coords( 1073 , 216 )
103     PyEndOfInitLoopSwitch = []
104     PyEndOfInitLoopSwitch.append( 'from time import *  ' )
105     PyEndOfInitLoopSwitch.append( 'def EndOfInitLoopSwitch(DoLoop,Index,Min,Max) :  ' )
106     PyEndOfInitLoopSwitch.append( '    sleep(1)  ' )
107     PyEndOfInitLoopSwitch.append( '    return DoLoop,Index,Min,Max  ' )
108     EndOfInitLoopSwitch.SetPyFunction( 'EndOfInitLoopSwitch' , PyEndOfInitLoopSwitch )
109     IInitLoopSwitchDoLoop = InitLoopSwitch.GetInPort( 'DoLoop' )
110     IInitLoopSwitchIndex = InitLoopSwitch.InPort( 'Index' , 'long' )
111     IInitLoopSwitchMin = InitLoopSwitch.InPort( 'Min' , 'long' )
112     IInitLoopSwitchMax = InitLoopSwitch.InPort( 'Max' , 'long' )
113     IInitLoopSwitchGate = InitLoopSwitch.GetInPort( 'Gate' )
114     OInitLoopSwitchDoLoop = InitLoopSwitch.GetOutPort( 'DoLoop' )
115     OInitLoopSwitchIndex = InitLoopSwitch.GetOutPort( 'Index' )
116     OInitLoopSwitchMin = InitLoopSwitch.GetOutPort( 'Min' )
117     OInitLoopSwitchMax = InitLoopSwitch.GetOutPort( 'Max' )
118     IEndOfInitLoopSwitchDoLoop = EndOfInitLoopSwitch.GetInPort( 'DoLoop' )
119     IEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetInPort( 'Index' )
120     IEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetInPort( 'Min' )
121     IEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetInPort( 'Max' )
122     IEndOfInitLoopSwitchGate = EndOfInitLoopSwitch.GetInPort( 'Gate' )
123     OEndOfInitLoopSwitchDoLoop = EndOfInitLoopSwitch.GetOutPort( 'DoLoop' )
124     OEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetOutPort( 'Index' )
125     OEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetOutPort( 'Min' )
126     OEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetOutPort( 'Max' )
127     OEndOfInitLoopSwitchGate = EndOfInitLoopSwitch.GetOutPort( 'Gate' )
128     InitLoopSwitch.SetName( 'InitLoopSwitch' )
129     InitLoopSwitch.SetAuthor( '' )
130     InitLoopSwitch.SetComment( 'Compute Node' )
131     InitLoopSwitch.Coords( 10 , 157 )
132     
133     # Creation of Switch Nodes
134     PySwitch = []
135     PySwitch.append( 'from time import *         ' )
136     PySwitch.append( 'def Switch(a) :  ' )
137     PySwitch.append( '    sleep(1)  ' )
138     PySwitch.append( '    Branch = "Negative or null"     ' )
139     PySwitch.append( '    if a <= 0 : ' )
140     PySwitch.append( '        if ( a & 1 ) == 0 : ' )
141     PySwitch.append( '            return 0,0,a,Branch,1 ' )
142     PySwitch.append( '        else : ' )
143     PySwitch.append( '            return 0,0,a,Branch,0 ' )
144     PySwitch.append( '    if ( a & 1 ) == 0 :     ' )
145     PySwitch.append( '        Branch = "Even"     ' )
146     PySwitch.append( '    else :     ' )
147     PySwitch.append( '        Branch = "Odd"     ' )
148     PySwitch.append( '    return a & 1,1-(a&1),a,Branch,0   ' )
149     Switch,EndOfSwitch = GraphSwitchCheckBranch1Default.SNode( 'Switch' , PySwitch )
150     EndOfSwitch.SetName( 'EndOfSwitch' )
151     EndOfSwitch.SetAuthor( '' )
152     EndOfSwitch.SetComment( 'Compute Node' )
153     EndOfSwitch.Coords( 880 , 216 )
154     PyEndOfSwitch = []
155     PyEndOfSwitch.append( 'from time import * ' )
156     PyEndOfSwitch.append( 'def EndOfSwitch(a,Branch) : ' )
157     PyEndOfSwitch.append( '    sleep(1) ' )
158     PyEndOfSwitch.append( '    return a ' )
159     EndOfSwitch.SetPyFunction( 'EndOfSwitch' , PyEndOfSwitch )
160     IEndOfSwitcha = EndOfSwitch.InPort( 'a' , 'long' )
161     IEndOfSwitchBranch = EndOfSwitch.InPort( 'Branch' , 'string' )
162     IEndOfSwitchDefault = EndOfSwitch.GetInPort( 'Default' )
163     OEndOfSwitcha = EndOfSwitch.OutPort( 'a' , 'long' )
164     OEndOfSwitchGate = EndOfSwitch.GetOutPort( 'Gate' )
165     Switch.SetName( 'Switch' )
166     Switch.SetAuthor( '' )
167     Switch.SetComment( 'Compute Node' )
168     Switch.Coords( 194 , 157 )
169     ISwitcha = Switch.InPort( 'a' , 'long' )
170     ISwitchGate = Switch.GetInPort( 'Gate' )
171     OSwitchOdd = Switch.OutPort( 'Odd' , 'long' )
172     OSwitchEven = Switch.OutPort( 'Even' , 'int' )
173     OSwitcha = Switch.OutPort( 'a' , 'int' )
174     OSwitchBranch = Switch.OutPort( 'Branch' , 'string' )
175     OSwitchdefault = Switch.OutPort( 'default' , 'boolean' )
176     OSwitchDefault = Switch.GetOutPort( 'Default' )
177     
178     # Creation of Links
179     LIsOddaEndOfSwitcha = GraphSwitchCheckBranch1Default.Link( OIsOdda , IEndOfSwitcha )
180     
181     LIsEvenaEndOfSwitcha = GraphSwitchCheckBranch1Default.Link( OIsEvena , IEndOfSwitcha )
182     
183     LBranchNodeBranchEndOfSwitchBranch = GraphSwitchCheckBranch1Default.Link( OBranchNodeBranch , IEndOfSwitchBranch )
184     
185     LInitLoopSwitchIndexSwitcha = GraphSwitchCheckBranch1Default.Link( OInitLoopSwitchIndex , ISwitcha )
186     
187     LInitLoopSwitchMinEndOfInitLoopSwitchMin = GraphSwitchCheckBranch1Default.Link( OInitLoopSwitchMin , IEndOfInitLoopSwitchMin )
188     
189     LInitLoopSwitchMaxEndOfInitLoopSwitchMax = GraphSwitchCheckBranch1Default.Link( OInitLoopSwitchMax , IEndOfInitLoopSwitchMax )
190     
191     LSwitchOddIsOddGate = GraphSwitchCheckBranch1Default.Link( OSwitchOdd , IIsOddGate )
192     LSwitchOddIsOddGate.AddCoord( 1 , 401 , 101 )
193     LSwitchOddIsOddGate.AddCoord( 2 , 401 , 188 )
194     
195     LSwitchEvenIsEvenGate = GraphSwitchCheckBranch1Default.Link( OSwitchEven , IIsEvenGate )
196     LSwitchEvenIsEvenGate.AddCoord( 1 , 392 , 533 )
197     LSwitchEvenIsEvenGate.AddCoord( 2 , 392 , 208 )
198     
199     LSwitchaIsOdda = GraphSwitchCheckBranch1Default.Link( OSwitcha , IIsOdda )
200     LSwitchaIsOdda.AddCoord( 1 , 382 , 78 )
201     LSwitchaIsOdda.AddCoord( 2 , 382 , 229 )
202     
203     LSwitchaIsEvena = GraphSwitchCheckBranch1Default.Link( OSwitcha , IIsEvena )
204     LSwitchaIsEvena.AddCoord( 1 , 381 , 509 )
205     LSwitchaIsEvena.AddCoord( 2 , 381 , 229 )
206     
207     LSwitchadefaulta = GraphSwitchCheckBranch1Default.Link( OSwitcha , Idefaulta )
208     LSwitchadefaulta.AddCoord( 1 , 382 , 377 )
209     LSwitchadefaulta.AddCoord( 2 , 382 , 228 )
210     
211     LSwitchBranchBranchNodeBranch = GraphSwitchCheckBranch1Default.Link( OSwitchBranch , IBranchNodeBranch )
212     
213     LSwitchdefaultdefaultGate = GraphSwitchCheckBranch1Default.Link( OSwitchdefault , IdefaultGate )
214     LSwitchdefaultdefaultGate.AddCoord( 1 , 410 , 403 )
215     LSwitchdefaultdefaultGate.AddCoord( 2 , 410 , 269 )
216     LSwitchdefaultdefaultGate.AddCoord( 3 , 410 , 268 )
217     
218     LSwitchDefaultEndOfSwitchDefault = GraphSwitchCheckBranch1Default.Link( OSwitchDefault , IEndOfSwitchDefault )
219     
220     LEndOfSwitchaEndOfInitLoopSwitchIndex = GraphSwitchCheckBranch1Default.Link( OEndOfSwitcha , IEndOfInitLoopSwitchIndex )
221     
222     LdefaultaEndOfSwitcha = GraphSwitchCheckBranch1Default.Link( Odefaulta , 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     return GraphSwitchCheckBranch1Default
234
235
236 GraphSwitchCheckBranch1Default = DefGraphSwitchCheckBranch1Default()