Salome HOME
Copyrights update 2015.
[samples/datafiles.git] / Superv / Python / GraphLoopSwitchOddEven.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 GraphLoopSwitchOddEven
24 #
25 from SuperV import *
26
27 # Graph creation of GraphLoopSwitchOddEven
28 def DefGraphLoopSwitchOddEven() :
29     GraphLoopSwitchOddEven = Graph( 'GraphLoopSwitchOddEven' )
30     GraphLoopSwitchOddEven.SetName( 'GraphLoopSwitchOddEven' )
31     GraphLoopSwitchOddEven.SetAuthor( 'JR' )
32     GraphLoopSwitchOddEven.SetComment( '' )
33     GraphLoopSwitchOddEven.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 = GraphLoopSwitchOddEven.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     PyIsEven = []
55     PyIsEven.append( 'from time import * ' )
56     PyIsEven.append( 'def IsEven(a) : ' )
57     PyIsEven.append( '    sleep(1) ' )
58     PyIsEven.append( '    return a  ' )
59     PyIsEven.append( ' ' )
60     IsEven = GraphLoopSwitchOddEven.INode( 'IsEven' , PyIsEven )
61     IsEven.SetName( 'IsEven' )
62     IsEven.SetAuthor( '' )
63     IsEven.SetComment( 'Compute Node' )
64     IsEven.Coords( 400 , 160 )
65     IIsEvena = IsEven.InPort( 'a' , 'long' )
66     IIsEvenGate = IsEven.GetInPort( 'Gate' )
67     OIsEvena = IsEven.OutPort( 'a' , 'long' )
68     OIsEvenGate = IsEven.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 = GraphLoopSwitchOddEven.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 = GraphLoopSwitchOddEven.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) : ' )
132     PyEndSwitch.append( '    sleep(1)   ' )
133     PyEndSwitch.append( '    return a     ' )
134     EndSwitch.SetPyFunction( 'EndSwitch' , PyEndSwitch )
135     IEndSwitcha = EndSwitch.InPort( 'a' , 'long' )
136     IEndSwitchDefault = EndSwitch.GetInPort( 'Default' )
137     OEndSwitcha = EndSwitch.OutPort( 'a' , 'long' )
138     OEndSwitchGate = EndSwitch.GetOutPort( 'Gate' )
139     Switch.SetName( 'Switch' )
140     Switch.SetAuthor( '' )
141     Switch.SetComment( 'Compute Node' )
142     Switch.Coords( 194 , 109 )
143     ISwitcha = Switch.InPort( 'a' , 'long' )
144     ISwitchGate = Switch.GetInPort( 'Gate' )
145     OSwitchOdd = Switch.OutPort( 'Odd' , 'long' )
146     OSwitchEven = Switch.OutPort( 'Even' , 'int' )
147     OSwitcha = Switch.OutPort( 'a' , 'int' )
148     OSwitchDefault = Switch.GetOutPort( 'Default' )
149     
150     # Creation of Links
151     LIsOddaEndSwitcha = GraphLoopSwitchOddEven.Link( OIsOdda , IEndSwitcha )
152     
153     LInitLoopIndexSwitcha = GraphLoopSwitchOddEven.Link( OInitLoopIndex , ISwitcha )
154     
155     LInitLoopMinEndOfInitLoopMin = GraphLoopSwitchOddEven.Link( OInitLoopMin , IEndOfInitLoopMin )
156     
157     LInitLoopMaxEndOfInitLoopMax = GraphLoopSwitchOddEven.Link( OInitLoopMax , IEndOfInitLoopMax )
158     
159     LSwitchOddIsOddGate = GraphLoopSwitchOddEven.Link( OSwitchOdd , IIsOddGate )
160     
161     LSwitchEvenIsEvenGate = GraphLoopSwitchOddEven.Link( OSwitchEven , IIsEvenGate )
162     
163     LSwitchaIsOdda = GraphLoopSwitchOddEven.Link( OSwitcha , IIsOdda )
164     
165     LSwitchaIsEvena = GraphLoopSwitchOddEven.Link( OSwitcha , IIsEvena )
166     
167     LEndSwitchaEndOfInitLoopIndex = GraphLoopSwitchOddEven.Link( OEndSwitcha , IEndOfInitLoopIndex )
168     
169     LIsEvenaEndSwitcha = GraphLoopSwitchOddEven.Link( OIsEvena , IEndSwitcha )
170     
171     # Input datas
172     IInitLoopIndex.Input( 0 )
173     IInitLoopMin.Input( 5 )
174     IInitLoopMax.Input( 23 )
175     
176     # Output Ports of the graph
177     #OEndOfInitLoopIndex = EndOfInitLoop.GetOutPort( 'Index' )
178     #OEndOfInitLoopMin = EndOfInitLoop.GetOutPort( 'Min' )
179     #OEndOfInitLoopMax = EndOfInitLoop.GetOutPort( 'Max' )
180     return GraphLoopSwitchOddEven
181
182
183 GraphLoopSwitchOddEven = DefGraphLoopSwitchOddEven()