2018-07-26 11:59:06 +00:00
|
|
|
# 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
|
2018-07-26 11:59:06 +00:00
|
|
|
|
2019-06-28 13:11:02 +00:00
|
|
|
from .event_handler import EventHandler
|
2018-07-26 11:59:06 +00:00
|
|
|
|
2019-06-28 13:11:02 +00:00
|
|
|
|
|
|
|
class FSMAwareEventHandler(EventHandler, FSMAware, ABC):
|
2018-07-26 11:59:06 +00:00
|
|
|
# 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)
|
2018-07-26 11:59:06 +00:00
|
|
|
FSMAware.__init__(self)
|
|
|
|
self.subscribe('fsm_update')
|
|
|
|
|
|
|
|
def dispatch_handling(self, message):
|
2019-06-28 14:50:36 +00:00
|
|
|
if not self.refresh_on_fsm_update(message):
|
|
|
|
super().dispatch_handling(message)
|