Salome HOME
Imported using TkCVS
[samples/datafiles.git] / Superv / Python / GraphSwitchBranchGates.py
1
2 # Generated python file of Graph GraphSwitchBranchGates
3
4 from SuperV import *
5
6 # Graph creation of GraphSwitchBranchGates
7 def DefGraphSwitchBranchGates() :
8     GraphSwitchBranchGates = Graph( 'GraphSwitchBranchGates' )
9     GraphSwitchBranchGates.SetName( 'GraphSwitchBranchGates' )
10     GraphSwitchBranchGates.SetAuthor( 'JR' )
11     GraphSwitchBranchGates.SetComment( '' )
12     GraphSwitchBranchGates.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 = GraphSwitchBranchGates.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 = GraphSwitchBranchGates.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 = GraphSwitchBranchGates.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 = GraphSwitchBranchGates.Link( OIsOdda , IEndOfSwitcha )
114     LIsOddaEndOfSwitcha.AddCoord( 1 , 571 , 201 )
115     LIsOddaEndOfSwitcha.AddCoord( 2 , 571 , 136 )
116     
117     LInitLoopIndexSwitcha = GraphSwitchBranchGates.Link( OInitLoopIndex , ISwitcha )
118     
119     LInitLoopMinEndOfInitLoopMin = GraphSwitchBranchGates.Link( OInitLoopMin , IEndOfInitLoopMin )
120     
121     LInitLoopMaxEndOfInitLoopMax = GraphSwitchBranchGates.Link( OInitLoopMax , IEndOfInitLoopMax )
122     
123     LSwitchOddIsOddGate = GraphSwitchBranchGates.Link( OSwitchOdd , IIsOddGate )
124     
125     LSwitchEvenEndOfSwitchDefault = GraphSwitchBranchGates.Link( OSwitchEven , IEndOfSwitchDefault )
126     
127     LSwitchaIsOdda = GraphSwitchBranchGates.Link( OSwitcha , IIsOdda )
128     LSwitchaIsOdda.AddCoord( 1 , 375 , 136 )
129     LSwitchaIsOdda.AddCoord( 2 , 375 , 201 )
130     
131     LSwitchDefaultEndOfSwitchDefault = GraphSwitchBranchGates.Link( OSwitchDefault , IEndOfSwitchDefault )
132     
133     LEndOfSwitchaEndOfInitLoopIndex = GraphSwitchBranchGates.Link( OEndOfSwitcha , IEndOfInitLoopIndex )
134     
135     # Input datas
136     IInitLoopIndex.Input( 0 )
137     IInitLoopMin.Input( -5 )
138     IInitLoopMax.Input( 23 )
139     
140     # Output Ports of the graph
141     #OEndOfInitLoopIndex = EndOfInitLoop.GetOutPort( 'Index' )
142     #OEndOfInitLoopMin = EndOfInitLoop.GetOutPort( 'Min' )
143     #OEndOfInitLoopMax = EndOfInitLoop.GetOutPort( 'Max' )
144     return GraphSwitchBranchGates
145
146
147 GraphSwitchBranchGates = DefGraphSwitchBranchGates()