Salome HOME
Copyrights update 2015.
[samples/datafiles.git] / Superv / Python / GraphLoopSwitchGateDefault.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 GraphLoopSwitchGateDefault
24 #
25 from SuperV import *
26
27 # Graph creation of GraphLoopSwitchGateDefault
28 def DefGraphLoopSwitchGateDefault() :
29     GraphLoopSwitchGateDefault = Graph( 'GraphLoopSwitchGateDefault' )
30     GraphLoopSwitchGateDefault.SetName( 'GraphLoopSwitchGateDefault' )
31     GraphLoopSwitchGateDefault.SetAuthor( 'JR' )
32     GraphLoopSwitchGateDefault.SetComment( '' )
33     GraphLoopSwitchGateDefault.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(a) :         ' )
41     PyIsOdd.append( '    print a,"IsOdd (GraphLoopSwitch1)"        ' )
42     PyIsOdd.append( '    sleep( 1 )     ' )
43     PyIsOdd.append( '    return a       ' )
44     IsOdd = GraphLoopSwitchGateDefault.INode( 'IsOdd' , PyIsOdd )
45     IsOdd.SetName( 'IsOdd' )
46     IsOdd.SetAuthor( '' )
47     IsOdd.SetComment( 'Python function' )
48     IsOdd.Coords( 397 , 1 )
49     IIsOdda = IsOdd.InPort( 'a' , 'long' )
50     IIsOddGate = IsOdd.GetInPort( 'Gate' )
51     OIsOdda = IsOdd.OutPort( 'a' , 'long' )
52     OIsOddGate = IsOdd.GetOutPort( 'Gate' )
53     
54     PyValEven = []
55     PyValEven.append( 'from time import * ' )
56     PyValEven.append( 'def ValEven(Even) : ' )
57     PyValEven.append( '    sleep(1) ' )
58     PyValEven.append( '    return Even   ' )
59     PyValEven.append( '' )
60     ValEven = GraphLoopSwitchGateDefault.INode( 'ValEven' , PyValEven )
61     ValEven.SetName( 'ValEven' )
62     ValEven.SetAuthor( '' )
63     ValEven.SetComment( 'Compute Node' )
64     ValEven.Coords( 396 , 222 )
65     IValEvenEven = ValEven.InPort( 'Even' , 'long' )
66     IValEvenGate = ValEven.GetInPort( 'Gate' )
67     OValEvenEven = ValEven.OutPort( 'Even' , 'long' )
68     OValEvenGate = ValEven.GetOutPort( 'Gate' )
69     
70     # Creation of Loop Nodes
71     PyInitLoop = []
72     PyInitLoop.append( 'def InitLoop(Index,Min,Max) : ' )
73     PyInitLoop.append( '        Index = Min ' )
74     PyInitLoop.append( '        return Index,Min,Max ' )
75     PyInitLoop.append( '' )
76     PyMoreInitLoop = []
77     PyMoreInitLoop.append( '' )
78     PyNextInitLoop = []
79     PyNextInitLoop.append( '' )
80     InitLoop,EndOfInitLoop = GraphLoopSwitchGateDefault.LNode( 'InitLoop' , PyInitLoop , '' , PyMoreInitLoop , '' , PyNextInitLoop )
81     EndOfInitLoop.SetName( 'EndOfInitLoop' )
82     EndOfInitLoop.SetAuthor( '' )
83     EndOfInitLoop.SetComment( 'Compute Node' )
84     EndOfInitLoop.Coords( 767 , 102 )
85     PyEndOfInitLoop = []
86     PyEndOfInitLoop.append( 'def EndOfInitLoop( DoLoop , Index , Min , Max ) :' )
87     PyEndOfInitLoop.append( '   Index = Index + 1     ' )
88     PyEndOfInitLoop.append( '   if Index <= Max :   ' )
89     PyEndOfInitLoop.append( '           DoLoop = 1     ' )
90     PyEndOfInitLoop.append( '   else :     ' )
91     PyEndOfInitLoop.append( '           DoLoop = 0     ' )
92     PyEndOfInitLoop.append( '   return DoLoop,Index,Min,Max     ' )
93     EndOfInitLoop.SetPyFunction( 'EndOfInitLoop' , PyEndOfInitLoop )
94     IInitLoopDoLoop = InitLoop.GetInPort( 'DoLoop' )
95     IInitLoopIndex = InitLoop.InPort( 'Index' , 'long' )
96     IInitLoopMin = InitLoop.InPort( 'Min' , 'long' )
97     IInitLoopMax = InitLoop.InPort( 'Max' , 'long' )
98     IInitLoopGate = InitLoop.GetInPort( 'Gate' )
99     OInitLoopDoLoop = InitLoop.GetOutPort( 'DoLoop' )
100     OInitLoopIndex = InitLoop.GetOutPort( 'Index' )
101     OInitLoopMin = InitLoop.GetOutPort( 'Min' )
102     OInitLoopMax = InitLoop.GetOutPort( 'Max' )
103     IEndOfInitLoopDoLoop = EndOfInitLoop.GetInPort( 'DoLoop' )
104     IEndOfInitLoopIndex = EndOfInitLoop.GetInPort( 'Index' )
105     IEndOfInitLoopMin = EndOfInitLoop.GetInPort( 'Min' )
106     IEndOfInitLoopMax = EndOfInitLoop.GetInPort( 'Max' )
107     IEndOfInitLoopGate = EndOfInitLoop.GetInPort( 'Gate' )
108     OEndOfInitLoopDoLoop = EndOfInitLoop.GetOutPort( 'DoLoop' )
109     OEndOfInitLoopIndex = EndOfInitLoop.GetOutPort( 'Index' )
110     OEndOfInitLoopMin = EndOfInitLoop.GetOutPort( 'Min' )
111     OEndOfInitLoopMax = EndOfInitLoop.GetOutPort( 'Max' )
112     OEndOfInitLoopGate = EndOfInitLoop.GetOutPort( 'Gate' )
113     InitLoop.SetName( 'InitLoop' )
114     InitLoop.SetAuthor( '' )
115     InitLoop.SetComment( 'Compute Node' )
116     InitLoop.Coords( 10 , 108 )
117     
118     # Creation of Switch Nodes
119     PySwitch = []
120     PySwitch.append( 'from time import *  ' )
121     PySwitch.append( 'def Switch(a) :    ' )
122     PySwitch.append( '    if ( a & 1 ) == 0 :  ' )
123     PySwitch.append( '        sleep(1)  ' )
124     PySwitch.append( '    return a & 1,1-(a&1),a    ' )
125     Switch,EndSwitch = GraphLoopSwitchGateDefault.SNode( 'Switch' , PySwitch )
126     EndSwitch.SetName( 'EndSwitch' )
127     EndSwitch.SetAuthor( '' )
128     EndSwitch.SetComment( 'Compute Node' )
129     EndSwitch.Coords( 587 , 103 )
130     PyEndSwitch = []
131     PyEndSwitch.append( 'def EndSwitch(a,Even) : ' )
132     PyEndSwitch.append( '    sleep(1)     ' )
133     PyEndSwitch.append( '    return a       ' )
134     EndSwitch.SetPyFunction( 'EndSwitch' , PyEndSwitch )
135     IEndSwitcha = EndSwitch.InPort( 'a' , 'long' )
136     IEndSwitchEven = EndSwitch.InPort( 'Even' , 'long' )
137     IEndSwitchDefault = EndSwitch.GetInPort( 'Default' )
138     OEndSwitcha = EndSwitch.OutPort( 'a' , 'long' )
139     OEndSwitchGate = EndSwitch.GetOutPort( 'Gate' )
140     Switch.SetName( 'Switch' )
141     Switch.SetAuthor( '' )
142     Switch.SetComment( 'Compute Node' )
143     Switch.Coords( 194 , 109 )
144     ISwitcha = Switch.InPort( 'a' , 'long' )
145     ISwitchGate = Switch.GetInPort( 'Gate' )
146     OSwitchOdd = Switch.OutPort( 'Odd' , 'long' )
147     OSwitchEven = Switch.OutPort( 'Even' , 'int' )
148     OSwitcha = Switch.OutPort( 'a' , 'int' )
149     OSwitchDefault = Switch.GetOutPort( 'Default' )
150     
151     # Creation of Links
152     LIsOddaEndSwitcha = GraphLoopSwitchGateDefault.Link( OIsOdda , IEndSwitcha )
153     
154     LIsOddGateEndSwitchDefault = GraphLoopSwitchGateDefault.Link( OIsOddGate , IEndSwitchDefault )
155     
156     LInitLoopIndexSwitcha = GraphLoopSwitchGateDefault.Link( OInitLoopIndex , ISwitcha )
157     
158     LInitLoopMinEndOfInitLoopMin = GraphLoopSwitchGateDefault.Link( OInitLoopMin , IEndOfInitLoopMin )
159     
160     LInitLoopMaxEndOfInitLoopMax = GraphLoopSwitchGateDefault.Link( OInitLoopMax , IEndOfInitLoopMax )
161     
162     LSwitchOddIsOddGate = GraphLoopSwitchGateDefault.Link( OSwitchOdd , IIsOddGate )
163     
164     LSwitchEvenValEvenEven = GraphLoopSwitchGateDefault.Link( OSwitchEven , IValEvenEven )
165     
166     LSwitchaIsOdda = GraphLoopSwitchGateDefault.Link( OSwitcha , IIsOdda )
167     
168     LSwitchDefaultEndSwitchDefault = GraphLoopSwitchGateDefault.Link( OSwitchDefault , IEndSwitchDefault )
169     
170     LEndSwitchaEndOfInitLoopIndex = GraphLoopSwitchGateDefault.Link( OEndSwitcha , IEndOfInitLoopIndex )
171     
172     LValEvenEvenEndSwitchEven = GraphLoopSwitchGateDefault.Link( OValEvenEven , IEndSwitchEven )
173     
174     # Input datas
175     IInitLoopIndex.Input( 0 )
176     IInitLoopMin.Input( 5 )
177     IInitLoopMax.Input( 23 )
178     
179     # Output Ports of the graph
180     #OEndOfInitLoopIndex = EndOfInitLoop.GetOutPort( 'Index' )
181     #OEndOfInitLoopMin = EndOfInitLoop.GetOutPort( 'Min' )
182     #OEndOfInitLoopMax = EndOfInitLoop.GetOutPort( 'Max' )
183     return GraphLoopSwitchGateDefault
184
185
186 GraphLoopSwitchGateDefault = DefGraphLoopSwitchGateDefault()