Implement first version of LinearFSM

This commit is contained in:
Kristóf Tóth 2018-04-07 15:21:13 +02:00
parent 1922050e87
commit 29da0a7ca6
2 changed files with 10 additions and 0 deletions

View File

@ -3,3 +3,4 @@
from .event_handler_base import TriggerlessEventHandler, TriggeredEventHandler
from .fsm_base import FSMBase
from .linear_fsm import LinearFSM

9
lib/tfw/linear_fsm.py Normal file
View File

@ -0,0 +1,9 @@
from .fsm_base import FSMBase
class LinearFSM(FSMBase):
def __init__(self, number_of_steps):
self.states = list(map(str, range(number_of_steps)))
self.transitions = [{'trigger': 'step', 'source': index, 'dest': str(int(index)+1)}
for index in self.states[:-1]]
super(LinearFSM, self).__init__()