Salome HOME
DCQ : Merge with Ecole_Ete_a6.
[modules/superv.git] / examples / GraphSyracuseC.py
1 #  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
3
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. 
8
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. 
13
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 
17
18 #  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
19 #
20 #
21 #
22 #  File   : GraphSyracuseC.py
23 #  Module : SuperVisionTest
24
25 from SuperV import *
26 # Graph creation 
27 GraphSyracuseC = Graph( 'GraphSyracuseC' )
28 GraphSyracuseC.SetName( 'GraphSyracuseC' )
29 GraphSyracuseC.SetAuthor( 'JR' )
30 GraphSyracuseC.SetComment( 'Syracuse algorithm' )
31 GraphSyracuseC.Coords( 0 , 0 )
32
33 # Creation of Computing Nodes
34 test_ISEVEN = GraphSyracuseC.Node( 'SyrComponent' , 'SyrComponent' , 'C_ISEVEN' )
35 test_ISEVEN.SetName( 'test_ISEVEN' )
36 test_ISEVEN.SetAuthor( '' )
37 test_ISEVEN.SetContainer( 'localhost/FactoryServer' )
38 test_ISEVEN.SetComment( '' )
39 test_ISEVEN.Coords( 252 , 266 )
40 test_ISONE = GraphSyracuseC.Node( 'SyrComponent' , 'SyrComponent' , 'C_ISONE' )
41 test_ISONE.SetName( 'test_ISONE' )
42 test_ISONE.SetAuthor( '' )
43 test_ISONE.SetContainer( 'localhost/FactoryServer' )
44 test_ISONE.SetComment( '' )
45 test_ISONE.Coords( 268 , 29 )
46 m3p1 = GraphSyracuseC.Node( 'SyrComponent' , 'SyrComponent' , 'C_M3P1' )
47 m3p1.SetName( 'm3p1' )
48 m3p1.SetAuthor( '' )
49 m3p1.SetContainer( 'localhost/FactoryServer' )
50 m3p1.SetComment( '' )
51 m3p1.Coords( 644 , 410 )
52 div2 = GraphSyracuseC.Node( 'SyrComponent' , 'SyrComponent' , 'C_DIV2' )
53 div2.SetName( 'div2' )
54 div2.SetAuthor( '' )
55 div2.SetContainer( 'localhost/FactoryServer' )
56 div2.SetComment( '' )
57 div2.Coords( 648 , 209 )
58 incr = GraphSyracuseC.Node( 'SyrComponent' , 'SyrComponent' , 'C_INCR' )
59 incr.SetName( 'incr' )
60 incr.SetAuthor( '' )
61 incr.SetContainer( 'localhost/FactoryServer' )
62 incr.SetComment( '' )
63 incr.Coords( 640 , 2 )
64
65 # Creation of Input datas
66 test_ISEVENanInteger = test_ISEVEN.Input( 'anInteger' , 7)
67 test_ISONEanInteger = test_ISONE.Input( 'anInteger' , 7)
68 m3p1anOddInteger = m3p1.Input( 'anOddInteger' , 7)
69 div2anEvenInteger = div2.Input( 'anEvenInteger' , 7)
70 incraCount = incr.Input( 'aCount' , 0)
71
72 # Creation of Output variables
73 test_ISEVENBoolEven = test_ISEVEN.Port( 'BoolEven' )
74 test_ISONEBoolOne = test_ISONE.Port( 'BoolOne' )
75 m3p1anEvenInteger = m3p1.Port( 'anEvenInteger' )
76 div2anInteger = div2.Port( 'anInteger' )
77 incraNewCount = incr.Port( 'aNewCount' )
78
79 GraphSyracuseC.IsValid()
80
81 GraphSyracuseC.ThreadsMax()
82
83 GraphSyracuseC.LevelMax()
84
85 GraphSyracuseC.GraphsNumber()
86
87 GraphSyracuseC.IsExecutable()
88
89 exec GraphSyracuseC.ListNodes()
90 test_ISEVENanInteger = test_ISEVEN.Port( 'anInteger' )
91 test_ISONEanInteger = test_ISONE.Port( 'anInteger' )
92 m3p1anOddInteger = m3p1.Port( 'anOddInteger' )
93 div2anEvenInteger = div2.Port( 'anEvenInteger' )
94 incraCount = incr.Port( 'aCount' )
95
96 # Creation of Output variables
97 test_ISEVENBoolEven = test_ISEVEN.Port( 'BoolEven' )
98 test_ISONEBoolOne = test_ISONE.Port( 'BoolOne' )
99 m3p1anEvenInteger = m3p1.Port( 'anEvenInteger' )
100 div2anInteger = div2.Port( 'anInteger' )
101 incraNewCount = incr.Port( 'aNewCount' )
102
103
104 GraphSyracuseC.Start()
105
106 test_ISEVEN.SuspendDone()
107 test_ISONE.SuspendDone()
108
109 test_ISEVEN.Resume()
110 test_ISONE.Resume()
111
112 # Suspend des nodes de tete des sous-graphes sauf test
113 m3p1.Suspend()
114 div2.Suspend()
115 incr.Suspend()
116
117 # Attentes de suspension de m3p1, div2, incr et result.
118 # Puis demandes de suspension après exécution
119 m3p1.SuspendDone()
120 div2.SuspendDone()
121 incr.SuspendDone()
122
123 # Attente de fin d'exécution de test
124 test_ISONE.DoneW()
125 test_ISEVEN.DoneW()
126
127 # Etats et Threads des nodes
128 GraphSyracuseC.PrintThreads()
129
130 while int( test_ISONEBoolOne.ToString() ) == 0 :
131     if int( test_ISEVENBoolEven.ToString() ) == 0 :
132         sts = m3p1.ReRun()
133         sts = incr.ReRun()
134         sts = m3p1.DoneW()
135         sts = test_ISEVENanInteger.Input( m3p1anEvenInteger.ToString() )
136         sts = test_ISONEanInteger.Input( m3p1anEvenInteger.ToString() )
137         sts = test_ISEVEN.ReRun()
138         sts = test_ISONE.ReRun()
139         sts = test_ISEVEN.DoneW()
140         sts = test_ISONE.DoneW()
141         sts = incr.DoneW()
142         sts = incraCount.Input( incraNewCount.ToString() )
143         print incraNewCount.ToString(),"m3p1",m3p1anEvenInteger.ToString(),test_ISEVENBoolEven.ToString()
144     while int( test_ISEVENBoolEven.ToString() ) == 1 :
145         sts = div2anEvenInteger.Input( test_ISEVENanInteger.ToString() )
146         sts = div2.ReRun()
147         sts = incr.ReRun()
148         sts = div2.DoneW()
149         sts = test_ISEVENanInteger.Input( div2anInteger.ToString() )
150         sts = test_ISONEanInteger.Input( div2anInteger.ToString() )
151         sts = test_ISEVEN.ReRun()
152         sts = test_ISONE.ReRun()
153         sts = test_ISEVEN.DoneW()
154         sts = test_ISONE.DoneW()
155         sts = incr.DoneW()
156         sts = incraCount.Input( incraNewCount.ToString() )
157         print incraNewCount.ToString(),"div2",div2anInteger.ToString(),test_ISEVENBoolEven.ToString()
158     sts = m3p1anOddInteger.Input( div2anInteger.ToString() )
159
160
161 GraphSyracuseC.PrintThreads()
162 m3p1.Resume()
163 div2.Resume()
164 incr.Resume()
165 test_ISONE.Resume()
166 test_ISEVEN.Resume()
167 GraphSyracuseC.DoneW()
168 GraphSyracuseC.PrintPorts()
169 GraphSyracuseC.PrintThreads()
170