mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-22 17:12:55 +08:00
28 lines
366 B
Python
28 lines
366 B
Python
|
import fsm
|
||
|
|
||
|
|
||
|
def state1():
|
||
|
print("state1")
|
||
|
return "state2"
|
||
|
|
||
|
|
||
|
def state2():
|
||
|
print("state2")
|
||
|
return state3
|
||
|
|
||
|
|
||
|
def state3():
|
||
|
print("state3")
|
||
|
fsm.stop()
|
||
|
return "state1"
|
||
|
|
||
|
|
||
|
def test_fsm():
|
||
|
fsm.addState(state1, "state1")
|
||
|
fsm.addState(state2, "state2")
|
||
|
fsm.addState(state3, "state3")
|
||
|
fsm.start("state1")
|
||
|
fsm.wait()
|
||
|
|
||
|
test_fsm()
|