Salome HOME
Many new examples specially for test of Switches
[modules/superv.git] / examples / GraphSwitchBugDefault.py
1
2 # Generated python file of Graph GraphSwitchBugDefault
3
4 from SuperV import *
5
6 # Graph creation of GraphSwitchBugDefault
7 def DefGraphSwitchBugDefault() :
8     GraphSwitchBugDefault = Graph( 'GraphSwitchBugDefault' )
9     GraphSwitchBugDefault.SetName( 'GraphSwitchBugDefault' )
10     GraphSwitchBugDefault.SetAuthor( 'JR' )
11     GraphSwitchBugDefault.SetComment( '' )
12     GraphSwitchBugDefault.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 = GraphSwitchBugDefault.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     PyInitLoopSwitch = []
35     PyInitLoopSwitch.append( 'def InitLoop(Index,Min,Max) : ' )
36     PyInitLoopSwitch.append( '    Index = Min ' )
37     PyInitLoopSwitch.append( '    return Index,Min,Max      ' )
38     PyMoreInitLoopSwitch = []
39     PyMoreInitLoopSwitch.append( 'def MoreLoop(Index,Min,Max) :      ' )
40     PyMoreInitLoopSwitch.append( '      if Index <= Max :    ' )
41     PyMoreInitLoopSwitch.append( '              DoLoop = 1      ' )
42     PyMoreInitLoopSwitch.append( '      else :      ' )
43     PyMoreInitLoopSwitch.append( '              DoLoop = 0      ' )
44     PyMoreInitLoopSwitch.append( '      return DoLoop,Index,Min,Max      ' )
45     PyNextInitLoopSwitch = []
46     PyNextInitLoopSwitch.append( 'def NextLoop(Index,Min,Max) :      ' )
47     PyNextInitLoopSwitch.append( '      Index = Index + 1      ' )
48     PyNextInitLoopSwitch.append( '      return Index,Min,Max      ' )
49     InitLoopSwitch,EndOfInitLoopSwitch = GraphSwitchBugDefault.LNode( 'InitLoop' , PyInitLoopSwitch , 'MoreLoop' , PyMoreInitLoopSwitch , 'NextLoop' , PyNextInitLoopSwitch )
50     EndOfInitLoopSwitch.SetName( 'EndOfInitLoopSwitch' )
51     EndOfInitLoopSwitch.SetAuthor( '' )
52     EndOfInitLoopSwitch.SetComment( 'Compute Node' )
53     EndOfInitLoopSwitch.Coords( 772 , 132 )
54     PyEndOfInitLoopSwitch = []
55     EndOfInitLoopSwitch.SetPyFunction( '' , PyEndOfInitLoopSwitch )
56     IInitLoopSwitchDoLoop = InitLoopSwitch.GetInPort( 'DoLoop' )
57     IInitLoopSwitchIndex = InitLoopSwitch.InPort( 'Index' , 'long' )
58     IInitLoopSwitchMin = InitLoopSwitch.InPort( 'Min' , 'long' )
59     IInitLoopSwitchMax = InitLoopSwitch.InPort( 'Max' , 'long' )
60     IInitLoopSwitchGate = InitLoopSwitch.GetInPort( 'Gate' )
61     OInitLoopSwitchDoLoop = InitLoopSwitch.GetOutPort( 'DoLoop' )
62     OInitLoopSwitchIndex = InitLoopSwitch.GetOutPort( 'Index' )
63     OInitLoopSwitchMin = InitLoopSwitch.GetOutPort( 'Min' )
64     OInitLoopSwitchMax = InitLoopSwitch.GetOutPort( 'Max' )
65     IEndOfInitLoopSwitchDoLoop = EndOfInitLoopSwitch.GetInPort( 'DoLoop' )
66     IEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetInPort( 'Index' )
67     IEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetInPort( 'Min' )
68     IEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetInPort( 'Max' )
69     IEndOfInitLoopSwitchGate = EndOfInitLoopSwitch.GetInPort( 'Gate' )
70     OEndOfInitLoopSwitchDoLoop = EndOfInitLoopSwitch.GetOutPort( 'DoLoop' )
71     OEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetOutPort( 'Index' )
72     OEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetOutPort( 'Min' )
73     OEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetOutPort( 'Max' )
74     OEndOfInitLoopSwitchGate = EndOfInitLoopSwitch.GetOutPort( 'Gate' )
75     InitLoopSwitch.SetName( 'InitLoopSwitch' )
76     InitLoopSwitch.SetAuthor( '' )
77     InitLoopSwitch.SetComment( 'Compute Node' )
78     InitLoopSwitch.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 & 1 ) == 0 :  ' )
85     PySwitch.append( '        sleep(1)     ' )
86     PySwitch.append( '    return a & 1,1-(a&1),a,a ' )
87     Switch,EndOfSwitch = GraphSwitchBugDefault.SNode( 'Switch' , PySwitch )
88     EndOfSwitch.SetName( 'EndOfSwitch' )
89     EndOfSwitch.SetAuthor( '' )
90     EndOfSwitch.SetComment( 'Compute Node' )
91     EndOfSwitch.Coords( 581 , 132 )
92     PyEndOfSwitch = []
93     PyEndOfSwitch.append( 'def EndOfSwitch(a,Even,k) : ' )
94     PyEndOfSwitch.append( '    return a ' )
95     EndOfSwitch.SetPyFunction( 'EndOfSwitch' , PyEndOfSwitch )
96     IEndOfSwitcha = EndOfSwitch.InPort( 'a' , 'long' )
97     IEndOfSwitchEven = EndOfSwitch.InPort( 'Even' , 'long' )
98     IEndOfSwitchk = EndOfSwitch.InPort( 'k' , 'long' )
99     IEndOfSwitchDefault = EndOfSwitch.GetInPort( 'Default' )
100     OEndOfSwitcha = EndOfSwitch.OutPort( 'a' , 'long' )
101     OEndOfSwitchGate = EndOfSwitch.GetOutPort( 'Gate' )
102     Switch.SetName( 'Switch' )
103     Switch.SetAuthor( '' )
104     Switch.SetComment( 'Compute Node' )
105     Switch.Coords( 194 , 129 )
106     ISwitcha = Switch.InPort( 'a' , 'long' )
107     ISwitchGate = Switch.GetInPort( 'Gate' )
108     OSwitchOdd = Switch.OutPort( 'Odd' , 'long' )
109     OSwitchEven = Switch.OutPort( 'Even' , 'int' )
110     OSwitcha = Switch.OutPort( 'a' , 'int' )
111     OSwitchn = Switch.OutPort( 'n' , 'int' )
112     OSwitchDefault = Switch.GetOutPort( 'Default' )
113     
114     # Creation of Links
115     LIsOddaEndOfSwitcha = GraphSwitchBugDefault.Link( OIsOdda , IEndOfSwitcha )
116     
117     LInitLoopSwitchIndexSwitcha = GraphSwitchBugDefault.Link( OInitLoopSwitchIndex , ISwitcha )
118     
119     LInitLoopSwitchMinEndOfInitLoopSwitchMin = GraphSwitchBugDefault.Link( OInitLoopSwitchMin , IEndOfInitLoopSwitchMin )
120     
121     LInitLoopSwitchMaxEndOfInitLoopSwitchMax = GraphSwitchBugDefault.Link( OInitLoopSwitchMax , IEndOfInitLoopSwitchMax )
122     
123     LSwitchOddIsOddGate = GraphSwitchBugDefault.Link( OSwitchOdd , IIsOddGate )
124     
125     LSwitchaIsOdda = GraphSwitchBugDefault.Link( OSwitcha , IIsOdda )
126     
127     LSwitchnEndOfSwitchk = GraphSwitchBugDefault.Link( OSwitchn , IEndOfSwitchk )
128     
129     LSwitchDefaultEndOfSwitchDefault = GraphSwitchBugDefault.Link( OSwitchDefault , IEndOfSwitchDefault )
130     
131     LEndOfSwitchaEndOfInitLoopSwitchIndex = GraphSwitchBugDefault.Link( OEndOfSwitcha , IEndOfInitLoopSwitchIndex )
132     
133     # Input datas
134     IInitLoopSwitchIndex.Input( 0 )
135     IInitLoopSwitchMin.Input( 1 )
136     IInitLoopSwitchMax.Input( 20 )
137     
138     # Input Ports of the graph
139     #IEndOfSwitchEven = EndOfSwitch.GetInPort( 'Even' )
140     
141     # Output Ports of the graph
142     #OEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetOutPort( 'Index' )
143     #OEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetOutPort( 'Min' )
144     #OEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetOutPort( 'Max' )
145     #OSwitchEven = Switch.GetOutPort( 'Even' )
146     return GraphSwitchBugDefault
147
148
149 GraphSwitchBugDefault = DefGraphSwitchBugDefault()