Salome HOME
Fix for bug IPAL9983 : Object browser is not updated after dataflow run.
[modules/superv.git] / examples / GraphSwitch2.py
1
2 # Generated python file of Graph GraphSwitch_1_1
3
4 from SuperV import *
5
6 # Graph creation of GraphSwitch_1_1
7 def DefGraphSwitch_1_1() :
8     GraphSwitch_1_1 = Graph( 'GraphSwitch_1_1' )
9     GraphSwitch_1_1.SetName( 'GraphSwitch_1_1' )
10     GraphSwitch_1_1.SetAuthor( '' )
11     GraphSwitch_1_1.SetComment( '' )
12     GraphSwitch_1_1.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 = GraphSwitch_1_1.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     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 = GraphSwitch_1_1.INode( 'IsEven' , PyIsEven )
40     IsEven.SetName( 'IsEven' )
41     IsEven.SetAuthor( '' )
42     IsEven.SetComment( 'Compute Node' )
43     IsEven.Coords( 397 , 279 )
44     IIsEvena = IsEven.InPort( 'a' , 'long' )
45     IIsEvenGate = IsEven.GetInPort( 'Gate' )
46     OIsEvena = IsEven.OutPort( 'a' , 'long' )
47     OIsEvenGate = IsEven.GetOutPort( 'Gate' )
48     
49     # Creation of Loop Nodes
50     PyInitLoopSwitch = []
51     PyInitLoopSwitch.append( 'def InitLoop(Index,Min,Max) :       ' )
52     PyInitLoopSwitch.append( '  Index = Max ' )
53     PyInitLoopSwitch.append( '  return Index,Min,Max      ' )
54     PyMoreInitLoopSwitch = []
55     PyMoreInitLoopSwitch.append( 'def MoreLoop(Index,Min,Max) :      ' )
56     PyMoreInitLoopSwitch.append( '      if Index >= Min :    ' )
57     PyMoreInitLoopSwitch.append( '              DoLoop = 1      ' )
58     PyMoreInitLoopSwitch.append( '      else :      ' )
59     PyMoreInitLoopSwitch.append( '              DoLoop = 0      ' )
60     PyMoreInitLoopSwitch.append( '      return DoLoop,Index,Min,Max      ' )
61     PyNextInitLoopSwitch = []
62     PyNextInitLoopSwitch.append( 'def NextLoop(Index,Min,Max) :      ' )
63     PyNextInitLoopSwitch.append( '      Index = Index - 1      ' )
64     PyNextInitLoopSwitch.append( '      return Index,Min,Max      ' )
65     InitLoopSwitch,EndOfInitLoopSwitch = GraphSwitch_1_1.LNode( 'InitLoop' , PyInitLoopSwitch , 'MoreLoop' , PyMoreInitLoopSwitch , 'NextLoop' , PyNextInitLoopSwitch )
66     EndOfInitLoopSwitch.SetName( 'EndOfInitLoopSwitch' )
67     EndOfInitLoopSwitch.SetAuthor( '' )
68     EndOfInitLoopSwitch.SetComment( 'Compute Node' )
69     EndOfInitLoopSwitch.Coords( 775 , 169 )
70     PyEndOfInitLoopSwitch = []
71     EndOfInitLoopSwitch.SetPyFunction( '' , PyEndOfInitLoopSwitch )
72     IInitLoopSwitchDoLoop = InitLoopSwitch.GetInPort( 'DoLoop' )
73     IInitLoopSwitchIndex = InitLoopSwitch.InPort( 'Index' , 'long' )
74     IInitLoopSwitchMin = InitLoopSwitch.InPort( 'Min' , 'long' )
75     IInitLoopSwitchMax = InitLoopSwitch.InPort( 'Max' , 'long' )
76     IInitLoopSwitchGate = InitLoopSwitch.GetInPort( 'Gate' )
77     OInitLoopSwitchDoLoop = InitLoopSwitch.GetOutPort( 'DoLoop' )
78     OInitLoopSwitchIndex = InitLoopSwitch.GetOutPort( 'Index' )
79     OInitLoopSwitchMin = InitLoopSwitch.GetOutPort( 'Min' )
80     OInitLoopSwitchMax = InitLoopSwitch.GetOutPort( 'Max' )
81     IEndOfInitLoopSwitchDoLoop = EndOfInitLoopSwitch.GetInPort( 'DoLoop' )
82     IEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetInPort( 'Index' )
83     IEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetInPort( 'Min' )
84     IEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetInPort( 'Max' )
85     IEndOfInitLoopSwitchGate = EndOfInitLoopSwitch.GetInPort( 'Gate' )
86     OEndOfInitLoopSwitchDoLoop = EndOfInitLoopSwitch.GetOutPort( 'DoLoop' )
87     OEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetOutPort( 'Index' )
88     OEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetOutPort( 'Min' )
89     OEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetOutPort( 'Max' )
90     OEndOfInitLoopSwitchGate = EndOfInitLoopSwitch.GetOutPort( 'Gate' )
91     InitLoopSwitch.SetName( 'InitLoopSwitch' )
92     InitLoopSwitch.SetAuthor( '' )
93     InitLoopSwitch.SetComment( 'Compute Node' )
94     InitLoopSwitch.Coords( 10 , 129 )
95     
96     # Creation of Switch Nodes
97     PySwitch = []
98     PySwitch.append( 'from time import *     ' )
99     PySwitch.append( 'def Switch(a) : ' )
100     PySwitch.append( '    sleep(1) ' )
101     PySwitch.append( '    if a <= 0 :    ' )
102     PySwitch.append( '        return 0,0,a    ' )
103     PySwitch.append( '    return a & 1,1-(a&1),a        ' )
104     Switch,EndOfSwitch = GraphSwitch_1_1.SNode( 'Switch' , PySwitch )
105     EndOfSwitch.SetName( 'EndOfSwitch' )
106     EndOfSwitch.SetAuthor( '' )
107     EndOfSwitch.SetComment( 'Compute Node' )
108     EndOfSwitch.Coords( 583 , 169 )
109     PyEndOfSwitch = []
110     EndOfSwitch.SetPyFunction( 'EndSwitch_1' , PyEndOfSwitch )
111     IEndOfSwitcha = EndOfSwitch.InPort( 'a' , 'long' )
112     IEndOfSwitchDefault = EndOfSwitch.GetInPort( 'Default' )
113     OEndOfSwitcha = EndOfSwitch.OutPort( 'a' , 'long' )
114     OEndOfSwitchGate = EndOfSwitch.GetOutPort( 'Gate' )
115     Switch.SetName( 'Switch' )
116     Switch.SetAuthor( '' )
117     Switch.SetComment( 'Compute Node' )
118     Switch.Coords( 195 , 129 )
119     ISwitcha = Switch.InPort( 'a' , 'long' )
120     ISwitchGate = Switch.GetInPort( 'Gate' )
121     OSwitchOdd = Switch.OutPort( 'Odd' , 'long' )
122     OSwitchEven = Switch.OutPort( 'Even' , 'int' )
123     OSwitcha = Switch.OutPort( 'a' , 'int' )
124     OSwitchDefault = Switch.GetOutPort( 'Default' )
125     
126     # Creation of Links
127     LIsOddaEndOfSwitcha = GraphSwitch_1_1.Link( OIsOdda , IEndOfSwitcha )
128     
129     LInitLoopSwitchIndexSwitcha = GraphSwitch_1_1.Link( OInitLoopSwitchIndex , ISwitcha )
130     
131     LInitLoopSwitchMinEndOfInitLoopSwitchMin = GraphSwitch_1_1.Link( OInitLoopSwitchMin , IEndOfInitLoopSwitchMin )
132     
133     LInitLoopSwitchMaxEndOfInitLoopSwitchMax = GraphSwitch_1_1.Link( OInitLoopSwitchMax , IEndOfInitLoopSwitchMax )
134     
135     LIsEvenaEndOfSwitcha = GraphSwitch_1_1.Link( OIsEvena , IEndOfSwitcha )
136     
137     LSwitchOddIsOddGate = GraphSwitch_1_1.Link( OSwitchOdd , IIsOddGate )
138     
139     LSwitchEvenIsEvenGate = GraphSwitch_1_1.Link( OSwitchEven , IIsEvenGate )
140     
141     LSwitchaIsOdda = GraphSwitch_1_1.Link( OSwitcha , IIsOdda )
142     
143     LSwitchaIsEvena = GraphSwitch_1_1.Link( OSwitcha , IIsEvena )
144     
145     LSwitchDefaultEndOfSwitchDefault = GraphSwitch_1_1.Link( OSwitchDefault , IEndOfSwitchDefault )
146     
147     LEndOfSwitchaEndOfInitLoopSwitchIndex = GraphSwitch_1_1.Link( OEndOfSwitcha , IEndOfInitLoopSwitchIndex )
148     
149     # Input datas
150     IInitLoopSwitchIndex.Input( 0 )
151     IInitLoopSwitchMin.Input( -5 )
152     IInitLoopSwitchMax.Input( 10 )
153     
154     # Output Ports of the graph
155     #OEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetOutPort( 'Index' )
156     #OEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetOutPort( 'Min' )
157     #OEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetOutPort( 'Max' )
158     return GraphSwitch_1_1
159
160
161 GraphSwitch_1_1 = DefGraphSwitch_1_1()