baseimage-tutorial-framework/lib/tfw/builtins/fsm_aware_event_handler.py

27 lines
795 B
Python
Raw Normal View History

# Copyright (C) 2018 Avatao.com Innovative Learning Kft.
# All Rights Reserved. See LICENSE file for details.
from abc import ABC
2019-06-28 13:11:02 +00:00
from tfw.components import FSMAware
from tfw.networking import Scope
2019-06-28 13:11:02 +00:00
from .event_handler import EventHandler
2019-06-28 13:11:02 +00:00
class FSMAwareEventHandler(EventHandler, FSMAware, ABC):
# pylint: disable=abstract-method
"""
Abstract base class for EventHandlers which automatically
keep track of the state of the TFW FSM.
"""
2019-06-28 13:11:02 +00:00
def __init__(self, key, scope=Scope.ZMQ):
EventHandler.__init__(self, key, scope=scope)
FSMAware.__init__(self)
self.subscribe('fsm_update')
def dispatch_handling(self, message):
2019-06-28 13:16:08 +00:00
if self.refresh_on_fsm_update(message):
return None
return super().dispatch_handling(message)