Salome HOME
Updated example graphs from Jean Rahuel. Mainly Switch nodes in the graphs were...
[modules/superv.git] / examples / GraphSwitchs.py
1
2 # Generated python file of Graph GraphSwitchs
3
4 from SuperV import *
5
6 # Graph creation of GraphSwitchs
7 def DefGraphSwitchs() :
8     GraphSwitchs = Graph( 'GraphSwitchs' )
9     GraphSwitchs.SetName( 'GraphSwitchs' )
10     GraphSwitchs.SetAuthor( '' )
11     GraphSwitchs.SetComment( '' )
12     GraphSwitchs.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 (GraphSwitchs)"      ' )
21     PyIsOdd.append( '    sleep( 1 )   ' )
22     PyIsOdd.append( '    return a     ' )
23     IsOdd = GraphSwitchs.INode( 'IsOdd' , PyIsOdd )
24     IsOdd.SetName( 'IsOdd' )
25     IsOdd.SetAuthor( '' )
26     IsOdd.SetComment( 'Python function' )
27     IsOdd.Coords( 388 , 50 )
28     IIsOdda = IsOdd.InPort( 'a' , 'long' )
29     IIsOddGate = IsOdd.GetInPort( 'Gate' )
30     OIsOdda = IsOdd.OutPort( 'a' , 'long' )
31     OIsOddGate = IsOdd.GetOutPort( 'Gate' )
32     
33     PyIsOdd_1 = []
34     PyIsOdd_1.append( 'from time import *   ' )
35     PyIsOdd_1.append( 'def IsOdd(a) :       ' )
36     PyIsOdd_1.append( '    print a,"IsOdd_1 (GraphSwitchs)"      ' )
37     PyIsOdd_1.append( '    sleep( 1 )   ' )
38     PyIsOdd_1.append( '    return a     ' )
39     IsOdd_1 = GraphSwitchs.INode( 'IsOdd' , PyIsOdd_1 )
40     IsOdd_1.SetName( 'IsOdd_1' )
41     IsOdd_1.SetAuthor( '' )
42     IsOdd_1.SetComment( 'Python function' )
43     IsOdd_1.Coords( 419 , 308 )
44     IIsOdd_1a = IsOdd_1.InPort( 'a' , 'long' )
45     IIsOdd_1Gate = IsOdd_1.GetInPort( 'Gate' )
46     OIsOdd_1a = IsOdd_1.OutPort( 'a' , 'long' )
47     OIsOdd_1Gate = IsOdd_1.GetOutPort( 'Gate' )
48     
49     # Creation of Loop Nodes
50     PyInitLoopSwitch = []
51     PyInitLoopSwitch.append( 'def InitLoop(Index,Min,Max) :      ' )
52     PyInitLoopSwitch.append( '  return Index,Min,Max     ' )
53     PyMoreInitLoopSwitch = []
54     PyMoreInitLoopSwitch.append( 'def MoreLoop(Index,Min,Max) :     ' )
55     PyMoreInitLoopSwitch.append( '      if Index <= Max :   ' )
56     PyMoreInitLoopSwitch.append( '              DoLoop = 1     ' )
57     PyMoreInitLoopSwitch.append( '      else :     ' )
58     PyMoreInitLoopSwitch.append( '              DoLoop = 0     ' )
59     PyMoreInitLoopSwitch.append( '      return DoLoop,Index,Min,Max     ' )
60     PyNextInitLoopSwitch = []
61     PyNextInitLoopSwitch.append( 'def NextLoop(Index,Min,Max) :     ' )
62     PyNextInitLoopSwitch.append( '      Index = Index + 1     ' )
63     PyNextInitLoopSwitch.append( '      return Index,Min,Max     ' )
64     InitLoopSwitch,EndOfInitLoopSwitch = GraphSwitchs.LNode( 'InitLoop' , PyInitLoopSwitch , 'MoreLoop' , PyMoreInitLoopSwitch , 'NextLoop' , PyNextInitLoopSwitch )
65     EndOfInitLoopSwitch.SetName( 'EndOfInitLoopSwitch' )
66     EndOfInitLoopSwitch.SetAuthor( '' )
67     EndOfInitLoopSwitch.SetComment( 'Compute Node' )
68     EndOfInitLoopSwitch.Coords( 766 , 127 )
69     PyEndOfInitLoopSwitch = []
70     EndOfInitLoopSwitch.SetPyFunction( '' , PyEndOfInitLoopSwitch )
71     IInitLoopSwitchDoLoop = InitLoopSwitch.GetInPort( 'DoLoop' )
72     IInitLoopSwitchIndex = InitLoopSwitch.InPort( 'Index' , 'long' )
73     IInitLoopSwitchMin = InitLoopSwitch.InPort( 'Min' , 'long' )
74     IInitLoopSwitchMax = InitLoopSwitch.InPort( 'Max' , 'long' )
75     IInitLoopSwitchGate = InitLoopSwitch.GetInPort( 'Gate' )
76     OInitLoopSwitchDoLoop = InitLoopSwitch.GetOutPort( 'DoLoop' )
77     OInitLoopSwitchIndex = InitLoopSwitch.GetOutPort( 'Index' )
78     OInitLoopSwitchMin = InitLoopSwitch.GetOutPort( 'Min' )
79     OInitLoopSwitchMax = InitLoopSwitch.GetOutPort( 'Max' )
80     IEndOfInitLoopSwitchDoLoop = EndOfInitLoopSwitch.GetInPort( 'DoLoop' )
81     IEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetInPort( 'Index' )
82     IEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetInPort( 'Min' )
83     IEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetInPort( 'Max' )
84     IEndOfInitLoopSwitchGate = EndOfInitLoopSwitch.GetInPort( 'Gate' )
85     OEndOfInitLoopSwitchDoLoop = EndOfInitLoopSwitch.GetOutPort( 'DoLoop' )
86     OEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetOutPort( 'Index' )
87     OEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetOutPort( 'Min' )
88     OEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetOutPort( 'Max' )
89     OEndOfInitLoopSwitchGate = EndOfInitLoopSwitch.GetOutPort( 'Gate' )
90     InitLoopSwitch.SetName( 'InitLoopSwitch' )
91     InitLoopSwitch.SetAuthor( '' )
92     InitLoopSwitch.SetComment( 'Compute Node' )
93     InitLoopSwitch.Coords( 10 , 129 )
94     
95     PyInitLoop = []
96     PyInitLoop.append( 'def InitLoop(Index,Min,Max) :      ' )
97     PyInitLoop.append( '        return Index,Min,Max     ' )
98     PyMoreInitLoop = []
99     PyMoreInitLoop.append( 'def MoreLoop(Index,Min,Max) :     ' )
100     PyMoreInitLoop.append( '    if Index <= Max :   ' )
101     PyMoreInitLoop.append( '            DoLoop = 1     ' )
102     PyMoreInitLoop.append( '    else :     ' )
103     PyMoreInitLoop.append( '            DoLoop = 0     ' )
104     PyMoreInitLoop.append( '    return DoLoop,Index,Min,Max     ' )
105     PyNextInitLoop = []
106     PyNextInitLoop.append( 'def NextLoop(Index,Min,Max) :     ' )
107     PyNextInitLoop.append( '    Index = Index + 1     ' )
108     PyNextInitLoop.append( '    return Index,Min,Max     ' )
109     InitLoop,EndOfInitLoop = GraphSwitchs.LNode( 'InitLoop' , PyInitLoop , 'MoreLoop' , PyMoreInitLoop , 'NextLoop' , PyNextInitLoop )
110     EndOfInitLoop.SetName( 'EndOfInitLoop' )
111     EndOfInitLoop.SetAuthor( '' )
112     EndOfInitLoop.SetComment( 'Compute Node' )
113     EndOfInitLoop.Coords( 783 , 381 )
114     PyEndOfInitLoop = []
115     EndOfInitLoop.SetPyFunction( '' , PyEndOfInitLoop )
116     IInitLoopDoLoop = InitLoop.GetInPort( 'DoLoop' )
117     IInitLoopIndex = InitLoop.InPort( 'Index' , 'long' )
118     IInitLoopMin = InitLoop.InPort( 'Min' , 'long' )
119     IInitLoopMax = InitLoop.InPort( 'Max' , 'long' )
120     IInitLoopGate = InitLoop.GetInPort( 'Gate' )
121     OInitLoopDoLoop = InitLoop.GetOutPort( 'DoLoop' )
122     OInitLoopIndex = InitLoop.GetOutPort( 'Index' )
123     OInitLoopMin = InitLoop.GetOutPort( 'Min' )
124     OInitLoopMax = InitLoop.GetOutPort( 'Max' )
125     IEndOfInitLoopDoLoop = EndOfInitLoop.GetInPort( 'DoLoop' )
126     IEndOfInitLoopIndex = EndOfInitLoop.GetInPort( 'Index' )
127     IEndOfInitLoopMin = EndOfInitLoop.GetInPort( 'Min' )
128     IEndOfInitLoopMax = EndOfInitLoop.GetInPort( 'Max' )
129     IEndOfInitLoopGate = EndOfInitLoop.GetInPort( 'Gate' )
130     OEndOfInitLoopDoLoop = EndOfInitLoop.GetOutPort( 'DoLoop' )
131     OEndOfInitLoopIndex = EndOfInitLoop.GetOutPort( 'Index' )
132     OEndOfInitLoopMin = EndOfInitLoop.GetOutPort( 'Min' )
133     OEndOfInitLoopMax = EndOfInitLoop.GetOutPort( 'Max' )
134     OEndOfInitLoopGate = EndOfInitLoop.GetOutPort( 'Gate' )
135     InitLoop.SetName( 'InitLoop' )
136     InitLoop.SetAuthor( '' )
137     InitLoop.SetComment( 'Compute Node' )
138     InitLoop.Coords( 10 , 388 )
139     
140     # Creation of Switch Nodes
141     PySwitch = []
142     PySwitch.append( 'from time import * ' )
143     PySwitch.append( 'def Switch(a) :   ' )
144     PySwitch.append( '    if ( a & 1 ) == 0 : ' )
145     PySwitch.append( '        sleep(1)    ' )
146     PySwitch.append( '    return a & 1,1-(a&1),a    ' )
147     Switch,EndOfSwitch = GraphSwitchs.SNode( 'Switch' , PySwitch )
148     EndOfSwitch.SetName( 'EndOfSwitch' )
149     EndOfSwitch.SetAuthor( '' )
150     EndOfSwitch.SetComment( 'Compute Node' )
151     EndOfSwitch.Coords( 587 , 126 )
152     PyEndOfSwitch = []
153     EndOfSwitch.SetPyFunction( '' , PyEndOfSwitch )
154     IEndOfSwitcha = EndOfSwitch.InPort( 'a' , 'long' )
155     IEndOfSwitchDefault = EndOfSwitch.GetInPort( 'Default' )
156     OEndOfSwitcha = EndOfSwitch.OutPort( 'a' , 'long' )
157     OEndOfSwitchGate = EndOfSwitch.GetOutPort( 'Gate' )
158     Switch.SetName( 'Switch' )
159     Switch.SetAuthor( '' )
160     Switch.SetComment( 'Compute Node' )
161     Switch.Coords( 186 , 130 )
162     ISwitcha = Switch.InPort( 'a' , 'long' )
163     ISwitchGate = Switch.GetInPort( 'Gate' )
164     OSwitchOdd = Switch.OutPort( 'Odd' , 'long' )
165     OSwitchEven = Switch.OutPort( 'Even' , 'int' )
166     OSwitcha = Switch.OutPort( 'a' , 'int' )
167     OSwitchDefault = Switch.GetOutPort( 'Default' )
168     
169     PySwitch_1 = []
170     PySwitch_1.append( 'from time import *  ' )
171     PySwitch_1.append( 'def Switch(a) :    ' )
172     PySwitch_1.append( '    if ( a & 1 ) == 0 :  ' )
173     PySwitch_1.append( '        sleep(1)  ' )
174     PySwitch_1.append( '    return a & 1,1-(a&1),a    ' )
175     Switch_1,EndSwitch = GraphSwitchs.SNode( 'Switch' , PySwitch_1 )
176     EndSwitch.SetName( 'EndSwitch' )
177     EndSwitch.SetAuthor( '' )
178     EndSwitch.SetComment( 'Compute Node' )
179     EndSwitch.Coords( 605 , 382 )
180     PyEndSwitch = []
181     EndSwitch.SetPyFunction( '' , PyEndSwitch )
182     IEndSwitcha = EndSwitch.InPort( 'a' , 'long' )
183     IEndSwitchDefault = EndSwitch.GetInPort( 'Default' )
184     OEndSwitcha = EndSwitch.OutPort( 'a' , 'long' )
185     OEndSwitchGate = EndSwitch.GetOutPort( 'Gate' )
186     Switch_1.SetName( 'Switch_1' )
187     Switch_1.SetAuthor( '' )
188     Switch_1.SetComment( 'Compute Node' )
189     Switch_1.Coords( 193 , 388 )
190     ISwitch_1a = Switch_1.InPort( 'a' , 'long' )
191     ISwitch_1Gate = Switch_1.GetInPort( 'Gate' )
192     OSwitch_1Odd = Switch_1.OutPort( 'Odd' , 'long' )
193     OSwitch_1Even = Switch_1.OutPort( 'Even' , 'int' )
194     OSwitch_1a = Switch_1.OutPort( 'a' , 'int' )
195     OSwitch_1Default = Switch_1.GetOutPort( 'Default' )
196     
197     # Creation of Links
198     LIsOddaEndOfSwitcha = GraphSwitchs.Link( OIsOdda , IEndOfSwitcha )
199     LIsOddaEndOfSwitcha.AddCoord( 1 , 573 , 160 )
200     LIsOddaEndOfSwitcha.AddCoord( 2 , 572 , 130 )
201     
202     LInitLoopSwitchIndexSwitcha = GraphSwitchs.Link( OInitLoopSwitchIndex , ISwitcha )
203     
204     LInitLoopSwitchMinEndOfInitLoopSwitchMin = GraphSwitchs.Link( OInitLoopSwitchMin , IEndOfInitLoopSwitchMin )
205     
206     LInitLoopSwitchMaxEndOfInitLoopSwitchMax = GraphSwitchs.Link( OInitLoopSwitchMax , IEndOfInitLoopSwitchMax )
207     
208     LSwitchOddIsOddGate = GraphSwitchs.Link( OSwitchOdd , IIsOddGate )
209     
210     LSwitchaIsOdda = GraphSwitchs.Link( OSwitcha , IIsOdda )
211     LSwitchaIsOdda.AddCoord( 1 , 365 , 129 )
212     LSwitchaIsOdda.AddCoord( 2 , 365 , 222 )
213     
214     LSwitchDefaultEndOfSwitchDefault = GraphSwitchs.Link( OSwitchDefault , IEndOfSwitchDefault )
215     LSwitchDefaultEndOfSwitchDefault.AddCoord( 1 , 572 , 194 )
216     LSwitchDefaultEndOfSwitchDefault.AddCoord( 2 , 571 , 257 )
217     
218     LEndOfSwitchaEndOfInitLoopSwitchIndex = GraphSwitchs.Link( OEndOfSwitcha , IEndOfInitLoopSwitchIndex )
219     
220     LIsOdd_1aEndSwitcha = GraphSwitchs.Link( OIsOdd_1a , IEndSwitcha )
221     LIsOdd_1aEndSwitcha.AddCoord( 1 , 599 , 416 )
222     LIsOdd_1aEndSwitcha.AddCoord( 2 , 598 , 389 )
223     
224     LInitLoopIndexSwitch_1a = GraphSwitchs.Link( OInitLoopIndex , ISwitch_1a )
225     
226     LInitLoopMinEndOfInitLoopMin = GraphSwitchs.Link( OInitLoopMin , IEndOfInitLoopMin )
227     
228     LInitLoopMaxEndOfInitLoopMax = GraphSwitchs.Link( OInitLoopMax , IEndOfInitLoopMax )
229     
230     LSwitch_1OddIsOdd_1Gate = GraphSwitchs.Link( OSwitch_1Odd , IIsOdd_1Gate )
231     
232     LSwitch_1EvenEndSwitchDefault = GraphSwitchs.Link( OSwitch_1Even , IEndSwitchDefault )
233     
234     LSwitch_1aIsOdd_1a = GraphSwitchs.Link( OSwitch_1a , IIsOdd_1a )
235     LSwitch_1aIsOdd_1a.AddCoord( 1 , 379 , 387 )
236     LSwitch_1aIsOdd_1a.AddCoord( 2 , 378 , 481 )
237     
238     LEndSwitchaEndOfInitLoopIndex = GraphSwitchs.Link( OEndSwitcha , IEndOfInitLoopIndex )
239     
240     # Input datas
241     IInitLoopSwitchIndex.Input( 0 )
242     IInitLoopSwitchMin.Input( 0 )
243     IInitLoopSwitchMax.Input( 20 )
244     IInitLoopIndex.Input( 0 )
245     IInitLoopMin.Input( 0 )
246     IInitLoopMax.Input( 20 )
247     
248     # Output Ports of the graph
249     #OEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetOutPort( 'Index' )
250     #OEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetOutPort( 'Min' )
251     #OEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetOutPort( 'Max' )
252     #OSwitchEven = Switch.GetOutPort( 'Even' )
253     #OEndOfInitLoopIndex = EndOfInitLoop.GetOutPort( 'Index' )
254     #OEndOfInitLoopMin = EndOfInitLoop.GetOutPort( 'Min' )
255     #OEndOfInitLoopMax = EndOfInitLoop.GetOutPort( 'Max' )
256     return GraphSwitchs
257
258
259 GraphSwitchs = DefGraphSwitchs()