Salome HOME
NRI : Add Dataflow examples.
[modules/superv.git] / examples / GraphSyracuseCEv.py
1
2 # Generated python file of Graph GraphSyracuseCEv
3
4 from SuperV import *
5 import SUPERV
6 import SUPERV_idl
7
8 # Graph creation 
9 GraphSyracuseCEv = Graph( 'GraphSyracuseCEv' )
10 GraphSyracuseCEv.SetName( 'GraphSyracuseCEv' )
11 GraphSyracuseCEv.SetAuthor( 'JR' )
12 GraphSyracuseCEv.SetComment( 'Syracuse algorithm' )
13 GraphSyracuseCEv.Coords( 0 , 0 )
14
15 # Creation of Computing Nodes
16 test_ISEVEN = GraphSyracuseCEv.Node( 'SyrComponent' , 'SyrComponent' , 'C_ISEVEN' )
17 test_ISEVEN.SetName( 'test_ISEVEN' )
18 test_ISEVEN.SetAuthor( '' )
19 test_ISEVEN.SetContainer( 'localhost/FactoryServer' )
20 test_ISEVEN.SetComment( '' )
21 test_ISEVEN.Coords( 252 , 266 )
22 test_ISONE = GraphSyracuseCEv.Node( 'SyrComponent' , 'SyrComponent' , 'C_ISONE' )
23 test_ISONE.SetName( 'test_ISONE' )
24 test_ISONE.SetAuthor( '' )
25 test_ISONE.SetContainer( 'localhost/FactoryServer' )
26 test_ISONE.SetComment( '' )
27 test_ISONE.Coords( 268 , 29 )
28 m3p1 = GraphSyracuseCEv.Node( 'SyrComponent' , 'SyrComponent' , 'C_M3P1' )
29 m3p1.SetName( 'm3p1' )
30 m3p1.SetAuthor( '' )
31 m3p1.SetContainer( 'localhost/FactoryServer' )
32 m3p1.SetComment( '' )
33 m3p1.Coords( 644 , 410 )
34 div2 = GraphSyracuseCEv.Node( 'SyrComponent' , 'SyrComponent' , 'C_DIV2' )
35 div2.SetName( 'div2' )
36 div2.SetAuthor( '' )
37 div2.SetContainer( 'localhost/FactoryServer' )
38 div2.SetComment( '' )
39 div2.Coords( 648 , 209 )
40 incr = GraphSyracuseCEv.Node( 'SyrComponent' , 'SyrComponent' , 'C_INCR' )
41 incr.SetName( 'incr' )
42 incr.SetAuthor( '' )
43 incr.SetContainer( 'localhost/FactoryServer' )
44 incr.SetComment( '' )
45 incr.Coords( 640 , 2 )
46
47 # Creation of Input datas
48 test_ISEVENanInteger = test_ISEVEN.Input( 'anInteger' , 31)
49 test_ISONEanInteger = test_ISONE.Input( 'anInteger' , 31)
50 m3p1anOddInteger = m3p1.Input( 'anOddInteger' , 31)
51 div2anEvenInteger = div2.Input( 'anEvenInteger' , 31)
52 incraCount = incr.Input( 'aCount' , 0)
53
54 GraphSyracuseCEv.IsValid()
55
56 GraphSyracuseCEv.ThreadsMax()
57
58 GraphSyracuseCEv.LevelMax()
59
60 GraphSyracuseCEv.GraphsNumber()
61
62 GraphSyracuseCEv.IsExecutable()
63
64
65
66
67 exec GraphSyracuseCEv.ListNodes()
68
69 test_ISEVENanInteger = test_ISEVEN.Port( 'anInteger' )
70 test_ISEVENBoolEven = test_ISEVEN.Port( 'BoolEven' )
71 test_ISONEanInteger = test_ISONE.Port( 'anInteger' )
72 test_ISONEBoolOne = test_ISONE.Port( 'BoolOne' )
73 m3p1anOddInteger = m3p1.Port( 'anOddInteger' )
74 m3p1anEvenInteger = m3p1.Port( 'anEvenInteger' )
75 div2anEvenInteger = div2.Port( 'anEvenInteger' )
76 div2anInteger = div2.Port( 'anInteger' )
77 incraCount = incr.Port( 'aCount' )
78 incraNewCount = incr.Port( 'aNewCount' )
79
80 GraphSyracuseCEv.Start()
81
82 test_ISEVEN.SuspendDone()
83 test_ISONE.SuspendDone()
84
85 test_ISEVEN.Resume()
86 test_ISONE.Resume()
87
88 m3p1.SuspendDone()
89 div2.SuspendDone()
90 incr.SuspendDone()
91
92 test_ISEVEN.DoneW()
93 test_ISONE.DoneW()
94
95 aStatus,aNode,anEvent,aState = GraphSyracuseCEv.Event()
96 while aNode != None :
97     if int( test_ISONEBoolOne.ToString() ) == 0 :
98         if int( test_ISEVENBoolEven.ToString() ) == 0 :
99             while aNode != None :
100                 if aNode.Name() == 'm3p1' :
101                     if aState == SUPERV_idl._0_SUPERV.SuspendReadyState :
102                         sts = m3p1.ReRun()
103                         sts = incr.ReRun()
104                     else :
105                         if aState == SUPERV_idl._0_SUPERV.SuspendDoneState :
106                             sts = test_ISEVENanInteger.Input( m3p1anEvenInteger.ToString() )
107                             sts = test_ISONEanInteger.Input( m3p1anEvenInteger.ToString() )
108                             sts = test_ISEVEN.ReRun()
109                             sts = test_ISONE.ReRun()
110                 else :
111                     if ( aNode.Name() == 'incr' ) & ( aState == SUPERV_idl._0_SUPERV.SuspendDoneState ) :
112                         sts = incraCount.Input( incraNewCount.ToString() )
113                 aStatus,aNode,anEvent,aState = GraphSyracuseCEv.Event()
114             print incraNewCount.ToString(),"m3p1",m3p1anEvenInteger.ToString()
115             sts = div2anEvenInteger.Input( m3p1anEvenInteger.ToString() )
116         while int( test_ISEVENBoolEven.ToString() ) == 1 :
117             sts = div2.ReRun()
118             sts = incr.ReRun()
119             aStatus,aNode,anEvent,aState = GraphSyracuseCEv.Event()
120             while aNode != None :
121                 if ( aNode.Name() == 'div2' ) & ( aState == SUPERV_idl._0_SUPERV.SuspendDoneState ) :
122                     sts = test_ISEVENanInteger.Input( div2anInteger.ToString() )
123                     sts = test_ISONEanInteger.Input( div2anInteger.ToString() )
124                     sts = test_ISEVEN.ReRun()
125                     sts = test_ISONE.ReRun()
126                 aStatus,aNode,anEvent,aState = GraphSyracuseCEv.Event()
127             sts = incraCount.Input( incraNewCount.ToString() )
128             print incraNewCount.ToString(),"div2",div2anInteger.ToString()
129             sts = m3p1anOddInteger.Input( div2anInteger.ToString() )
130             sts = div2anEvenInteger.Input( div2anInteger.ToString() )
131             if int( test_ISONEBoolOne.ToString() ) == 0 :
132                 sts = m3p1.ReRun()
133                 sts = incr.ReRun()
134                 aStatus,aNode,anEvent,aState = GraphSyracuseCEv.Event()
135             else :
136                 GraphSyracuseCEv.PrintThreads()
137                 m3p1.Resume()
138                 div2.Resume()
139                 incr.Resume()
140                 test_ISONE.Resume()
141                 test_ISEVEN.Resume()
142     aStatus,aNode,anEvent,aState = GraphSyracuseCEv.Event()
143
144 GraphSyracuseCEv.DoneW()
145 GraphSyracuseCEv.PrintThreads()
146 GraphSyracuseCEv.PrintPorts()