Salome HOME
Copyrights update 2015.
[samples/datafiles.git] / Superv / Python / GraphSwitchGates.py
1 # Copyright (C) 2007-2015  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, or (at your option) any later version.
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
23 # Generated python file of Graph GraphSwitchGates
24 #
25 from SuperV import *
26
27 # Graph creation of GraphSwitchGates
28 def DefGraphSwitchGates() :
29     GraphSwitchGates = Graph( 'GraphSwitchGates' )
30     GraphSwitchGates.SetName( 'GraphSwitchGates' )
31     GraphSwitchGates.SetAuthor( 'JR' )
32     GraphSwitchGates.SetComment( '' )
33     GraphSwitchGates.Coords( 0 , 0 )
34     
35     # Creation of Factory Nodes
36     
37     # Creation of InLine Nodes
38     PyIsOdd = []
39     PyIsOdd.append( 'from time import * ' )
40     PyIsOdd.append( 'def IsOdd() : ' )
41     PyIsOdd.append( '    sleep(1) ' )
42     PyIsOdd.append( '    return  ' )
43     IsOdd = GraphSwitchGates.INode( 'IsOdd' , PyIsOdd )
44     IsOdd.SetName( 'IsOdd' )
45     IsOdd.SetAuthor( '' )
46     IsOdd.SetComment( 'Compute Node' )
47     IsOdd.Coords( 424 , 116 )
48     IIsOddGate = IsOdd.GetInPort( 'Gate' )
49     OIsOddGate = IsOdd.GetOutPort( 'Gate' )
50     
51     PyIsEven = []
52     PyIsEven.append( 'from time import * ' )
53     PyIsEven.append( 'def IsEven() :  ' )
54     PyIsEven.append( '    sleep(1) ' )
55     PyIsEven.append( '    return  ' )
56     IsEven = GraphSwitchGates.INode( 'IsEven' , PyIsEven )
57     IsEven.SetName( 'IsEven' )
58     IsEven.SetAuthor( '' )
59     IsEven.SetComment( 'Compute Node' )
60     IsEven.Coords( 428 , 345 )
61     IIsEvenGate = IsEven.GetInPort( 'Gate' )
62     OIsEvenGate = IsEven.GetOutPort( 'Gate' )
63     
64     # Creation of Loop Nodes
65     PyLoopGates = []
66     PyLoopGates.append( 'def InitLoop(Index,Max,Min) :    ' )
67     PyLoopGates.append( '    Index = Max   ' )
68     PyLoopGates.append( '    return Index,Max,Min    ' )
69     PyMoreLoopGates = []
70     PyMoreLoopGates.append( 'from time import *  ' )
71     PyMoreLoopGates.append( 'def MoreLoop(Index,Max,Min) :  ' )
72     PyMoreLoopGates.append( '    sleep(1)  ' )
73     PyMoreLoopGates.append( '    DoLoop = 0   ' )
74     PyMoreLoopGates.append( '    if Index >= Min :   ' )
75     PyMoreLoopGates.append( '        DoLoop = 1   ' )
76     PyMoreLoopGates.append( '    return DoLoop,Index,Max,Min ' )
77     PyNextLoopGates = []
78     PyNextLoopGates.append( 'def  NextLoop(Index,Max,Min) :   ' )
79     PyNextLoopGates.append( '    Index = Index - 1   ' )
80     PyNextLoopGates.append( '    return Index,Max,Min   ' )
81     LoopGates,EndLoopGates = GraphSwitchGates.LNode( 'InitLoop' , PyLoopGates , 'MoreLoop' , PyMoreLoopGates , 'NextLoop' , PyNextLoopGates )
82     EndLoopGates.SetName( 'EndLoopGates' )
83     EndLoopGates.SetAuthor( '' )
84     EndLoopGates.SetComment( 'Compute Node' )
85     EndLoopGates.Coords( 875 , 216 )
86     PyEndLoopGates = []
87     EndLoopGates.SetPyFunction( 'EndLoopGates' , PyEndLoopGates )
88     ILoopGatesDoLoop = LoopGates.GetInPort( 'DoLoop' )
89     ILoopGatesIndex = LoopGates.InPort( 'Index' , 'long' )
90     ILoopGatesMax = LoopGates.InPort( 'Max' , 'long' )
91     ILoopGatesMin = LoopGates.InPort( 'Min' , 'long' )
92     ILoopGatesGate = LoopGates.GetInPort( 'Gate' )
93     OLoopGatesDoLoop = LoopGates.GetOutPort( 'DoLoop' )
94     OLoopGatesIndex = LoopGates.GetOutPort( 'Index' )
95     OLoopGatesMax = LoopGates.GetOutPort( 'Max' )
96     OLoopGatesMin = LoopGates.GetOutPort( 'Min' )
97     IEndLoopGatesDoLoop = EndLoopGates.GetInPort( 'DoLoop' )
98     IEndLoopGatesIndex = EndLoopGates.GetInPort( 'Index' )
99     IEndLoopGatesMax = EndLoopGates.GetInPort( 'Max' )
100     IEndLoopGatesMin = EndLoopGates.GetInPort( 'Min' )
101     IEndLoopGatesGate = EndLoopGates.GetInPort( 'Gate' )
102     OEndLoopGatesDoLoop = EndLoopGates.GetOutPort( 'DoLoop' )
103     OEndLoopGatesIndex = EndLoopGates.GetOutPort( 'Index' )
104     OEndLoopGatesMax = EndLoopGates.GetOutPort( 'Max' )
105     OEndLoopGatesMin = EndLoopGates.GetOutPort( 'Min' )
106     OEndLoopGatesGate = EndLoopGates.GetOutPort( 'Gate' )
107     LoopGates.SetName( 'LoopGates' )
108     LoopGates.SetAuthor( '' )
109     LoopGates.SetComment( 'Compute Node' )
110     LoopGates.Coords( 13 , 236 )
111     
112     # Creation of Switch Nodes
113     PySwitchGates = []
114     PySwitchGates.append( 'def SwitchGates(Index) :  ' )
115     PySwitchGates.append( '    Odd = 0  ' )
116     PySwitchGates.append( '    Even = 0  ' )
117     PySwitchGates.append( '    if (Index & 1) == 1 :  ' )
118     PySwitchGates.append( '        Odd = 1  ' )
119     PySwitchGates.append( '    if (Index & 1) == 0 :  ' )
120     PySwitchGates.append( '        Even = 1  ' )
121     PySwitchGates.append( '    return Odd,Even   ' )
122     SwitchGates,EndSwitchGates = GraphSwitchGates.SNode( 'SwitchGates' , PySwitchGates )
123     EndSwitchGates.SetName( 'EndSwitchGates' )
124     EndSwitchGates.SetAuthor( '' )
125     EndSwitchGates.SetComment( 'Compute Node' )
126     EndSwitchGates.Coords( 648 , 276 )
127     PyEndSwitchGates = []
128     PyEndSwitchGates.append( 'from time import * ' )
129     PyEndSwitchGates.append( 'def EndSwitchGates() : ' )
130     PyEndSwitchGates.append( '    sleep(1) ' )
131     PyEndSwitchGates.append( '    return ' )
132     PyEndSwitchGates.append( '' )
133     EndSwitchGates.SetPyFunction( 'EndSwitchGates' , PyEndSwitchGates )
134     IEndSwitchGatesDefault = EndSwitchGates.GetInPort( 'Default' )
135     OEndSwitchGatesGate = EndSwitchGates.GetOutPort( 'Gate' )
136     SwitchGates.SetName( 'SwitchGates' )
137     SwitchGates.SetAuthor( '' )
138     SwitchGates.SetComment( 'Compute Node' )
139     SwitchGates.Coords( 204 , 236 )
140     ISwitchGatesIndex = SwitchGates.InPort( 'Index' , 'long' )
141     ISwitchGatesGate = SwitchGates.GetInPort( 'Gate' )
142     OSwitchGatesOdd = SwitchGates.OutPort( 'Odd' , 'long' )
143     OSwitchGatesEven = SwitchGates.OutPort( 'Even' , 'long' )
144     OSwitchGatesDefault = SwitchGates.GetOutPort( 'Default' )
145     
146     # Creation of Links
147     LLoopGatesIndexEndLoopGatesIndex = GraphSwitchGates.Link( OLoopGatesIndex , IEndLoopGatesIndex )
148     
149     LLoopGatesIndexSwitchGatesIndex = GraphSwitchGates.Link( OLoopGatesIndex , ISwitchGatesIndex )
150     
151     LLoopGatesMaxEndLoopGatesMax = GraphSwitchGates.Link( OLoopGatesMax , IEndLoopGatesMax )
152     
153     LLoopGatesMinEndLoopGatesMin = GraphSwitchGates.Link( OLoopGatesMin , IEndLoopGatesMin )
154     
155     LSwitchGatesOddIsOddGate = GraphSwitchGates.Link( OSwitchGatesOdd , IIsOddGate )
156     
157     LSwitchGatesEvenIsEvenGate = GraphSwitchGates.Link( OSwitchGatesEven , IIsEvenGate )
158     
159     LEndSwitchGatesGateEndLoopGatesGate = GraphSwitchGates.Link( OEndSwitchGatesGate , IEndLoopGatesGate )
160     
161     LIsOddGateEndSwitchGatesDefault = GraphSwitchGates.Link( OIsOddGate , IEndSwitchGatesDefault )
162     
163     LIsEvenGateEndSwitchGatesDefault = GraphSwitchGates.Link( OIsEvenGate , IEndSwitchGatesDefault )
164     
165     # Input datas
166     ILoopGatesIndex.Input( 0 )
167     ILoopGatesMax.Input( 13 )
168     ILoopGatesMin.Input( -7 )
169     
170     # Output Ports of the graph
171     #OEndLoopGatesIndex = EndLoopGates.GetOutPort( 'Index' )
172     #OEndLoopGatesMax = EndLoopGates.GetOutPort( 'Max' )
173     #OEndLoopGatesMin = EndLoopGates.GetOutPort( 'Min' )
174     return GraphSwitchGates
175
176
177 GraphSwitchGates = DefGraphSwitchGates()