From 4236a17b692971d54a61a40b98d860752a39650c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Sat, 14 Jul 2018 20:45:26 +0200 Subject: [PATCH] Include last trigger in fsm_update messages --- lib/tfw/components/fsm_managing_event_handler.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/tfw/components/fsm_managing_event_handler.py b/lib/tfw/components/fsm_managing_event_handler.py index f84186f..1068bbd 100644 --- a/lib/tfw/components/fsm_managing_event_handler.py +++ b/lib/tfw/components/fsm_managing_event_handler.py @@ -28,7 +28,8 @@ class FSMManagingEventHandler(EventHandlerBase): LOG.error('IGNORING MESSAGE: Invalid message received: %s', message) def handle_trigger(self, data): - self.fsm.step(data['value']) + trigger = data['value'] + self.fsm.step(trigger) return data def handle_update(self, data): @@ -51,7 +52,9 @@ class FSMUpdater: {'trigger': trigger} for trigger in self.fsm.get_triggers(self.fsm.state) ] + last_trigger = self.fsm.trigger_history[-1] if self.fsm.trigger_history else None return { 'current_state': state, - 'valid_transitions': valid_transitions + 'valid_transitions': valid_transitions, + 'last_trigger': last_trigger }