Salome HOME
3b314a7c03e84988386f1f265dd825cc69f2d024
[samples/datafiles.git] / Superv / Python / GraphSwitchBranchGates.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 GraphSwitchBranchGates
23 #
24 from SuperV import *
25
26 # Graph creation of GraphSwitchBranchGates
27 def DefGraphSwitchBranchGates() :
28     GraphSwitchBranchGates = Graph( 'GraphSwitchBranchGates' )
29     GraphSwitchBranchGates.SetName( 'GraphSwitchBranchGates' )
30     GraphSwitchBranchGates.SetAuthor( 'JR' )
31     GraphSwitchBranchGates.SetComment( '' )
32     GraphSwitchBranchGates.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 = GraphSwitchBranchGates.INode( 'IsOdd' , PyIsOdd )
44     IsOdd.SetName( 'IsOdd' )
45     IsOdd.SetAuthor( '' )
46     IsOdd.SetComment( 'Python function' )
47     IsOdd.Coords( 389 , 65 )
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( '    Index = Max ' )
57     PyInitLoop.append( '    return Index,Min,Max      ' )
58     PyMoreInitLoop = []
59     PyMoreInitLoop.append( 'def MoreLoop(Index,Min,Max) :      ' )
60     PyMoreInitLoop.append( '    if Index >= Min :    ' )
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 = GraphSwitchBranchGates.LNode( 'InitLoop' , PyInitLoop , 'MoreLoop' , PyMoreInitLoop , 'NextLoop' , PyNextInitLoop )
70     EndOfInitLoop.SetName( 'EndOfInitLoop' )
71     EndOfInitLoop.SetAuthor( '' )
72     EndOfInitLoop.SetComment( 'Compute Node' )
73     EndOfInitLoop.Coords( 777 , 170 )
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     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 <= 0 :  ' )
105     PySwitch.append( '        sleep(1) ' )
106     PySwitch.append( '        return 0,0,a  ' )
107     PySwitch.append( '    if ( a & 1 ) == 0 :    ' )
108     PySwitch.append( '        sleep(1)    ' )
109     PySwitch.append( '    return a & 1,1-(a&1),a      ' )
110     Switch,EndOfSwitch = GraphSwitchBranchGates.SNode( 'Switch' , PySwitch )
111     EndOfSwitch.SetName( 'EndOfSwitch' )
112     EndOfSwitch.SetAuthor( '' )
113     EndOfSwitch.SetComment( 'Compute Node' )
114     EndOfSwitch.Coords( 589 , 170 )
115     PyEndOfSwitch = []
116     EndOfSwitch.SetPyFunction( '' , PyEndOfSwitch )
117     IEndOfSwitcha = EndOfSwitch.InPort( 'a' , 'long' )
118     IEndOfSwitchDefault = EndOfSwitch.GetInPort( 'Default' )
119     OEndOfSwitcha = EndOfSwitch.OutPort( 'a' , 'long' )
120     OEndOfSwitchGate = EndOfSwitch.GetOutPort( 'Gate' )
121     Switch.SetName( 'Switch' )
122     Switch.SetAuthor( '' )
123     Switch.SetComment( 'Compute Node' )
124     Switch.Coords( 195 , 130 )
125     ISwitcha = Switch.InPort( 'a' , 'long' )
126     ISwitchGate = Switch.GetInPort( 'Gate' )
127     OSwitchOdd = Switch.OutPort( 'Odd' , 'long' )
128     OSwitchEven = Switch.OutPort( 'Even' , 'int' )
129     OSwitcha = Switch.OutPort( 'a' , 'int' )
130     OSwitchDefault = Switch.GetOutPort( 'Default' )
131     
132     # Creation of Links
133     LIsOddaEndOfSwitcha = GraphSwitchBranchGates.Link( OIsOdda , IEndOfSwitcha )
134     LIsOddaEndOfSwitcha.AddCoord( 1 , 571 , 201 )
135     LIsOddaEndOfSwitcha.AddCoord( 2 , 571 , 136 )
136     
137     LInitLoopIndexSwitcha = GraphSwitchBranchGates.Link( OInitLoopIndex , ISwitcha )
138     
139     LInitLoopMinEndOfInitLoopMin = GraphSwitchBranchGates.Link( OInitLoopMin , IEndOfInitLoopMin )
140     
141     LInitLoopMaxEndOfInitLoopMax = GraphSwitchBranchGates.Link( OInitLoopMax , IEndOfInitLoopMax )
142     
143     LSwitchOddIsOddGate = GraphSwitchBranchGates.Link( OSwitchOdd , IIsOddGate )
144     
145     LSwitchEvenEndOfSwitchDefault = GraphSwitchBranchGates.Link( OSwitchEven , IEndOfSwitchDefault )
146     
147     LSwitchaIsOdda = GraphSwitchBranchGates.Link( OSwitcha , IIsOdda )
148     LSwitchaIsOdda.AddCoord( 1 , 375 , 136 )
149     LSwitchaIsOdda.AddCoord( 2 , 375 , 201 )
150     
151     LSwitchDefaultEndOfSwitchDefault = GraphSwitchBranchGates.Link( OSwitchDefault , IEndOfSwitchDefault )
152     
153     LEndOfSwitchaEndOfInitLoopIndex = GraphSwitchBranchGates.Link( OEndOfSwitcha , IEndOfInitLoopIndex )
154     
155     # Input datas
156     IInitLoopIndex.Input( 0 )
157     IInitLoopMin.Input( -5 )
158     IInitLoopMax.Input( 23 )
159     
160     # Output Ports of the graph
161     #OEndOfInitLoopIndex = EndOfInitLoop.GetOutPort( 'Index' )
162     #OEndOfInitLoopMin = EndOfInitLoop.GetOutPort( 'Min' )
163     #OEndOfInitLoopMax = EndOfInitLoop.GetOutPort( 'Max' )
164     return GraphSwitchBranchGates
165
166
167 GraphSwitchBranchGates = DefGraphSwitchBranchGates()