11### Issue 308
22
3- A StateMachine that exercices the example given on issue
3+ A StateMachine that exercises the example given on issue
44#[ 308] ( https://github.com/fgmacedo/python-statemachine/issues/308 ) .
55
6- On this example, we share the transitions list between events.
6+ In this example, we share the transition list between events.
77
88``` py
99>> > from statemachine import StateMachine, State
@@ -14,12 +14,12 @@ On this example, we share the transitions list between events.
1414... state3 = State(' s3' )
1515... state4 = State(' s4' , final = True )
1616...
17- ... trans12 = state1.to(state2)
18- ... trans23 = state2.to(state3)
19- ... trans34 = state3.to(state4)
17+ ... event1 = state1.to(state2)
18+ ... event2 = state2.to(state3)
19+ ... event3 = state3.to(state4)
2020...
2121... # cycle = state1.to(state2) | state2.to(state3) | state3.to(state4)
22- ... cycle = trans12 | trans23 | trans34
22+ ... cycle = event1 | event2 | event3
2323...
2424... def before_cycle (self ):
2525... print (" before cycle" )
@@ -55,31 +55,31 @@ On this example, we share the transitions list between events.
5555... print (' exit state4' )
5656...
5757... def before_trans12 (self ):
58- ... print (' before trans12 ' )
58+ ... print (' before event1 ' )
5959...
6060... def on_trans12 (self ):
61- ... print (' on trans12 ' )
61+ ... print (' on event1 ' )
6262...
6363... def after_trans12 (self ):
64- ... print (' after trans12 ' )
64+ ... print (' after event1 ' )
6565...
6666... def before_trans23 (self ):
67- ... print (' before trans23 ' )
67+ ... print (' before event2 ' )
6868...
6969... def on_trans23 (self ):
70- ... print (' on trans23 ' )
70+ ... print (' on event2 ' )
7171...
7272... def after_trans23 (self ):
73- ... print (' after trans23 ' )
73+ ... print (' after event2 ' )
7474...
7575... def before_trans34 (self ):
76- ... print (' before trans34 ' )
76+ ... print (' before event3 ' )
7777...
7878... def on_trans34 (self ):
79- ... print (' on trans34 ' )
79+ ... print (' on event3 ' )
8080...
8181... def after_trans34 (self ):
82- ... print (' after trans34 ' )
82+ ... print (' after event3 ' )
8383...
8484
8585```
@@ -94,35 +94,26 @@ enter state1
9494>> > m.state1.is_active, m.state2.is_active, m.state3.is_active, m.state4.is_active, m.current_state ; _ = m.cycle()
9595(True , False , False , False , State(' s1' , id = ' state1' , value = ' state1' , initial = True , final = False ))
9696before cycle
97- before trans12
9897exit state1
9998on cycle
100- on trans12
10199enter state2
102100after cycle
103- after trans12
104101
105102>> > m.state1.is_active, m.state2.is_active, m.state3.is_active, m.state4.is_active, m.current_state ; _ = m.cycle()
106103(False , True , False , False , State(' s2' , id = ' state2' , value = ' state2' , initial = False , final = False ))
107104before cycle
108- before trans23
109105exit state2
110106on cycle
111- on trans23
112107enter state3
113108after cycle
114- after trans23
115109
116110>> > m.state1.is_active, m.state2.is_active, m.state3.is_active, m.state4.is_active, m.current_state ; _ = m.cycle()
117111(False , False , True , False , State(' s3' , id = ' state3' , value = ' state3' , initial = False , final = False ))
118112before cycle
119- before trans34
120113exit state3
121114on cycle
122- on trans34
123115enter state4
124116after cycle
125- after trans34
126117
127118>> > m.state1.is_active, m.state2.is_active, m.state3.is_active, m.state4.is_active, m.current_state
128119(False , False , False , True , State(' s4' , id = ' state4' , value = ' state4' , initial = False , final = True ))
0 commit comments