Merge pull request #28 from avatao-content/linearfsm

Implement first version of LinearFSM
This commit is contained in:
Bokros Bálint 2018-04-10 17:34:46 +02:00 committed by GitHub
commit ba66188d80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View File

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

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

@ -0,0 +1,12 @@
# Copyright (C) 2018 Avatao.com Innovative Learning Kft.
# All Rights Reserved. See LICENSE file for details.
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__()