1 # Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
22 # File : GraphSyracuseCpp.py
23 # Module : SuperVisionTest
27 GraphSyracuseCpp = Graph( 'GraphSyracuseCpp' )
28 GraphSyracuseCpp.SetName( 'GraphSyracuseCpp' )
29 GraphSyracuseCpp.SetAuthor( 'JR' )
30 GraphSyracuseCpp.SetComment( 'Syracuse algorithm' )
31 GraphSyracuseCpp.Coords( 0 , 0 )
33 # Creation of Computing Nodes
34 Syracuse = GraphSyracuseCpp.Node( 'SyrComponent' , 'SyrComponent' , 'Init' )
35 Syracuse.SetName( 'Syracuse' )
36 Syracuse.SetAuthor( '' )
37 #Syracuse.SetContainer( 'localhost/FactoryServer' )
38 Syracuse.SetComment( '' )
39 Syracuse.Coords( 9 , 207 )
40 test_IsEven = GraphSyracuseCpp.CNode( 'SyrComponent' , 'Syr' , 'IsEven' )
41 test_IsEven.SetName( 'test_IsEven' )
42 test_IsEven.SetAuthor( '' )
43 #test_IsEven.SetContainer( 'localhost/FactoryServer' )
44 test_IsEven.SetComment( '' )
45 test_IsEven.Coords( 197 , 407 )
46 test_IsOne = GraphSyracuseCpp.CNode( 'SyrComponent' , 'Syr' , 'IsOne' )
47 test_IsOne.SetName( 'test_IsOne' )
48 test_IsOne.SetAuthor( '' )
49 #test_IsOne.SetContainer( 'localhost/FactoryServer' )
50 test_IsOne.SetComment( '' )
51 test_IsOne.Coords( 208 , 59 )
52 m3p1_M3p1 = GraphSyracuseCpp.CNode( 'SyrComponent' , 'Syr' , 'M3p1' )
53 m3p1_M3p1.SetName( 'm3p1_M3p1' )
54 m3p1_M3p1.SetAuthor( '' )
55 #m3p1_M3p1.SetContainer( 'localhost/FactoryServer' )
56 m3p1_M3p1.SetComment( '' )
57 m3p1_M3p1.Coords( 418 , 408 )
58 div2_Div2 = GraphSyracuseCpp.CNode( 'SyrComponent' , 'Syr' , 'Div2' )
59 div2_Div2.SetName( 'div2_Div2' )
60 div2_Div2.SetAuthor( '' )
61 #div2_Div2.SetContainer( 'localhost/FactoryServer' )
62 div2_Div2.SetComment( '' )
63 div2_Div2.Coords( 414 , 10 )
64 incr_Incr = GraphSyracuseCpp.CNode( 'SyrComponent' , 'Syr' , 'Incr' )
65 incr_Incr.SetName( 'incr_Incr' )
66 incr_Incr.SetAuthor( '' )
67 #incr_Incr.SetContainer( 'localhost/FactoryServer' )
68 incr_Incr.SetComment( '' )
69 incr_Incr.Coords( 416 , 207 )
70 result_Current = GraphSyracuseCpp.CNode( 'SyrComponent' , 'Syr' , 'Current' )
71 result_Current.SetName( 'result_Current' )
72 result_Current.SetAuthor( '' )
73 #result_Current.SetContainer( 'localhost/FactoryServer' )
74 result_Current.SetComment( '' )
75 result_Current.Coords( 603 , 216 )
76 result_Count = GraphSyracuseCpp.CNode( 'SyrComponent' , 'Syr' , 'Count' )
77 result_Count.SetName( 'result_Count' )
78 result_Count.SetAuthor( '' )
79 #result_Count.SetContainer( 'localhost/FactoryServer' )
80 result_Count.SetComment( '' )
81 result_Count.Coords( 803 , 212 )
83 # Creation of intermediate Output variables and of Computing Links
84 SyracuseaSyracuse = Syracuse.Port( 'aSyracuse' )
85 test_IsEvenaSyracuse = GraphSyracuseCpp.Link( SyracuseaSyracuse , test_IsEven.Port( 'aSyracuse' ) )
86 test_IsEvenaSyracuse.AddCoord( 1 , 175 , 559 )
87 test_IsEvenaSyracuse.AddCoord( 2 , 175 , 359 )
88 test_IsOneaSyracuse = GraphSyracuseCpp.Link( SyracuseaSyracuse , test_IsOne.Port( 'aSyracuse' ) )
89 test_IsOneaSyracuse.AddCoord( 1 , 177 , 211 )
90 test_IsOneaSyracuse.AddCoord( 2 , 177 , 359 )
91 m3p1_M3p1aSyracuse = GraphSyracuseCpp.Link( SyracuseaSyracuse , m3p1_M3p1.Port( 'aSyracuse' ) )
92 m3p1_M3p1aSyracuse.AddCoord( 1 , 388 , 560 )
93 m3p1_M3p1aSyracuse.AddCoord( 2 , 388 , 359 )
94 div2_Div2aSyracuse = GraphSyracuseCpp.Link( SyracuseaSyracuse , div2_Div2.Port( 'aSyracuse' ) )
95 div2_Div2aSyracuse.AddCoord( 1 , 389 , 162 )
96 div2_Div2aSyracuse.AddCoord( 2 , 389 , 359 )
97 incr_IncraSyracuse = GraphSyracuseCpp.Link( SyracuseaSyracuse , incr_Incr.Port( 'aSyracuse' ) )
98 result_CurrentaSyracuse = GraphSyracuseCpp.Link( SyracuseaSyracuse , result_Current.Port( 'aSyracuse' ) )
99 result_CurrentaSyracuse.AddCoord( 1 , 590 , 368 )
100 result_CurrentaSyracuse.AddCoord( 2 , 590 , 390 )
101 result_CurrentaSyracuse.AddCoord( 3 , 388 , 390 )
102 result_CurrentaSyracuse.AddCoord( 4 , 388 , 359 )
103 result_CountaSyracuse = GraphSyracuseCpp.Link( SyracuseaSyracuse , result_Count.Port( 'aSyracuse' ) )
104 result_CountaSyracuse.AddCoord( 1 , 785 , 364 )
105 result_CountaSyracuse.AddCoord( 2 , 785 , 391 )
106 result_CountaSyracuse.AddCoord( 3 , 389 , 391 )
107 result_CountaSyracuse.AddCoord( 4 , 389 , 357 )
109 # Missing Input datas
110 SyracuseanOddInteger = Syracuse.Input( 'anOddInteger' , 7 )
112 # Creation of Output variables
113 test_IsEvenBoolEven = test_IsEven.Port( 'BoolEven' )
114 test_IsOneBoolOne = test_IsOne.Port( 'BoolOne' )
115 count_incr_Incr = incr_Incr.Port('aSyracuse')
116 result_CurrentaCurrent = result_Current.Port( 'aCurrent' )
118 GraphSyracuseCpp.IsValid()
119 GraphSyracuseCpp.LevelMax()
120 GraphSyracuseCpp.ThreadsMax()
122 exec GraphSyracuseCpp.ListNodes()
123 SyracuseanOddInteger = Syracuse.Input( 'anOddInteger' , 7 )
124 test_IsEvenBoolEven = test_IsEven.Port( 'BoolEven' )
125 test_IsOneBoolOne = test_IsOne.Port( 'BoolOne' )
126 count_incr_Incr = incr_Incr.Port('aSyracuse')
127 result_CurrentaCurrent = result_Current.Port( 'aCurrent' )
130 GraphSyracuseCpp.Start( 7 )
132 # Suspend des nodes de tete de Syr
133 sts = test_IsOne.Suspend()
134 sts = test_IsEven.Suspend()
135 sts = m3p1_M3p1.Suspend()
136 sts = div2_Div2.Suspend()
137 sts = incr_Incr.Suspend()
138 sts = result_Current.Suspend()
139 sts = result_Count.Suspend()
141 # Ex
\81écution du node de tete
142 sts = Syracuse.Resume()
143 sts = Syracuse.DoneW()
145 # Attente de suspension de test et demandes de suspension apr
\81ès ex
\81écution
146 sts = test_IsOne.SuspendedW()
147 sts = test_IsOne.SuspendDone()
148 sts = test_IsEven.SuspendedW()
149 sts = test_IsEven.SuspendDone()
151 # Ex
\81écution de test avec la valeur de d
\81épart
152 sts = test_IsOne.Resume()
153 sts = test_IsEven.Resume()
155 # Attentes de suspension de m3p1, div2, incr et result.
156 # Puis demandes de suspension apr
\81ès ex
\81écution
157 sts = m3p1_M3p1.SuspendedW()
158 sts = div2_Div2.SuspendedW()
159 sts = incr_Incr.SuspendedW()
160 sts = result_Current.SuspendedW()
161 sts = result_Count.SuspendedW()
162 sts = m3p1_M3p1.SuspendDone()
163 sts = div2_Div2.SuspendDone()
164 sts = incr_Incr.SuspendDone()
165 sts = result_Current.SuspendDone()
167 # Attente de fin d'ex
\81écution de test
168 sts = test_IsOne.SuspendedW()
169 sts = test_IsEven.SuspendedW()
171 GraphSyracuseCpp.PrintThreads()
173 IsOneBoolOne = test_IsOneBoolOne.ToString()
174 while int( IsOneBoolOne ) == 0 :
175 IsEvenBoolEven = test_IsEvenBoolEven.ToString()
176 if int( IsEvenBoolEven ) == 0 :
177 sts = m3p1_M3p1.ReRun()
178 sts = incr_Incr.ReRun()
179 sts = m3p1_M3p1.SuspendedW()
180 sts = result_Current.ReRun()
181 sts = test_IsOne.ReRun()
182 sts = test_IsEven.ReRun()
183 sts = test_IsOne.SuspendedW()
184 sts = test_IsEven.SuspendedW()
185 sts = incr_Incr.SuspendedW()
186 sts = result_Current.SuspendedW()
187 print "m3p1_M3p1",result_CurrentaCurrent.ToString(),IsEvenBoolEven
188 IsEvenBoolEven = test_IsEvenBoolEven.ToString()
189 while int( IsEvenBoolEven ) == 1 :
190 sts = div2_Div2.ReRun()
191 sts = incr_Incr.ReRun()
192 sts = div2_Div2.SuspendedW()
193 sts = result_Current.ReRun()
194 sts = test_IsOne.ReRun()
195 sts = test_IsEven.ReRun()
196 sts = test_IsOne.SuspendedW()
197 sts = test_IsEven.SuspendedW()
198 sts = incr_Incr.SuspendedW()
199 sts = IsEvenBoolEven = test_IsEvenBoolEven.ToString()
200 sts = result_Current.SuspendedW()
201 print "div2_Div2",result_CurrentaCurrent.ToString(),IsEvenBoolEven
202 IsOneBoolOne = test_IsOneBoolOne.ToString()
206 GraphSyracuseCpp.PrintThreads()
207 sts = m3p1_M3p1.ControlClear()
208 sts = m3p1_M3p1.Resume()
209 sts = div2_Div2.ControlClear()
210 sts = div2_Div2.Resume()
211 sts = incr_Incr.ControlClear()
212 sts = incr_Incr.Resume()
213 sts = test_IsOne.Resume()
214 sts = test_IsEven.Resume()
215 sts = result_Current.ControlClear()
216 sts = result_Current.Resume()
217 sts = result_Count.ControlClear()
218 sts = result_Count.Resume()
219 sts = GraphSyracuseCpp.DoneW()
220 GraphSyracuseCpp.PrintPorts()
221 GraphSyracuseCpp.PrintThreads()