mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-05 14:41:20 +00:00
Fix LinearFSM not being compatible with controller stuff
This commit is contained in:
parent
96b4e314a9
commit
cb4ba563e9
@ -1,6 +1,8 @@
|
|||||||
# Copyright (C) 2018 Avatao.com Innovative Learning Kft.
|
# Copyright (C) 2018 Avatao.com Innovative Learning Kft.
|
||||||
# All Rights Reserved. See LICENSE file for details.
|
# All Rights Reserved. See LICENSE file for details.
|
||||||
|
|
||||||
|
from transitions import State
|
||||||
|
|
||||||
from .fsm_base import FSMBase
|
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
|
(0) -- step_1 --> (1) -- step_2 --> (2) -- step_3 --> (3) ... and so on
|
||||||
"""
|
"""
|
||||||
def __init__(self, number_of_steps):
|
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 = []
|
self.transitions = []
|
||||||
for index in self.states[:-1]:
|
for state in self.states[:-1]:
|
||||||
self.transitions.append({
|
self.transitions.append({
|
||||||
'trigger': f'step_{int(index)+1}',
|
'trigger': f'step_{int(state.name)+1}',
|
||||||
'source': index,
|
'source': state.name,
|
||||||
'dest': str(int(index)+1)
|
'dest': str(int(state.name)+1)
|
||||||
})
|
})
|
||||||
self.transitions.append({
|
self.transitions.append({
|
||||||
'trigger': 'step_next',
|
'trigger': 'step_next',
|
||||||
'source': index,
|
'source': state.name,
|
||||||
'dest': str(int(index)+1)
|
'dest': str(int(state.name)+1)
|
||||||
})
|
})
|
||||||
super(LinearFSM, self).__init__()
|
super(LinearFSM, self).__init__()
|
||||||
|
Loading…
Reference in New Issue
Block a user