Ejemplo n.º 1
0
 def __init__(self):
     QtCore.QObject.__init__(self)
     self.bobina = Bobina()
     self.event_monitor = EventMonitor()
     self.event_monitor.bell_now.connect(self.on_event)
     self.last_event = None
     self.paused = False
Ejemplo n.º 2
0
 def __init__(self):
     QtCore.QObject.__init__(self)
     self.bobina = Bobina()
     self.event_monitor = EventMonitor()
     self.event_monitor.bell_now.connect(self.on_event)
     self.last_event = None
     self.paused = False
Ejemplo n.º 3
0
class EventAggregator(QtCore.QObject):
    '''
    EventManager knows what need to be played; it handles Bobina, listen to
    events.
    More abstractly, it's an Audio source that aggregates different Audio
    sources
    '''
    @log.cls_logger
    def __init__(self):
        QtCore.QObject.__init__(self)
        self.bobina = Bobina()
        self.event_monitor = EventMonitor()
        self.event_monitor.bell_now.connect(self.on_event)
        self.last_event = None
        self.paused = False

    def on_event(self, ev):
        self.log.info("Bell rang " + str(ev))
        if not self.paused:
            self.last_event = ev
        else:
            self.log.debug("Ignoring bell: we're in pause mode")

    def get_next(self):
        last = self.last_event
        self.last_event = None
        if last is None:
            next_audio = [self.bobina.get_next()]
            self.log.info("Next audio is %s, from Bobina" % next_audio[0])
        else:
            next_audio = last.audio
            self.log.info("Next audio is %s, from Event %s" %
                          (next_audio, last))
        return next_audio

    def pause_events(self, value=None):
        if value is None:
            value = not self.paused
        self.paused = value

    @short_command("last_event")
    def cmd_lastevent(controller, args):
        return str(controller.audio_source.last_event)

    @short_command("pause_events")
    def cmd_pause_events(controller, args):
        controller.audio_source.pause_events()
        return str(controller.audio_source.paused)
Ejemplo n.º 4
0
class EventAggregator(QtCore.QObject):
    '''
    EventManager knows what need to be played; it handles Bobina, listen to
    events.
    More abstractly, it's an Audio source that aggregates different Audio
    sources
    '''
    @log.cls_logger
    def __init__(self):
        QtCore.QObject.__init__(self)
        self.bobina = Bobina()
        self.event_monitor = EventMonitor()
        self.event_monitor.bell_now.connect(self.on_event)
        self.last_event = None
        self.paused = False

    def on_event(self, ev):
        self.log.info("Bell rang " + str(ev))
        if not self.paused:
            self.last_event = ev
        else:
            self.log.debug("Ignoring bell: we're in pause mode")

    def get_next(self):
        last = self.last_event
        self.last_event = None
        if last is None:
            next_audio = [self.bobina.get_next()]
            self.log.info("Next audio is %s, from Bobina" % next_audio[0])
        else:
            next_audio = last.audio
            self.log.info("Next audio is %s, from Event %s" %
                          (next_audio, last))
        return next_audio

    def pause_events(self, value=None):
        if value is None:
            value = not self.paused
        self.paused = value

    @short_command("last_event")
    def cmd_lastevent(controller, args):
        return str(controller.audio_source.last_event)

    @short_command("pause_events")
    def cmd_pause_events(controller, args):
        controller.audio_source.pause_events()
        return str(controller.audio_source.paused)