Salome HOME
4034379ba65ba25005ce6e78e01b0425e96892c2
[modules/superv.git] / examples / GraphSyracuseC_Gate.py
1
2 # Generated python file of Graph GraphSyracuseC_Gate
3
4 from SuperV import *
5 # Graph creation 
6 GraphSyracuseC_Gate = Graph( 'GraphSyracuseC_Gate' )
7 GraphSyracuseC_Gate.SetName( 'GraphSyracuseC_Gate' )
8 GraphSyracuseC_Gate.SetAuthor( 'JR' )
9 GraphSyracuseC_Gate.SetComment( 'Syracuse algorithm' )
10 GraphSyracuseC_Gate.Coords( 0 , 0 )
11
12 # Creation of Computing Nodes
13 test_ISEVEN = GraphSyracuseC_Gate.Node( 'SyrComponent' , 'SyrComponent' , 'C_ISEVEN' )
14 test_ISEVEN.SetName( 'test_ISEVEN' )
15 test_ISEVEN.SetAuthor( '' )
16 test_ISEVEN.SetContainer( 'localhost/FactoryServer' )
17 test_ISEVEN.SetComment( '' )
18 test_ISEVEN.Coords( 5 , 416 )
19 test_ISONE = GraphSyracuseC_Gate.Node( 'SyrComponent' , 'SyrComponent' , 'C_ISONE' )
20 test_ISONE.SetName( 'test_ISONE' )
21 test_ISONE.SetAuthor( '' )
22 test_ISONE.SetContainer( 'localhost/FactoryServer' )
23 test_ISONE.SetComment( '' )
24 test_ISONE.Coords( 7 , 232 )
25 m3p1 = GraphSyracuseC_Gate.Node( 'SyrComponent' , 'SyrComponent' , 'C_M3P1' )
26 m3p1.SetName( 'm3p1' )
27 m3p1.SetAuthor( '' )
28 m3p1.SetContainer( 'localhost/FactoryServer' )
29 m3p1.SetComment( '' )
30 m3p1.Coords( 180 , 417 )
31 div2 = GraphSyracuseC_Gate.Node( 'SyrComponent' , 'SyrComponent' , 'C_DIV2' )
32 div2.SetName( 'div2' )
33 div2.SetAuthor( '' )
34 div2.SetContainer( 'localhost/FactoryServer' )
35 div2.SetComment( '' )
36 div2.Coords( 435 , 7 )
37 div2_ISEVEN = GraphSyracuseC_Gate.Node( 'SyrComponent' , 'SyrComponent' , 'C_ISEVEN' )
38 div2_ISEVEN.SetName( 'div2_ISEVEN' )
39 div2_ISEVEN.SetAuthor( '' )
40 div2_ISEVEN.SetContainer( 'localhost/FactoryServer' )
41 div2_ISEVEN.SetComment( '' )
42 div2_ISEVEN.Coords( 619 , 191 )
43 div2_ISONE = GraphSyracuseC_Gate.Node( 'SyrComponent' , 'SyrComponent' , 'C_ISONE' )
44 div2_ISONE.SetName( 'div2_ISONE' )
45 div2_ISONE.SetAuthor( '' )
46 div2_ISONE.SetContainer( 'localhost/FactoryServer' )
47 div2_ISONE.SetComment( '' )
48 div2_ISONE.Coords( 616 , 6 )
49 incr = GraphSyracuseC_Gate.Node( 'SyrComponent' , 'SyrComponent' , 'C_INCR' )
50 incr.SetName( 'incr' )
51 incr.SetAuthor( '' )
52 incr.SetContainer( 'localhost/FactoryServer' )
53 incr.SetComment( '' )
54 incr.Coords( 434 , 193 )
55
56 # Creation of intermediate Output variables and of Computing Links
57 test_ISEVENOutGate = test_ISEVEN.Port( 'OutGate' )
58 m3p1InGate = GraphSyracuseC_Gate.Link( test_ISEVENOutGate , m3p1.Port( 'InGate' ) )
59 m3p1anEvenInteger = m3p1.Port( 'anEvenInteger' )
60 div2anEvenInteger = GraphSyracuseC_Gate.Link( m3p1anEvenInteger , div2.Port( 'anEvenInteger' ) )
61 div2anEvenInteger.AddCoord( 1 , 368 , 158 )
62 div2anEvenInteger.AddCoord( 2 , 369 , 568 )
63 div2anInteger = div2.Port( 'anInteger' )
64 div2_ISONEanInteger = GraphSyracuseC_Gate.Link( div2anInteger , div2_ISONE.Port( 'anInteger' ) )
65 div2_ISEVENanInteger = GraphSyracuseC_Gate.Link( div2anInteger , div2_ISEVEN.Port( 'anInteger' ) )
66 div2_ISEVENanInteger.AddCoord( 1 , 603 , 342 )
67 div2_ISEVENanInteger.AddCoord( 2 , 603 , 158 )
68
69 # Creation of Input datas
70 curM3P1 = m3p1.Input( 'anOddInteger' , 31)
71 curtestISEVEN = test_ISEVEN.Input( 'anInteger' , curM3P1.ToAny() )
72 curtestISONE = test_ISONE.Input( 'anInteger' , curM3P1.ToAny() )
73 div2InanEvenInteger = div2.Port( 'anEvenInteger' )
74 incraCount = incr.Input( 'aCount' , 0)
75
76 # Creation of Output variables
77 test_ISEVENBoolEven = test_ISEVEN.Port( 'BoolEven' )
78 test_ISONEBoolOne = test_ISONE.Port( 'BoolOne' )
79 div2_ISEVENBoolEven = div2_ISEVEN.Port( 'BoolEven' )
80 div2_ISONEBoolOne = div2_ISONE.Port( 'BoolOne' )
81 incraNewCount = incr.Port( 'aNewCount' )
82
83 GraphSyracuseC_Gate.IsValid()
84
85 GraphSyracuseC_Gate.ThreadsMax()
86
87 GraphSyracuseC_Gate.LevelMax()
88
89 GraphSyracuseC_Gate.GraphsNumber()
90
91 GraphSyracuseC_Gate.IsExecutable()
92
93 exec GraphSyracuseC_Gate.ListNodes()
94
95 curM3P1 = m3p1.Port( 'anOddInteger' )
96 m3p1anEvenInteger = m3p1.Port( 'anEvenInteger' )
97 curtestISEVEN = test_ISEVEN.Port( 'anInteger' )
98 curtestISONE = test_ISONE.Port( 'anInteger' )
99 div2anEvenInteger = div2.Port( 'anEvenInteger' )
100 div2anInteger = div2.Port( 'anInteger' )
101 incraCount = incr.Port( 'aCount' )
102
103 # Creation of Output variables
104 test_ISEVENBoolEven = test_ISEVEN.Port( 'BoolEven' )
105 test_ISONEBoolOne = test_ISONE.Port( 'BoolOne' )
106 div2_ISEVENBoolEven = div2_ISEVEN.Port( 'BoolEven' )
107 div2_ISONEBoolOne = div2_ISONE.Port( 'BoolOne' )
108 incraNewCount = incr.Port( 'aNewCount' )
109
110 GraphSyracuseC_Gate.Start()
111
112 m3p1.Suspend()
113
114 div2_ISEVEN.SuspendDone()
115 div2_ISONE.SuspendDone()
116
117 test_ISEVEN.Resume()
118 test_ISONE.Resume()
119
120 # Attente de fin d'execution de test
121 test_ISONE.DoneW()
122 test_ISEVEN.DoneW()
123
124 m3p1.SuspendedW()
125 incr.SuspendedW()
126 incr.SuspendDone()
127
128 # Etats et Threads des nodes
129 GraphSyracuseC_Gate.PrintThreads()
130
131 BoolOne = int( test_ISONEBoolOne.ToString() )
132 BoolEven = int( test_ISEVENBoolEven.ToString() )
133 while BoolOne == 0 :
134     if BoolEven == 0 :
135         sts = div2_ISONE.ReRunAt('m3p1')
136         sts = incr.ReRun()
137         sts = m3p1.DoneW()
138         sts = incr.DoneW()
139         sts = incraCount.Input( int( incraNewCount.ToString() ) + 1 )
140         BoolEven = 1 
141         BoolOne = 0
142         Current = int( m3p1anEvenInteger.ToString() )
143         print incraNewCount.ToString(),"m3p1",Current,BoolEven
144     while BoolEven == 1 :
145         sts = incr.ReRun()
146         sts = div2.DoneW()
147         sts = div2_ISEVEN.DoneW()
148         sts = div2_ISONE.DoneW()
149         sts = incr.DoneW()
150         sts = incraCount.Input( incraNewCount.ToString() )
151         BoolOne = int( div2_ISONEBoolOne.ToString() )
152         BoolEven = int( div2_ISEVENBoolEven.ToString() )
153         Current = int( div2anInteger.ToString() )
154         print incraNewCount.ToString(),"div2",Current,BoolEven,BoolOne
155         if BoolEven == 1 :
156             sts = div2InanEvenInteger.Input( Current )
157             sts = div2_ISONE.ReRunAt('div2')
158     sts = curM3P1.Input( Current )
159     sts = m3p1InGate.InPort().Input( 1 )
160
161
162 GraphSyracuseC_Gate.PrintThreads()
163 m3p1.Resume()
164 div2.Resume()
165 incr.Resume()
166 div2_ISONE.Resume()
167 div2_ISEVEN.Resume()
168 GraphSyracuseC_Gate.DoneW()
169 GraphSyracuseC_Gate.PrintPorts()
170 GraphSyracuseC_Gate.PrintThreads()
171