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