Commit 09e04442 authored by David Trattnig's avatar David Trattnig
Browse files

Event for end of timeslot. #38

parent f761dc9e
......@@ -204,6 +204,19 @@ class EngineEventDispatcher():
thread.start()
def on_timeslot_end(self, timeslot):
"""
Called when a timeslot ends.
"""
def func(self, timeslot):
self.logger.debug("on_timeslot_end(..)")
self.fallback_manager.on_timeslot_end(timeslot)
self.call_event("on_timeslot_end", timeslot)
thread = Thread(target = func, args = (self, timeslot))
thread.start()
def on_play(self, entry):
"""
Event Handler which is called by the engine when some entry is actually playing.
......
......@@ -52,7 +52,7 @@ class EntryQueueState(Enum):
class TimeslotCommand(EngineExecutor):
"""
Command for triggering start of timeslot events.
Command for triggering start and end of timeslot events.
"""
engine = None
......@@ -68,8 +68,13 @@ class TimeslotCommand(EngineExecutor):
def do_start_timeslot(timeslot):
self.logger.info(SU.cyan(f"=== on_timeslot_start('{timeslot}') ==="))
self.engine.event_dispatcher.on_timeslot_start(timeslot)
super().__init__("TIMESLOT", None, timeslot.start_unix, do_start_timeslot, timeslot)
def do_end_timeslot(timeslot):
self.logger.info(SU.cyan(f"=== on_timeslot_end('{timeslot}') ==="))
self.engine.event_dispatcher.on_timeslot_end(timeslot)
child_timer = EngineExecutor("TIMESLOT", None, timeslot.end_unix, do_end_timeslot, timeslot)
super().__init__("TIMESLOT", child_timer, timeslot.start_unix, do_start_timeslot, timeslot)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment