Salome HOME
Merge from BR_V5_DEV 17Feb09
[samples/datafiles.git] / Superv / Python / GraphSwitch2.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 GraphSwitch_1_1
23 #
24 from SuperV import *
25
26 # Graph creation of GraphSwitch_1_1
27 def DefGraphSwitch_1_1() :
28     GraphSwitch_1_1 = Graph( 'GraphSwitch_1_1' )
29     GraphSwitch_1_1.SetName( 'GraphSwitch_1_1' )
30     GraphSwitch_1_1.SetAuthor( '' )
31     GraphSwitch_1_1.SetComment( '' )
32     GraphSwitch_1_1.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(a) :       ' )
40     PyIsOdd.append( '    print a,"IsOdd (GraphSwitch)"      ' )
41     PyIsOdd.append( '    sleep( 1 )   ' )
42     PyIsOdd.append( '    return a     ' )
43     IsOdd = GraphSwitch_1_1.INode( 'IsOdd' , PyIsOdd )
44     IsOdd.SetName( 'IsOdd' )
45     IsOdd.SetAuthor( '' )
46     IsOdd.SetComment( 'Python function' )
47     IsOdd.Coords( 388 , 50 )
48     IIsOdda = IsOdd.InPort( 'a' , 'long' )
49     IIsOddGate = IsOdd.GetInPort( 'Gate' )
50     OIsOdda = IsOdd.OutPort( 'a' , 'long' )
51     OIsOddGate = IsOdd.GetOutPort( 'Gate' )
52     
53     PyIsEven = []
54     PyIsEven.append( 'from time import *    ' )
55     PyIsEven.append( 'def IsEven(a) :        ' )
56     PyIsEven.append( '    print a,"IsEven (GraphSwitch)"       ' )
57     PyIsEven.append( '    sleep( 1 )    ' )
58     PyIsEven.append( '    return a      ' )
59     IsEven = GraphSwitch_1_1.INode( 'IsEven' , PyIsEven )
60     IsEven.SetName( 'IsEven' )
61     IsEven.SetAuthor( '' )
62     IsEven.SetComment( 'Compute Node' )
63     IsEven.Coords( 397 , 279 )
64     IIsEvena = IsEven.InPort( 'a' , 'long' )
65     IIsEvenGate = IsEven.GetInPort( 'Gate' )
66     OIsEvena = IsEven.OutPort( 'a' , 'long' )
67     OIsEvenGate = IsEven.GetOutPort( 'Gate' )
68     
69     # Creation of Loop Nodes
70     PyInitLoopSwitch = []
71     PyInitLoopSwitch.append( 'def InitLoop(Index,Min,Max) :       ' )
72     PyInitLoopSwitch.append( '  Index = Max ' )
73     PyInitLoopSwitch.append( '  return Index,Min,Max      ' )
74     PyMoreInitLoopSwitch = []
75     PyMoreInitLoopSwitch.append( 'def MoreLoop(Index,Min,Max) :      ' )
76     PyMoreInitLoopSwitch.append( '      if Index >= Min :    ' )
77     PyMoreInitLoopSwitch.append( '              DoLoop = 1      ' )
78     PyMoreInitLoopSwitch.append( '      else :      ' )
79     PyMoreInitLoopSwitch.append( '              DoLoop = 0      ' )
80     PyMoreInitLoopSwitch.append( '      return DoLoop,Index,Min,Max      ' )
81     PyNextInitLoopSwitch = []
82     PyNextInitLoopSwitch.append( 'def NextLoop(Index,Min,Max) :      ' )
83     PyNextInitLoopSwitch.append( '      Index = Index - 1      ' )
84     PyNextInitLoopSwitch.append( '      return Index,Min,Max      ' )
85     InitLoopSwitch,EndOfInitLoopSwitch = GraphSwitch_1_1.LNode( 'InitLoop' , PyInitLoopSwitch , 'MoreLoop' , PyMoreInitLoopSwitch , 'NextLoop' , PyNextInitLoopSwitch )
86     EndOfInitLoopSwitch.SetName( 'EndOfInitLoopSwitch' )
87     EndOfInitLoopSwitch.SetAuthor( '' )
88     EndOfInitLoopSwitch.SetComment( 'Compute Node' )
89     EndOfInitLoopSwitch.Coords( 775 , 169 )
90     PyEndOfInitLoopSwitch = []
91     EndOfInitLoopSwitch.SetPyFunction( '' , PyEndOfInitLoopSwitch )
92     IInitLoopSwitchDoLoop = InitLoopSwitch.GetInPort( 'DoLoop' )
93     IInitLoopSwitchIndex = InitLoopSwitch.InPort( 'Index' , 'long' )
94     IInitLoopSwitchMin = InitLoopSwitch.InPort( 'Min' , 'long' )
95     IInitLoopSwitchMax = InitLoopSwitch.InPort( 'Max' , 'long' )
96     IInitLoopSwitchGate = InitLoopSwitch.GetInPort( 'Gate' )
97     OInitLoopSwitchDoLoop = InitLoopSwitch.GetOutPort( 'DoLoop' )
98     OInitLoopSwitchIndex = InitLoopSwitch.GetOutPort( 'Index' )
99     OInitLoopSwitchMin = InitLoopSwitch.GetOutPort( 'Min' )
100     OInitLoopSwitchMax = InitLoopSwitch.GetOutPort( 'Max' )
101     IEndOfInitLoopSwitchDoLoop = EndOfInitLoopSwitch.GetInPort( 'DoLoop' )
102     IEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetInPort( 'Index' )
103     IEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetInPort( 'Min' )
104     IEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetInPort( 'Max' )
105     IEndOfInitLoopSwitchGate = EndOfInitLoopSwitch.GetInPort( 'Gate' )
106     OEndOfInitLoopSwitchDoLoop = EndOfInitLoopSwitch.GetOutPort( 'DoLoop' )
107     OEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetOutPort( 'Index' )
108     OEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetOutPort( 'Min' )
109     OEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetOutPort( 'Max' )
110     OEndOfInitLoopSwitchGate = EndOfInitLoopSwitch.GetOutPort( 'Gate' )
111     InitLoopSwitch.SetName( 'InitLoopSwitch' )
112     InitLoopSwitch.SetAuthor( '' )
113     InitLoopSwitch.SetComment( 'Compute Node' )
114     InitLoopSwitch.Coords( 10 , 129 )
115     
116     # Creation of Switch Nodes
117     PySwitch = []
118     PySwitch.append( 'from time import *     ' )
119     PySwitch.append( 'def Switch(a) : ' )
120     PySwitch.append( '    sleep(1) ' )
121     PySwitch.append( '    if a <= 0 :    ' )
122     PySwitch.append( '        return 0,0,a    ' )
123     PySwitch.append( '    return a & 1,1-(a&1),a        ' )
124     Switch,EndOfSwitch = GraphSwitch_1_1.SNode( 'Switch' , PySwitch )
125     EndOfSwitch.SetName( 'EndOfSwitch' )
126     EndOfSwitch.SetAuthor( '' )
127     EndOfSwitch.SetComment( 'Compute Node' )
128     EndOfSwitch.Coords( 583 , 169 )
129     PyEndOfSwitch = []
130     EndOfSwitch.SetPyFunction( 'EndSwitch_1' , PyEndOfSwitch )
131     IEndOfSwitcha = EndOfSwitch.InPort( 'a' , 'long' )
132     IEndOfSwitchDefault = EndOfSwitch.GetInPort( 'Default' )
133     OEndOfSwitcha = EndOfSwitch.OutPort( 'a' , 'long' )
134     OEndOfSwitchGate = EndOfSwitch.GetOutPort( 'Gate' )
135     Switch.SetName( 'Switch' )
136     Switch.SetAuthor( '' )
137     Switch.SetComment( 'Compute Node' )
138     Switch.Coords( 195 , 129 )
139     ISwitcha = Switch.InPort( 'a' , 'long' )
140     ISwitchGate = Switch.GetInPort( 'Gate' )
141     OSwitchOdd = Switch.OutPort( 'Odd' , 'long' )
142     OSwitchEven = Switch.OutPort( 'Even' , 'int' )
143     OSwitcha = Switch.OutPort( 'a' , 'int' )
144     OSwitchDefault = Switch.GetOutPort( 'Default' )
145     
146     # Creation of Links
147     LIsOddaEndOfSwitcha = GraphSwitch_1_1.Link( OIsOdda , IEndOfSwitcha )
148     
149     LInitLoopSwitchIndexSwitcha = GraphSwitch_1_1.Link( OInitLoopSwitchIndex , ISwitcha )
150     
151     LInitLoopSwitchMinEndOfInitLoopSwitchMin = GraphSwitch_1_1.Link( OInitLoopSwitchMin , IEndOfInitLoopSwitchMin )
152     
153     LInitLoopSwitchMaxEndOfInitLoopSwitchMax = GraphSwitch_1_1.Link( OInitLoopSwitchMax , IEndOfInitLoopSwitchMax )
154     
155     LIsEvenaEndOfSwitcha = GraphSwitch_1_1.Link( OIsEvena , IEndOfSwitcha )
156     
157     LSwitchOddIsOddGate = GraphSwitch_1_1.Link( OSwitchOdd , IIsOddGate )
158     
159     LSwitchEvenIsEvenGate = GraphSwitch_1_1.Link( OSwitchEven , IIsEvenGate )
160     
161     LSwitchaIsOdda = GraphSwitch_1_1.Link( OSwitcha , IIsOdda )
162     
163     LSwitchaIsEvena = GraphSwitch_1_1.Link( OSwitcha , IIsEvena )
164     
165     LSwitchDefaultEndOfSwitchDefault = GraphSwitch_1_1.Link( OSwitchDefault , IEndOfSwitchDefault )
166     
167     LEndOfSwitchaEndOfInitLoopSwitchIndex = GraphSwitch_1_1.Link( OEndOfSwitcha , IEndOfInitLoopSwitchIndex )
168     
169     # Input datas
170     IInitLoopSwitchIndex.Input( 0 )
171     IInitLoopSwitchMin.Input( -5 )
172     IInitLoopSwitchMax.Input( 10 )
173     
174     # Output Ports of the graph
175     #OEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetOutPort( 'Index' )
176     #OEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetOutPort( 'Min' )
177     #OEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetOutPort( 'Max' )
178     return GraphSwitch_1_1
179
180
181 GraphSwitch_1_1 = DefGraphSwitch_1_1()