Salome HOME
Copyrights update 2015.
[samples/datafiles.git] / Superv / Python / GraphLoopSwitchDefault.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 GraphLoopSwitchDefault
24 #
25 from SuperV import *
26
27 # Graph creation of GraphLoopSwitchDefault
28 def DefGraphLoopSwitchDefault() :
29     GraphLoopSwitchDefault = Graph( 'GraphLoopSwitchDefault' )
30     GraphLoopSwitchDefault.SetName( 'GraphLoopSwitchDefault' )
31     GraphLoopSwitchDefault.SetAuthor( 'JR' )
32     GraphLoopSwitchDefault.SetComment( '' )
33     GraphLoopSwitchDefault.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 (GraphLoopSwitch1)"        ' )
42     PyIsOdd.append( '    sleep( 1 )     ' )
43     PyIsOdd.append( '    return a       ' )
44     IsOdd = GraphLoopSwitchDefault.INode( 'IsOdd' , PyIsOdd )
45     IsOdd.SetName( 'IsOdd' )
46     IsOdd.SetAuthor( '' )
47     IsOdd.SetComment( 'Python function' )
48     IsOdd.Coords( 397 , 1 )
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 = Min ' )
58     PyInitLoop.append( '        return Index,Min,Max ' )
59     PyInitLoop.append( '' )
60     PyMoreInitLoop = []
61     PyMoreInitLoop.append( '' )
62     PyNextInitLoop = []
63     PyNextInitLoop.append( '' )
64     InitLoop,EndOfInitLoop = GraphLoopSwitchDefault.LNode( 'InitLoop' , PyInitLoop , '' , PyMoreInitLoop , '' , PyNextInitLoop )
65     EndOfInitLoop.SetName( 'EndOfInitLoop' )
66     EndOfInitLoop.SetAuthor( '' )
67     EndOfInitLoop.SetComment( 'Compute Node' )
68     EndOfInitLoop.Coords( 767 , 102 )
69     PyEndOfInitLoop = []
70     PyEndOfInitLoop.append( 'def EndOfInitLoop( DoLoop , Index , Min , Max ) :' )
71     PyEndOfInitLoop.append( '   Index = Index + 1     ' )
72     PyEndOfInitLoop.append( '   if Index <= Max :   ' )
73     PyEndOfInitLoop.append( '           DoLoop = 1     ' )
74     PyEndOfInitLoop.append( '   else :     ' )
75     PyEndOfInitLoop.append( '           DoLoop = 0     ' )
76     PyEndOfInitLoop.append( '   return DoLoop,Index,Min,Max     ' )
77     EndOfInitLoop.SetPyFunction( 'EndOfInitLoop' , PyEndOfInitLoop )
78     IInitLoopDoLoop = InitLoop.GetInPort( 'DoLoop' )
79     IInitLoopIndex = InitLoop.InPort( 'Index' , 'long' )
80     IInitLoopMin = InitLoop.InPort( 'Min' , 'long' )
81     IInitLoopMax = InitLoop.InPort( 'Max' , 'long' )
82     IInitLoopGate = InitLoop.GetInPort( 'Gate' )
83     OInitLoopDoLoop = InitLoop.GetOutPort( 'DoLoop' )
84     OInitLoopIndex = InitLoop.GetOutPort( 'Index' )
85     OInitLoopMin = InitLoop.GetOutPort( 'Min' )
86     OInitLoopMax = InitLoop.GetOutPort( 'Max' )
87     IEndOfInitLoopDoLoop = EndOfInitLoop.GetInPort( 'DoLoop' )
88     IEndOfInitLoopIndex = EndOfInitLoop.GetInPort( 'Index' )
89     IEndOfInitLoopMin = EndOfInitLoop.GetInPort( 'Min' )
90     IEndOfInitLoopMax = EndOfInitLoop.GetInPort( 'Max' )
91     IEndOfInitLoopGate = EndOfInitLoop.GetInPort( 'Gate' )
92     OEndOfInitLoopDoLoop = EndOfInitLoop.GetOutPort( 'DoLoop' )
93     OEndOfInitLoopIndex = EndOfInitLoop.GetOutPort( 'Index' )
94     OEndOfInitLoopMin = EndOfInitLoop.GetOutPort( 'Min' )
95     OEndOfInitLoopMax = EndOfInitLoop.GetOutPort( 'Max' )
96     OEndOfInitLoopGate = EndOfInitLoop.GetOutPort( 'Gate' )
97     InitLoop.SetName( 'InitLoop' )
98     InitLoop.SetAuthor( '' )
99     InitLoop.SetComment( 'Compute Node' )
100     InitLoop.Coords( 10 , 108 )
101     
102     # Creation of Switch Nodes
103     PySwitch = []
104     PySwitch.append( 'from time import *  ' )
105     PySwitch.append( 'def Switch(a) :    ' )
106     PySwitch.append( '    if ( a & 1 ) == 0 :  ' )
107     PySwitch.append( '        sleep(1)  ' )
108     PySwitch.append( '    return a & 1,1-(a&1),a    ' )
109     Switch,EndSwitch = GraphLoopSwitchDefault.SNode( 'Switch' , PySwitch )
110     EndSwitch.SetName( 'EndSwitch' )
111     EndSwitch.SetAuthor( '' )
112     EndSwitch.SetComment( 'Compute Node' )
113     EndSwitch.Coords( 587 , 103 )
114     PyEndSwitch = []
115     PyEndSwitch.append( 'def EndSwitch(a) :    ' )
116     PyEndSwitch.append( '    if ( a & 1 ) == 0 :  ' )
117     PyEndSwitch.append( '        sleep(1)  ' )
118     PyEndSwitch.append( '    return a    ' )
119     EndSwitch.SetPyFunction( 'EndSwitch' , PyEndSwitch )
120     IEndSwitcha = EndSwitch.InPort( 'a' , 'long' )
121     IEndSwitchDefault = EndSwitch.GetInPort( 'Default' )
122     OEndSwitcha = EndSwitch.OutPort( 'a' , 'long' )
123     OEndSwitchGate = EndSwitch.GetOutPort( 'Gate' )
124     Switch.SetName( 'Switch' )
125     Switch.SetAuthor( '' )
126     Switch.SetComment( 'Compute Node' )
127     Switch.Coords( 194 , 109 )
128     ISwitcha = Switch.InPort( 'a' , 'long' )
129     ISwitchGate = Switch.GetInPort( 'Gate' )
130     OSwitchOdd = Switch.OutPort( 'Odd' , 'long' )
131     OSwitchEven = Switch.OutPort( 'Even' , 'int' )
132     OSwitcha = Switch.OutPort( 'a' , 'int' )
133     OSwitchDefault = Switch.GetOutPort( 'Default' )
134     
135     # Creation of Links
136     LIsOddaEndSwitcha = GraphLoopSwitchDefault.Link( OIsOdda , IEndSwitcha )
137     
138     LInitLoopIndexSwitcha = GraphLoopSwitchDefault.Link( OInitLoopIndex , ISwitcha )
139     
140     LInitLoopMinEndOfInitLoopMin = GraphLoopSwitchDefault.Link( OInitLoopMin , IEndOfInitLoopMin )
141     
142     LInitLoopMaxEndOfInitLoopMax = GraphLoopSwitchDefault.Link( OInitLoopMax , IEndOfInitLoopMax )
143     
144     LSwitchOddIsOddGate = GraphLoopSwitchDefault.Link( OSwitchOdd , IIsOddGate )
145     
146     LSwitchaIsOdda = GraphLoopSwitchDefault.Link( OSwitcha , IIsOdda )
147     
148     LSwitchDefaultEndSwitchDefault = GraphLoopSwitchDefault.Link( OSwitchDefault , IEndSwitchDefault )
149     
150     LEndSwitchaEndOfInitLoopIndex = GraphLoopSwitchDefault.Link( OEndSwitcha , IEndOfInitLoopIndex )
151     
152     # Input datas
153     IInitLoopIndex.Input( 0 )
154     IInitLoopMin.Input( 5 )
155     IInitLoopMax.Input( 23 )
156     
157     # Output Ports of the graph
158     #OEndOfInitLoopIndex = EndOfInitLoop.GetOutPort( 'Index' )
159     #OEndOfInitLoopMin = EndOfInitLoop.GetOutPort( 'Min' )
160     #OEndOfInitLoopMax = EndOfInitLoop.GetOutPort( 'Max' )
161     #OSwitchEven = Switch.GetOutPort( 'Even' )
162     return GraphLoopSwitchDefault
163
164
165 GraphLoopSwitchDefault = DefGraphLoopSwitchDefault()