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 : GraphSyracuseCEv.py
23 # Module : SuperVisionTest
30 GraphSyracuseCEv = Graph( 'GraphSyracuseCEv' )
31 GraphSyracuseCEv.SetName( 'GraphSyracuseCEv' )
32 GraphSyracuseCEv.SetAuthor( 'JR' )
33 GraphSyracuseCEv.SetComment( 'Syracuse algorithm' )
34 GraphSyracuseCEv.Coords( 0 , 0 )
36 # Creation of Computing Nodes
37 test_ISEVEN = GraphSyracuseCEv.Node( 'SyrComponent' , 'SyrComponent' , 'C_ISEVEN' )
38 test_ISEVEN.SetName( 'test_ISEVEN' )
39 test_ISEVEN.SetAuthor( '' )
40 test_ISEVEN.SetContainer( 'localhost/FactoryServer' )
41 test_ISEVEN.SetComment( '' )
42 test_ISEVEN.Coords( 252 , 266 )
43 test_ISONE = GraphSyracuseCEv.Node( 'SyrComponent' , 'SyrComponent' , 'C_ISONE' )
44 test_ISONE.SetName( 'test_ISONE' )
45 test_ISONE.SetAuthor( '' )
46 test_ISONE.SetContainer( 'localhost/FactoryServer' )
47 test_ISONE.SetComment( '' )
48 test_ISONE.Coords( 268 , 29 )
49 m3p1 = GraphSyracuseCEv.Node( 'SyrComponent' , 'SyrComponent' , 'C_M3P1' )
50 m3p1.SetName( 'm3p1' )
52 m3p1.SetContainer( 'localhost/FactoryServer' )
54 m3p1.Coords( 644 , 410 )
55 div2 = GraphSyracuseCEv.Node( 'SyrComponent' , 'SyrComponent' , 'C_DIV2' )
56 div2.SetName( 'div2' )
58 div2.SetContainer( 'localhost/FactoryServer' )
60 div2.Coords( 648 , 209 )
61 incr = GraphSyracuseCEv.Node( 'SyrComponent' , 'SyrComponent' , 'C_INCR' )
62 incr.SetName( 'incr' )
64 incr.SetContainer( 'localhost/FactoryServer' )
66 incr.Coords( 640 , 2 )
68 # Creation of Input datas
69 test_ISEVENanInteger = test_ISEVEN.Input( 'anInteger' , 31)
70 test_ISONEanInteger = test_ISONE.Input( 'anInteger' , 31)
71 m3p1anOddInteger = m3p1.Input( 'anOddInteger' , 31)
72 div2anEvenInteger = div2.Input( 'anEvenInteger' , 31)
73 incraCount = incr.Input( 'aCount' , 0)
75 GraphSyracuseCEv.IsValid()
77 GraphSyracuseCEv.ThreadsMax()
79 GraphSyracuseCEv.LevelMax()
81 GraphSyracuseCEv.GraphsNumber()
83 GraphSyracuseCEv.IsExecutable()
88 exec GraphSyracuseCEv.ListNodes()
90 test_ISEVENanInteger = test_ISEVEN.Port( 'anInteger' )
91 test_ISEVENBoolEven = test_ISEVEN.Port( 'BoolEven' )
92 test_ISONEanInteger = test_ISONE.Port( 'anInteger' )
93 test_ISONEBoolOne = test_ISONE.Port( 'BoolOne' )
94 m3p1anOddInteger = m3p1.Port( 'anOddInteger' )
95 m3p1anEvenInteger = m3p1.Port( 'anEvenInteger' )
96 div2anEvenInteger = div2.Port( 'anEvenInteger' )
97 div2anInteger = div2.Port( 'anInteger' )
98 incraCount = incr.Port( 'aCount' )
99 incraNewCount = incr.Port( 'aNewCount' )
101 GraphSyracuseCEv.Start()
103 test_ISEVEN.SuspendDone()
104 test_ISONE.SuspendDone()
116 aStatus,aNode,anEvent,aState = GraphSyracuseCEv.Event()
117 while aNode != None :
118 if int( test_ISONEBoolOne.ToString() ) == 0 :
119 if int( test_ISEVENBoolEven.ToString() ) == 0 :
120 while aNode != None :
121 if aNode.Name() == 'm3p1' :
122 if aState == SUPERV_idl._0_SUPERV.SuspendReadyState :
126 if aState == SUPERV_idl._0_SUPERV.SuspendDoneState :
127 sts = test_ISEVENanInteger.Input( m3p1anEvenInteger.ToString() )
128 sts = test_ISONEanInteger.Input( m3p1anEvenInteger.ToString() )
129 sts = test_ISEVEN.ReRun()
130 sts = test_ISONE.ReRun()
132 if ( aNode.Name() == 'incr' ) & ( aState == SUPERV_idl._0_SUPERV.SuspendDoneState ) :
133 sts = incraCount.Input( incraNewCount.ToString() )
134 aStatus,aNode,anEvent,aState = GraphSyracuseCEv.Event()
135 print incraNewCount.ToString(),"m3p1",m3p1anEvenInteger.ToString()
136 sts = div2anEvenInteger.Input( m3p1anEvenInteger.ToString() )
137 while int( test_ISEVENBoolEven.ToString() ) == 1 :
140 aStatus,aNode,anEvent,aState = GraphSyracuseCEv.Event()
141 while aNode != None :
142 if ( aNode.Name() == 'div2' ) & ( aState == SUPERV_idl._0_SUPERV.SuspendDoneState ) :
143 sts = test_ISEVENanInteger.Input( div2anInteger.ToString() )
144 sts = test_ISONEanInteger.Input( div2anInteger.ToString() )
145 sts = test_ISEVEN.ReRun()
146 sts = test_ISONE.ReRun()
147 aStatus,aNode,anEvent,aState = GraphSyracuseCEv.Event()
148 sts = incraCount.Input( incraNewCount.ToString() )
149 print incraNewCount.ToString(),"div2",div2anInteger.ToString()
150 sts = m3p1anOddInteger.Input( div2anInteger.ToString() )
151 sts = div2anEvenInteger.Input( div2anInteger.ToString() )
152 if int( test_ISONEBoolOne.ToString() ) == 0 :
155 aStatus,aNode,anEvent,aState = GraphSyracuseCEv.Event()
157 GraphSyracuseCEv.PrintThreads()
163 aStatus,aNode,anEvent,aState = GraphSyracuseCEv.Event()
165 GraphSyracuseCEv.DoneW()
166 GraphSyracuseCEv.PrintThreads()
167 GraphSyracuseCEv.PrintPorts()