diff --git a/lib/tfw/linear_fsm.py b/lib/tfw/linear_fsm.py index 1f0e3af..a053c30 100644 --- a/lib/tfw/linear_fsm.py +++ b/lib/tfw/linear_fsm.py @@ -1,6 +1,8 @@ # Copyright (C) 2018 Avatao.com Innovative Learning Kft. # All Rights Reserved. See LICENSE file for details. +from transitions import State + from .fsm_base import FSMBase @@ -13,17 +15,17 @@ class LinearFSM(FSMBase): (0) -- step_1 --> (1) -- step_2 --> (2) -- step_3 --> (3) ... and so on """ def __init__(self, number_of_steps): - self.states = list(map(str, range(number_of_steps))) + self.states = [State(name=str(index)) for index in range(number_of_steps)] self.transitions = [] - for index in self.states[:-1]: + for state in self.states[:-1]: self.transitions.append({ - 'trigger': f'step_{int(index)+1}', - 'source': index, - 'dest': str(int(index)+1) + 'trigger': f'step_{int(state.name)+1}', + 'source': state.name, + 'dest': str(int(state.name)+1) }) self.transitions.append({ 'trigger': 'step_next', - 'source': index, - 'dest': str(int(index)+1) + 'source': state.name, + 'dest': str(int(state.name)+1) }) super(LinearFSM, self).__init__()