Salome HOME
Fix for improvement IPAL9815 : Remove "Add Port" functionality as duplicate of "Edit...
[modules/superv.git] / examples / GraphSwitchBranchGates1.py
1
2 # Generated python file of Graph GraphSwitchBranchGates1
3
4 from SuperV import *
5
6 # Graph creation of GraphSwitchBranchGates1
7 def DefGraphSwitchBranchGates1() :
8     GraphSwitchBranchGates1 = Graph( 'GraphSwitchBranchGates1' )
9     GraphSwitchBranchGates1.SetName( 'GraphSwitchBranchGates1' )
10     GraphSwitchBranchGates1.SetAuthor( 'JR' )
11     GraphSwitchBranchGates1.SetComment( '' )
12     GraphSwitchBranchGates1.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 (GraphSwitch1)"      ' )
21     PyIsOdd.append( '    sleep( 1 )   ' )
22     PyIsOdd.append( '    return a     ' )
23     IsOdd = GraphSwitchBranchGates1.INode( 'IsOdd' , PyIsOdd )
24     IsOdd.SetName( 'IsOdd' )
25     IsOdd.SetAuthor( '' )
26     IsOdd.SetComment( 'Python function' )
27     IsOdd.Coords( 389 , 65 )
28     IIsOdda = IsOdd.InPort( 'a' , 'long' )
29     IIsOddGate = IsOdd.GetInPort( 'Gate' )
30     OIsOdda = IsOdd.OutPort( 'a' , 'long' )
31     OIsOddGate = IsOdd.GetOutPort( 'Gate' )
32     
33     # Creation of Loop Nodes
34     PyInitLoop = []
35     PyInitLoop.append( 'def InitLoop(Index,Min,Max) : ' )
36     PyInitLoop.append( '    Index = Max ' )
37     PyInitLoop.append( '    return Index,Min,Max      ' )
38     PyMoreInitLoop = []
39     PyMoreInitLoop.append( 'def MoreLoop(Index,Min,Max) :      ' )
40     PyMoreInitLoop.append( '    if Index >= Min :    ' )
41     PyMoreInitLoop.append( '            DoLoop = 1      ' )
42     PyMoreInitLoop.append( '    else :      ' )
43     PyMoreInitLoop.append( '            DoLoop = 0      ' )
44     PyMoreInitLoop.append( '    return DoLoop,Index,Min,Max      ' )
45     PyNextInitLoop = []
46     PyNextInitLoop.append( 'def NextLoop(Index,Min,Max) :      ' )
47     PyNextInitLoop.append( '    Index = Index - 1      ' )
48     PyNextInitLoop.append( '    return Index,Min,Max      ' )
49     InitLoop,EndOfInitLoop = GraphSwitchBranchGates1.LNode( 'InitLoop' , PyInitLoop , 'MoreLoop' , PyMoreInitLoop , 'NextLoop' , PyNextInitLoop )
50     EndOfInitLoop.SetName( 'EndOfInitLoop' )
51     EndOfInitLoop.SetAuthor( '' )
52     EndOfInitLoop.SetComment( 'Compute Node' )
53     EndOfInitLoop.Coords( 777 , 170 )
54     PyEndOfInitLoop = []
55     EndOfInitLoop.SetPyFunction( '' , PyEndOfInitLoop )
56     IInitLoopDoLoop = InitLoop.GetInPort( 'DoLoop' )
57     IInitLoopIndex = InitLoop.InPort( 'Index' , 'long' )
58     IInitLoopMin = InitLoop.InPort( 'Min' , 'long' )
59     IInitLoopMax = InitLoop.InPort( 'Max' , 'long' )
60     IInitLoopGate = InitLoop.GetInPort( 'Gate' )
61     OInitLoopDoLoop = InitLoop.GetOutPort( 'DoLoop' )
62     OInitLoopIndex = InitLoop.GetOutPort( 'Index' )
63     OInitLoopMin = InitLoop.GetOutPort( 'Min' )
64     OInitLoopMax = InitLoop.GetOutPort( 'Max' )
65     IEndOfInitLoopDoLoop = EndOfInitLoop.GetInPort( 'DoLoop' )
66     IEndOfInitLoopIndex = EndOfInitLoop.GetInPort( 'Index' )
67     IEndOfInitLoopMin = EndOfInitLoop.GetInPort( 'Min' )
68     IEndOfInitLoopMax = EndOfInitLoop.GetInPort( 'Max' )
69     IEndOfInitLoopGate = EndOfInitLoop.GetInPort( 'Gate' )
70     OEndOfInitLoopDoLoop = EndOfInitLoop.GetOutPort( 'DoLoop' )
71     OEndOfInitLoopIndex = EndOfInitLoop.GetOutPort( 'Index' )
72     OEndOfInitLoopMin = EndOfInitLoop.GetOutPort( 'Min' )
73     OEndOfInitLoopMax = EndOfInitLoop.GetOutPort( 'Max' )
74     OEndOfInitLoopGate = EndOfInitLoop.GetOutPort( 'Gate' )
75     InitLoop.SetName( 'InitLoop' )
76     InitLoop.SetAuthor( '' )
77     InitLoop.SetComment( 'Compute Node' )
78     InitLoop.Coords( 10 , 129 )
79     
80     # Creation of Switch Nodes
81     PySwitch = []
82     PySwitch.append( 'from time import *    ' )
83     PySwitch.append( 'def Switch(a) :  ' )
84     PySwitch.append( '    if a <= 0 :  ' )
85     PySwitch.append( '        sleep(1) ' )
86     PySwitch.append( '        return 0,0,a  ' )
87     PySwitch.append( '    if ( a & 1 ) == 0 :    ' )
88     PySwitch.append( '        sleep(1)    ' )
89     PySwitch.append( '    return a & 1,1-(a&1),a      ' )
90     Switch,EndOfSwitch = GraphSwitchBranchGates1.SNode( 'Switch' , PySwitch )
91     EndOfSwitch.SetName( 'EndOfSwitch' )
92     EndOfSwitch.SetAuthor( '' )
93     EndOfSwitch.SetComment( 'Compute Node' )
94     EndOfSwitch.Coords( 589 , 170 )
95     PyEndOfSwitch = []
96     EndOfSwitch.SetPyFunction( '' , PyEndOfSwitch )
97     IEndOfSwitcha = EndOfSwitch.InPort( 'a' , 'long' )
98     IEndOfSwitchDefault = EndOfSwitch.GetInPort( 'Default' )
99     OEndOfSwitcha = EndOfSwitch.OutPort( 'a' , 'long' )
100     OEndOfSwitchGate = EndOfSwitch.GetOutPort( 'Gate' )
101     Switch.SetName( 'Switch' )
102     Switch.SetAuthor( '' )
103     Switch.SetComment( 'Compute Node' )
104     Switch.Coords( 195 , 130 )
105     ISwitcha = Switch.InPort( 'a' , 'long' )
106     ISwitchGate = Switch.GetInPort( 'Gate' )
107     OSwitchOdd = Switch.OutPort( 'Odd' , 'long' )
108     OSwitchEven = Switch.OutPort( 'Even' , 'int' )
109     OSwitcha = Switch.OutPort( 'a' , 'int' )
110     OSwitchDefault = Switch.GetOutPort( 'Default' )
111     
112     # Creation of Links
113     LIsOddaEndOfSwitcha = GraphSwitchBranchGates1.Link( OIsOdda , IEndOfSwitcha )
114     LIsOddaEndOfSwitcha.AddCoord( 1 , 571 , 201 )
115     LIsOddaEndOfSwitcha.AddCoord( 2 , 571 , 136 )
116     
117     LIsOddGateEndOfSwitchDefault = GraphSwitchBranchGates1.Link( OIsOddGate , IEndOfSwitchDefault )
118     
119     LInitLoopIndexSwitcha = GraphSwitchBranchGates1.Link( OInitLoopIndex , ISwitcha )
120     
121     LInitLoopMinEndOfInitLoopMin = GraphSwitchBranchGates1.Link( OInitLoopMin , IEndOfInitLoopMin )
122     
123     LInitLoopMaxEndOfInitLoopMax = GraphSwitchBranchGates1.Link( OInitLoopMax , IEndOfInitLoopMax )
124     
125     LSwitchOddIsOddGate = GraphSwitchBranchGates1.Link( OSwitchOdd , IIsOddGate )
126     
127     LSwitchEvenEndOfSwitchDefault = GraphSwitchBranchGates1.Link( OSwitchEven , IEndOfSwitchDefault )
128     
129     LSwitchaIsOdda = GraphSwitchBranchGates1.Link( OSwitcha , IIsOdda )
130     LSwitchaIsOdda.AddCoord( 1 , 375 , 136 )
131     LSwitchaIsOdda.AddCoord( 2 , 375 , 201 )
132     
133     LSwitchDefaultEndOfSwitchDefault = GraphSwitchBranchGates1.Link( OSwitchDefault , IEndOfSwitchDefault )
134     
135     LEndOfSwitchaEndOfInitLoopIndex = GraphSwitchBranchGates1.Link( OEndOfSwitcha , IEndOfInitLoopIndex )
136     
137     # Input datas
138     IInitLoopIndex.Input( 0 )
139     IInitLoopMin.Input( -5 )
140     IInitLoopMax.Input( 23 )
141     
142     # Output Ports of the graph
143     #OEndOfInitLoopIndex = EndOfInitLoop.GetOutPort( 'Index' )
144     #OEndOfInitLoopMin = EndOfInitLoop.GetOutPort( 'Min' )
145     #OEndOfInitLoopMax = EndOfInitLoop.GetOutPort( 'Max' )
146     return GraphSwitchBranchGates1
147
148
149 GraphSwitchBranchGates1 = DefGraphSwitchBranchGates1()