Salome HOME
1b29e49413ebbbea734ac24becd06601a223f59e
[samples/datafiles.git] / Superv / Python / GraphSwitchGates.py
1 #  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 #
3 #  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 #
6 #  This library is free software; you can redistribute it and/or
7 #  modify it under the terms of the GNU Lesser General Public
8 #  License as published by the Free Software Foundation; either
9 #  version 2.1 of the License.
10 #
11 #  This library is distributed in the hope that it will be useful,
12 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 #  Lesser General Public License for more details.
15 #
16 #  You should have received a copy of the GNU Lesser General Public
17 #  License along with this library; if not, write to the Free Software
18 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 #
20 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #
22 # Generated python file of Graph GraphSwitchGates
23 #
24 from SuperV import *
25
26 # Graph creation of GraphSwitchGates
27 def DefGraphSwitchGates() :
28     GraphSwitchGates = Graph( 'GraphSwitchGates' )
29     GraphSwitchGates.SetName( 'GraphSwitchGates' )
30     GraphSwitchGates.SetAuthor( 'JR' )
31     GraphSwitchGates.SetComment( '' )
32     GraphSwitchGates.Coords( 0 , 0 )
33     
34     # Creation of Factory Nodes
35     
36     # Creation of InLine Nodes
37     PyIsOdd = []
38     PyIsOdd.append( 'from time import * ' )
39     PyIsOdd.append( 'def IsOdd() : ' )
40     PyIsOdd.append( '    sleep(1) ' )
41     PyIsOdd.append( '    return  ' )
42     IsOdd = GraphSwitchGates.INode( 'IsOdd' , PyIsOdd )
43     IsOdd.SetName( 'IsOdd' )
44     IsOdd.SetAuthor( '' )
45     IsOdd.SetComment( 'Compute Node' )
46     IsOdd.Coords( 424 , 116 )
47     IIsOddGate = IsOdd.GetInPort( 'Gate' )
48     OIsOddGate = IsOdd.GetOutPort( 'Gate' )
49     
50     PyIsEven = []
51     PyIsEven.append( 'from time import * ' )
52     PyIsEven.append( 'def IsEven() :  ' )
53     PyIsEven.append( '    sleep(1) ' )
54     PyIsEven.append( '    return  ' )
55     IsEven = GraphSwitchGates.INode( 'IsEven' , PyIsEven )
56     IsEven.SetName( 'IsEven' )
57     IsEven.SetAuthor( '' )
58     IsEven.SetComment( 'Compute Node' )
59     IsEven.Coords( 428 , 345 )
60     IIsEvenGate = IsEven.GetInPort( 'Gate' )
61     OIsEvenGate = IsEven.GetOutPort( 'Gate' )
62     
63     # Creation of Loop Nodes
64     PyLoopGates = []
65     PyLoopGates.append( 'def InitLoop(Index,Max,Min) :    ' )
66     PyLoopGates.append( '    Index = Max   ' )
67     PyLoopGates.append( '    return Index,Max,Min    ' )
68     PyMoreLoopGates = []
69     PyMoreLoopGates.append( 'from time import *  ' )
70     PyMoreLoopGates.append( 'def MoreLoop(Index,Max,Min) :  ' )
71     PyMoreLoopGates.append( '    sleep(1)  ' )
72     PyMoreLoopGates.append( '    DoLoop = 0   ' )
73     PyMoreLoopGates.append( '    if Index >= Min :   ' )
74     PyMoreLoopGates.append( '        DoLoop = 1   ' )
75     PyMoreLoopGates.append( '    return DoLoop,Index,Max,Min ' )
76     PyNextLoopGates = []
77     PyNextLoopGates.append( 'def  NextLoop(Index,Max,Min) :   ' )
78     PyNextLoopGates.append( '    Index = Index - 1   ' )
79     PyNextLoopGates.append( '    return Index,Max,Min   ' )
80     LoopGates,EndLoopGates = GraphSwitchGates.LNode( 'InitLoop' , PyLoopGates , 'MoreLoop' , PyMoreLoopGates , 'NextLoop' , PyNextLoopGates )
81     EndLoopGates.SetName( 'EndLoopGates' )
82     EndLoopGates.SetAuthor( '' )
83     EndLoopGates.SetComment( 'Compute Node' )
84     EndLoopGates.Coords( 875 , 216 )
85     PyEndLoopGates = []
86     EndLoopGates.SetPyFunction( 'EndLoopGates' , PyEndLoopGates )
87     ILoopGatesDoLoop = LoopGates.GetInPort( 'DoLoop' )
88     ILoopGatesIndex = LoopGates.InPort( 'Index' , 'long' )
89     ILoopGatesMax = LoopGates.InPort( 'Max' , 'long' )
90     ILoopGatesMin = LoopGates.InPort( 'Min' , 'long' )
91     ILoopGatesGate = LoopGates.GetInPort( 'Gate' )
92     OLoopGatesDoLoop = LoopGates.GetOutPort( 'DoLoop' )
93     OLoopGatesIndex = LoopGates.GetOutPort( 'Index' )
94     OLoopGatesMax = LoopGates.GetOutPort( 'Max' )
95     OLoopGatesMin = LoopGates.GetOutPort( 'Min' )
96     IEndLoopGatesDoLoop = EndLoopGates.GetInPort( 'DoLoop' )
97     IEndLoopGatesIndex = EndLoopGates.GetInPort( 'Index' )
98     IEndLoopGatesMax = EndLoopGates.GetInPort( 'Max' )
99     IEndLoopGatesMin = EndLoopGates.GetInPort( 'Min' )
100     IEndLoopGatesGate = EndLoopGates.GetInPort( 'Gate' )
101     OEndLoopGatesDoLoop = EndLoopGates.GetOutPort( 'DoLoop' )
102     OEndLoopGatesIndex = EndLoopGates.GetOutPort( 'Index' )
103     OEndLoopGatesMax = EndLoopGates.GetOutPort( 'Max' )
104     OEndLoopGatesMin = EndLoopGates.GetOutPort( 'Min' )
105     OEndLoopGatesGate = EndLoopGates.GetOutPort( 'Gate' )
106     LoopGates.SetName( 'LoopGates' )
107     LoopGates.SetAuthor( '' )
108     LoopGates.SetComment( 'Compute Node' )
109     LoopGates.Coords( 13 , 236 )
110     
111     # Creation of Switch Nodes
112     PySwitchGates = []
113     PySwitchGates.append( 'def SwitchGates(Index) :  ' )
114     PySwitchGates.append( '    Odd = 0  ' )
115     PySwitchGates.append( '    Even = 0  ' )
116     PySwitchGates.append( '    if (Index & 1) == 1 :  ' )
117     PySwitchGates.append( '        Odd = 1  ' )
118     PySwitchGates.append( '    if (Index & 1) == 0 :  ' )
119     PySwitchGates.append( '        Even = 1  ' )
120     PySwitchGates.append( '    return Odd,Even   ' )
121     SwitchGates,EndSwitchGates = GraphSwitchGates.SNode( 'SwitchGates' , PySwitchGates )
122     EndSwitchGates.SetName( 'EndSwitchGates' )
123     EndSwitchGates.SetAuthor( '' )
124     EndSwitchGates.SetComment( 'Compute Node' )
125     EndSwitchGates.Coords( 648 , 276 )
126     PyEndSwitchGates = []
127     PyEndSwitchGates.append( 'from time import * ' )
128     PyEndSwitchGates.append( 'def EndSwitchGates() : ' )
129     PyEndSwitchGates.append( '    sleep(1) ' )
130     PyEndSwitchGates.append( '    return ' )
131     PyEndSwitchGates.append( '' )
132     EndSwitchGates.SetPyFunction( 'EndSwitchGates' , PyEndSwitchGates )
133     IEndSwitchGatesDefault = EndSwitchGates.GetInPort( 'Default' )
134     OEndSwitchGatesGate = EndSwitchGates.GetOutPort( 'Gate' )
135     SwitchGates.SetName( 'SwitchGates' )
136     SwitchGates.SetAuthor( '' )
137     SwitchGates.SetComment( 'Compute Node' )
138     SwitchGates.Coords( 204 , 236 )
139     ISwitchGatesIndex = SwitchGates.InPort( 'Index' , 'long' )
140     ISwitchGatesGate = SwitchGates.GetInPort( 'Gate' )
141     OSwitchGatesOdd = SwitchGates.OutPort( 'Odd' , 'long' )
142     OSwitchGatesEven = SwitchGates.OutPort( 'Even' , 'long' )
143     OSwitchGatesDefault = SwitchGates.GetOutPort( 'Default' )
144     
145     # Creation of Links
146     LLoopGatesIndexEndLoopGatesIndex = GraphSwitchGates.Link( OLoopGatesIndex , IEndLoopGatesIndex )
147     
148     LLoopGatesIndexSwitchGatesIndex = GraphSwitchGates.Link( OLoopGatesIndex , ISwitchGatesIndex )
149     
150     LLoopGatesMaxEndLoopGatesMax = GraphSwitchGates.Link( OLoopGatesMax , IEndLoopGatesMax )
151     
152     LLoopGatesMinEndLoopGatesMin = GraphSwitchGates.Link( OLoopGatesMin , IEndLoopGatesMin )
153     
154     LSwitchGatesOddIsOddGate = GraphSwitchGates.Link( OSwitchGatesOdd , IIsOddGate )
155     
156     LSwitchGatesEvenIsEvenGate = GraphSwitchGates.Link( OSwitchGatesEven , IIsEvenGate )
157     
158     LEndSwitchGatesGateEndLoopGatesGate = GraphSwitchGates.Link( OEndSwitchGatesGate , IEndLoopGatesGate )
159     
160     LIsOddGateEndSwitchGatesDefault = GraphSwitchGates.Link( OIsOddGate , IEndSwitchGatesDefault )
161     
162     LIsEvenGateEndSwitchGatesDefault = GraphSwitchGates.Link( OIsEvenGate , IEndSwitchGatesDefault )
163     
164     # Input datas
165     ILoopGatesIndex.Input( 0 )
166     ILoopGatesMax.Input( 13 )
167     ILoopGatesMin.Input( -7 )
168     
169     # Output Ports of the graph
170     #OEndLoopGatesIndex = EndLoopGates.GetOutPort( 'Index' )
171     #OEndLoopGatesMax = EndLoopGates.GetOutPort( 'Max' )
172     #OEndLoopGatesMin = EndLoopGates.GetOutPort( 'Min' )
173     return GraphSwitchGates
174
175
176 GraphSwitchGates = DefGraphSwitchGates()