From cb4ba563e99f4a91df31f2751f949e05b2210f8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Fri, 20 Jul 2018 15:03:28 +0200 Subject: [PATCH] Fix LinearFSM not being compatible with controller stuff --- lib/tfw/linear_fsm.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) 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__()