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