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