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