2018-04-10 09:19:53 +00:00
|
|
|
from tfw import LinearFSM
|
|
|
|
from tfw.networking import MessageSender
|
|
|
|
|
|
|
|
|
|
|
|
class TestFSM(LinearFSM):
|
2018-04-19 09:22:43 +00:00
|
|
|
# pylint: disable=unused-argument
|
|
|
|
|
2018-04-10 09:19:53 +00:00
|
|
|
def __init__(self, number_of_steps):
|
|
|
|
super().__init__(number_of_steps)
|
|
|
|
self.message_sender = MessageSender()
|
|
|
|
|
|
|
|
def on_enter_1(self, event_data):
|
|
|
|
self.state_notify(1)
|
|
|
|
|
|
|
|
def on_enter_2(self, event_data):
|
|
|
|
self.state_notify(2)
|
|
|
|
|
|
|
|
def on_enter_3(self, event_data):
|
|
|
|
self.state_notify(3)
|
|
|
|
|
|
|
|
def on_enter_4(self, event_data):
|
|
|
|
self.state_notify(4)
|
|
|
|
|
|
|
|
def on_enter_5(self, event_data):
|
|
|
|
self.state_notify(5)
|
|
|
|
|
|
|
|
def state_notify(self, state):
|
2018-04-19 07:19:32 +00:00
|
|
|
self.message_sender.send('TestFSM', f'Entered state {state}!')
|