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