Salome HOME
0022763: [EDF] Shape processing
[samples/datafiles.git] / Superv / Python / GraphSwitch1.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 GraphSwitch1
24 #
25 from SuperV import *
26
27 # Graph creation of GraphSwitch1
28 def DefGraphSwitch1() :
29     GraphSwitch1 = Graph( 'GraphSwitch1' )
30     GraphSwitch1.SetName( 'GraphSwitch1' )
31     GraphSwitch1.SetAuthor( '' )
32     GraphSwitch1.SetComment( '' )
33     GraphSwitch1.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 (GraphSwitch1)"      ' )
42     PyIsOdd.append( '    sleep( 1 )   ' )
43     PyIsOdd.append( '    return a     ' )
44     IsOdd = GraphSwitch1.INode( 'IsOdd' , PyIsOdd )
45     IsOdd.SetName( 'IsOdd' )
46     IsOdd.SetAuthor( '' )
47     IsOdd.SetComment( 'Python function' )
48     IsOdd.Coords( 408 , 34 )
49     IIsOdda = IsOdd.InPort( 'a' , 'long' )
50     IIsOddGate = IsOdd.GetInPort( 'Gate' )
51     OIsOdda = IsOdd.OutPort( 'a' , 'long' )
52     OIsOddGate = IsOdd.GetOutPort( 'Gate' )
53     
54     # Creation of Loop Nodes
55     PyInitLoop = []
56     PyInitLoop.append( 'def InitLoop(Index,Min,Max) :      ' )
57     PyInitLoop.append( '        return Index,Min,Max     ' )
58     PyMoreInitLoop = []
59     PyMoreInitLoop.append( 'def MoreLoop(Index,Min,Max) :     ' )
60     PyMoreInitLoop.append( '    if Index <= Max :   ' )
61     PyMoreInitLoop.append( '            DoLoop = 1     ' )
62     PyMoreInitLoop.append( '    else :     ' )
63     PyMoreInitLoop.append( '            DoLoop = 0     ' )
64     PyMoreInitLoop.append( '    return DoLoop,Index,Min,Max     ' )
65     PyNextInitLoop = []
66     PyNextInitLoop.append( 'def NextLoop(Index,Min,Max) :     ' )
67     PyNextInitLoop.append( '    Index = Index + 1     ' )
68     PyNextInitLoop.append( '    return Index,Min,Max     ' )
69     InitLoop,EndOfInitLoop = GraphSwitch1.LNode( 'InitLoop' , PyInitLoop , 'MoreLoop' , PyMoreInitLoop , 'NextLoop' , PyNextInitLoop )
70     EndOfInitLoop.SetName( 'EndOfInitLoop' )
71     EndOfInitLoop.SetAuthor( '' )
72     EndOfInitLoop.SetComment( 'Compute Node' )
73     EndOfInitLoop.Coords( 862 , 156 )
74     PyEndOfInitLoop = []
75     EndOfInitLoop.SetPyFunction( '' , PyEndOfInitLoop )
76     IInitLoopDoLoop = InitLoop.GetInPort( 'DoLoop' )
77     IInitLoopIndex = InitLoop.InPort( 'Index' , 'long' )
78     IInitLoopMin = InitLoop.InPort( 'Min' , 'long' )
79     IInitLoopMax = InitLoop.InPort( 'Max' , 'long' )
80     IInitLoopGate = InitLoop.GetInPort( 'Gate' )
81     OInitLoopDoLoop = InitLoop.GetOutPort( 'DoLoop' )
82     OInitLoopIndex = InitLoop.GetOutPort( 'Index' )
83     OInitLoopMin = InitLoop.GetOutPort( 'Min' )
84     OInitLoopMax = InitLoop.GetOutPort( 'Max' )
85     OInitLoopGate = InitLoop.GetOutPort( 'Gate' )
86     IEndOfInitLoopDoLoop = EndOfInitLoop.GetInPort( 'DoLoop' )
87     IEndOfInitLoopIndex = EndOfInitLoop.GetInPort( 'Index' )
88     IEndOfInitLoopMin = EndOfInitLoop.GetInPort( 'Min' )
89     IEndOfInitLoopMax = EndOfInitLoop.GetInPort( 'Max' )
90     IEndOfInitLoopGate = EndOfInitLoop.GetInPort( 'Gate' )
91     OEndOfInitLoopDoLoop = EndOfInitLoop.GetOutPort( 'DoLoop' )
92     OEndOfInitLoopIndex = EndOfInitLoop.GetOutPort( 'Index' )
93     OEndOfInitLoopMin = EndOfInitLoop.GetOutPort( 'Min' )
94     OEndOfInitLoopMax = EndOfInitLoop.GetOutPort( 'Max' )
95     OEndOfInitLoopGate = EndOfInitLoop.GetOutPort( 'Gate' )
96     InitLoop.SetName( 'InitLoop' )
97     InitLoop.SetAuthor( '' )
98     InitLoop.SetComment( 'Compute Node' )
99     InitLoop.Coords( 10 , 129 )
100     
101     # Creation of Switch Nodes
102     PySwitch = []
103     PySwitch.append( 'from time import *  ' )
104     PySwitch.append( 'def Switch(a) :    ' )
105     PySwitch.append( '    if ( a & 1 ) == 0 :  ' )
106     PySwitch.append( '        sleep(1)  ' )
107     PySwitch.append( '    return a & 1,1-(a&1),a    ' )
108     Switch,EndOfSwitch = GraphSwitch1.SNode( 'Switch' , PySwitch )
109     EndOfSwitch.SetName( 'EndOfSwitch' )
110     EndOfSwitch.SetAuthor( '' )
111     EndOfSwitch.SetComment( 'Compute Node' )
112     EndOfSwitch.Coords( 640 , 155 )
113     PyEndOfSwitch = []
114     EndOfSwitch.SetPyFunction( '' , PyEndOfSwitch )
115     IEndOfSwitcha = EndOfSwitch.InPort( 'a' , 'long' )
116     IEndOfSwitchDefault = EndOfSwitch.GetInPort( 'Default' )
117     OEndOfSwitcha = EndOfSwitch.OutPort( 'a' , 'long' )
118     OEndOfSwitchGate = EndOfSwitch.GetOutPort( 'Gate' )
119     Switch.SetName( 'Switch' )
120     Switch.SetAuthor( '' )
121     Switch.SetComment( 'Compute Node' )
122     Switch.Coords( 195 , 130 )
123     ISwitcha = Switch.InPort( 'a' , 'long' )
124     ISwitchGate = Switch.GetInPort( 'Gate' )
125     OSwitchOdd = Switch.OutPort( 'Odd' , 'long' )
126     OSwitchEven = Switch.OutPort( 'Even' , 'int' )
127     OSwitcha = Switch.OutPort( 'a' , 'int' )
128     OSwitchDefault = Switch.GetOutPort( 'Default' )
129     
130     # Creation of Links
131     LIsOddaEndOfSwitcha = GraphSwitch1.Link( OIsOdda , IEndOfSwitcha )
132     
133     LInitLoopIndexSwitcha = GraphSwitch1.Link( OInitLoopIndex , ISwitcha )
134     
135     LInitLoopMinEndOfInitLoopMin = GraphSwitch1.Link( OInitLoopMin , IEndOfInitLoopMin )
136     
137     LInitLoopMaxEndOfInitLoopMax = GraphSwitch1.Link( OInitLoopMax , IEndOfInitLoopMax )
138     
139     LSwitchOddIsOddGate = GraphSwitch1.Link( OSwitchOdd , IIsOddGate )
140     
141     LSwitchaIsOdda = GraphSwitch1.Link( OSwitcha , IIsOdda )
142     LSwitchaIsOdda.AddCoord( 1 , 375 , 105 )
143     LSwitchaIsOdda.AddCoord( 2 , 375 , 201 )
144     
145     LSwitchDefaultEndOfSwitchDefault = GraphSwitch1.Link( OSwitchDefault , IEndOfSwitchDefault )
146     
147     LEndOfSwitchaEndOfInitLoopIndex = GraphSwitch1.Link( OEndOfSwitcha , IEndOfInitLoopIndex )
148     
149     # Input datas
150     IInitLoopIndex.Input( 0 )
151     IInitLoopMin.Input( 0 )
152     IInitLoopMax.Input( 100 )
153     
154     # Output Ports of the graph
155     #OEndOfInitLoopIndex = EndOfInitLoop.GetOutPort( 'Index' )
156     #OEndOfInitLoopMin = EndOfInitLoop.GetOutPort( 'Min' )
157     #OEndOfInitLoopMax = EndOfInitLoop.GetOutPort( 'Max' )
158     #OSwitchEven = Switch.GetOutPort( 'Even' )
159     return GraphSwitch1
160
161
162 GraphSwitch1 = DefGraphSwitch1()