1 # Copyright (C) 2003 CEA/DEN, EDF R&D
5 # File : GraphSyracuseC_Gate.py
6 # Module : SuperVisionTest
10 GraphSyracuseC_Gate = Graph( 'GraphSyracuseC_Gate' )
11 GraphSyracuseC_Gate.SetName( 'GraphSyracuseC_Gate' )
12 GraphSyracuseC_Gate.SetAuthor( 'JR' )
13 GraphSyracuseC_Gate.SetComment( 'Syracuse algorithm' )
14 GraphSyracuseC_Gate.Coords( 0 , 0 )
16 # Creation of Factory Nodes
17 test_ISEVEN = GraphSyracuseC_Gate.FNode( 'SyrComponent' , 'SyrComponent' , 'C_ISEVEN' )
18 test_ISEVEN.SetName( 'test_ISEVEN' )
19 test_ISEVEN.SetAuthor( '' )
20 test_ISEVEN.SetContainer( 'localhost/FactoryServer' )
21 test_ISEVEN.SetComment( 'C_ISEVEN from SyrComponent' )
22 test_ISEVEN.Coords( 5 , 416 )
23 test_ISONE = GraphSyracuseC_Gate.FNode( 'SyrComponent' , 'SyrComponent' , 'C_ISONE' )
24 test_ISONE.SetName( 'test_ISONE' )
25 test_ISONE.SetAuthor( '' )
26 test_ISONE.SetContainer( 'localhost/FactoryServer' )
27 test_ISONE.SetComment( 'C_ISONE from SyrComponent' )
28 test_ISONE.Coords( 7 , 232 )
29 m3p1 = GraphSyracuseC_Gate.FNode( 'SyrComponent' , 'SyrComponent' , 'C_M3P1' )
30 m3p1.SetName( 'm3p1' )
32 m3p1.SetContainer( 'localhost/FactoryServer' )
33 m3p1.SetComment( 'C_M3P1 from SyrComponent' )
34 m3p1.Coords( 180 , 417 )
35 div2 = GraphSyracuseC_Gate.FNode( 'SyrComponent' , 'SyrComponent' , 'C_DIV2' )
36 div2.SetName( 'div2' )
38 div2.SetContainer( 'localhost/FactoryServer' )
39 div2.SetComment( 'C_DIV2 from SyrComponent' )
40 div2.Coords( 435 , 7 )
41 div2_ISEVEN = GraphSyracuseC_Gate.FNode( 'SyrComponent' , 'SyrComponent' , 'C_ISEVEN' )
42 div2_ISEVEN.SetName( 'div2_ISEVEN' )
43 div2_ISEVEN.SetAuthor( '' )
44 div2_ISEVEN.SetContainer( 'localhost/FactoryServer' )
45 div2_ISEVEN.SetComment( 'C_ISEVEN from SyrComponent' )
46 div2_ISEVEN.Coords( 663 , 193 )
47 div2_ISONE = GraphSyracuseC_Gate.FNode( 'SyrComponent' , 'SyrComponent' , 'C_ISONE' )
48 div2_ISONE.SetName( 'div2_ISONE' )
49 div2_ISONE.SetAuthor( '' )
50 div2_ISONE.SetContainer( 'localhost/FactoryServer' )
51 div2_ISONE.SetComment( 'C_ISONE from SyrComponent' )
52 div2_ISONE.Coords( 651 , 6 )
53 incr = GraphSyracuseC_Gate.FNode( 'SyrComponent' , 'SyrComponent' , 'C_INCR' )
54 incr.SetName( 'incr' )
56 incr.SetContainer( 'localhost/FactoryServer' )
57 incr.SetComment( 'C_INCR from SyrComponent' )
58 incr.Coords( 434 , 193 )
60 # Creation of intermediate Output variables and of Control Links
61 test_ISEVENOutGate = test_ISEVEN.Port( 'OutGate' )
62 m3p1InGate = GraphSyracuseC_Gate.Link( test_ISEVENOutGate , m3p1.Port( 'InGate' ) )
63 m3p1anEvenInteger = m3p1.Port( 'anEvenInteger' )
64 div2anEvenInteger = GraphSyracuseC_Gate.Link( m3p1anEvenInteger , div2.Port( 'anEvenInteger' ) )
65 div2anEvenInteger.AddCoord( 1 , 373 , 117 )
66 div2anEvenInteger.AddCoord( 2 , 373 , 528 )
67 div2anInteger = div2.Port( 'anInteger' )
68 div2_ISONEanInteger = GraphSyracuseC_Gate.Link( div2anInteger , div2_ISONE.Port( 'anInteger' ) )
69 div2_ISEVENanInteger = GraphSyracuseC_Gate.Link( div2anInteger , div2_ISEVEN.Port( 'anInteger' ) )
70 div2_ISEVENanInteger.AddCoord( 1 , 626 , 302 )
71 div2_ISEVENanInteger.AddCoord( 2 , 626 , 116 )
73 # Creation of Input datas
74 test_ISEVENanInteger = test_ISEVEN.Input( 'anInteger' , 31)
75 test_ISONEanInteger = test_ISONE.Input( 'anInteger' , 31)
76 m3p1anOddInteger = m3p1.Input( 'anOddInteger' , 31)
77 incraCount = incr.Input( 'aCount' , 0)
79 # Creation of Output variables
80 test_ISEVENBoolEven = test_ISEVEN.Port( 'BoolEven' )
81 test_ISONEBoolOne = test_ISONE.Port( 'BoolOne' )
82 div2_ISEVENBoolEven = div2_ISEVEN.Port( 'BoolEven' )
83 div2_ISONEBoolOne = div2_ISONE.Port( 'BoolOne' )
84 incraNewCount = incr.Port( 'aNewCount' )
87 GraphSyracuseC_Gate.Start()
89 div2InanInteger = div2.Port( 'anEvenInteger' )
93 div2_ISEVEN.SuspendDone()
94 div2_ISONE.SuspendDone()
99 # Attente de fin d'execution de test
107 # Etats et Threads des nodes
108 GraphSyracuseC_Gate.PrintThreads()
110 BoolOne = int( test_ISONEBoolOne.ToString() )
111 BoolEven = int( test_ISEVENBoolEven.ToString() )
114 sts = div2_ISONE.ReRunAt('m3p1')
116 print 'div2_ISONE.ReRunAt error'
120 print 'incr.ReRun error'
124 print 'm3p1.DoneW error'
128 print 'incr.DoneW error'
130 sts = incraCount.Input( int( incraNewCount.ToString() ) + 1 )
132 print 'incraCount.Input error'
136 Current = int( m3p1anEvenInteger.ToString() )
137 print incraNewCount.ToString(),"m3p1",Current,BoolEven
142 while BoolEven == 1 :
145 print 'incr.ReRun error'
149 print 'div2.DoneW error'
151 sts = div2_ISEVEN.DoneW()
153 print 'div2_ISEVEN.DoneW error'
155 sts = div2_ISONE.DoneW()
157 print 'div2_ISONE.DoneW error'
161 print 'incr.DoneW error'
163 sts = incraCount.Input( incraNewCount.ToString() )
165 print 'incraCount.Input error'
167 BoolOne = int( div2_ISONEBoolOne.ToString() )
168 BoolEven = int( div2_ISEVENBoolEven.ToString() )
169 Current = int( div2anInteger.ToString() )
170 print incraNewCount.ToString(),"div2",Current,BoolEven,BoolOne
174 sts = div2InanInteger.Input( Current )
176 print 'div2InanInteger.Input error'
178 sts = div2_ISONE.ReRunAt('div2')
180 print 'div2_ISONE.ReRunAt error'
184 sts = m3p1anOddInteger.Input( Current )
186 print 'm3p1anOddInteger.Input error'
188 sts = m3p1InGate.InPort().Input( 1 )
190 print 'm3p1InGate.InPort error'
194 GraphSyracuseC_Gate.PrintThreads()
200 GraphSyracuseC_Gate.DoneW()
201 GraphSyracuseC_Gate.PrintPorts()
202 GraphSyracuseC_Gate.PrintThreads()