def _stopped_maxtimer(self, dev: str): self.maxtimer_running[dev] = False self.dgtmenu.disable_picochess_displayed(dev) if dev not in self.devices: logging.debug('delete not registered (%s) tasks', dev) self.tasks[dev] = [] return if self.tasks[dev]: logging.debug('processing delayed (%s) tasks: %s', dev, self.tasks[dev]) else: logging.debug( '(%s) max timer finished - returning to time display', dev) DisplayDgt.show( Dgt.DISPLAY_TIME(force=False, wait=True, devs={dev})) while self.tasks[dev]: logging.debug('(%s) tasks has %i members', dev, len(self.tasks[dev])) try: message = self.tasks[dev].pop(0) except IndexError: break with self.process_lock[dev]: self._process_message(message, dev) if self.maxtimer_running[ dev]: # run over the task list until a maxtime command was processed remaining = len(self.tasks[dev]) if remaining: logging.debug('(%s) tasks stopped on %i remaining members', dev, remaining) else: logging.debug('(%s) tasks completed', dev) break
def _stopped_maxtimer(self, dev: str): self.maxtimer_running[dev] = False self.dgtmenu.disable_picochess_displayed(dev) if dev not in self.devices: logging.debug('delete not registered (%s) tasks', dev) self.tasks[dev] = [] return if self.tasks[dev]: logging.debug('processing delayed (%s) tasks: %s', dev, self.tasks[dev]) else: logging.debug('(%s) max timer finished - returning to time display', dev) DisplayDgt.show(Dgt.DISPLAY_TIME(force=False, wait=True, devs={dev})) while self.tasks[dev]: logging.debug('(%s) tasks has %i members', dev, len(self.tasks[dev])) try: message = self.tasks[dev].pop(0) except IndexError: break with self.process_lock[dev]: self._process_message(message, dev) if self.maxtimer_running[dev]: # run over the task list until a maxtime command was processed remaining = len(self.tasks[dev]) if remaining: logging.debug('(%s) tasks stopped on %i remaining members', dev, remaining) else: logging.debug('(%s) tasks completed', dev) break
def _process_message(self, message, dev: str): do_handle = True if repr(message) in (DgtApi.CLOCK_START, DgtApi.CLOCK_STOP, DgtApi.DISPLAY_TIME): self.display_hash[ dev] = None # Cant know the clock display if command changing the running status else: if repr(message) in (DgtApi.DISPLAY_MOVE, DgtApi.DISPLAY_TEXT): if self.display_hash[dev] == hash( message) and not message.beep: do_handle = False else: self.display_hash[dev] = hash(message) if do_handle: logging.debug('(%s) handle DgtApi: %s', dev, message) if repr(message) == DgtApi.CLOCK_VERSION: logging.debug('(%s) clock registered', dev) self.clock_connected[dev] = True clk = (DgtApi.DISPLAY_MOVE, DgtApi.DISPLAY_TEXT, DgtApi.DISPLAY_TIME, DgtApi.CLOCK_SET, DgtApi.CLOCK_START, DgtApi.CLOCK_STOP) if repr(message) in clk and not self.clock_connected[dev]: logging.debug('(%s) clock still not registered => ignore %s', dev, message) return if hasattr(message, 'maxtime') and message.maxtime > 0: if repr(message) == DgtApi.DISPLAY_TEXT: if message.maxtime == 2.1: # 2.1=picochess message self.dgtmenu.enable_picochess_displayed(dev) if self.dgtmenu.inside_updt_menu(): if message.maxtime == 0.1: # 0.1=eBoard error logging.debug( '(%s) inside update menu => board errors not displayed', dev) return if message.maxtime == 1.1: # 1.1=eBoard connect logging.debug( '(%s) inside update menu => board connect not displayed', dev) return self.maxtimer[dev] = Timer(message.maxtime * self.time_factor, self._stopped_maxtimer, [dev]) self.maxtimer[dev].start() logging.debug('(%s) showing %s for %.1f secs', dev, message, message.maxtime * self.time_factor) self.maxtimer_running[dev] = True if repr( message ) == DgtApi.CLOCK_START and self.dgtmenu.inside_updt_menu(): logging.debug('(%s) inside update menu => clock not started', dev) return message.devs = { dev } # on new system, we only have ONE device each message - force this! DisplayDgt.show(message) else: logging.debug('(%s) hash ignore DgtApi: %s', dev, message)
def _process_message(self, message, dev: str): do_handle = True if repr(message) in (DgtApi.CLOCK_START, DgtApi.CLOCK_STOP, DgtApi.DISPLAY_TIME): self.display_hash[dev] = None # Cant know the clock display if command changing the running status else: if repr(message) in (DgtApi.DISPLAY_MOVE, DgtApi.DISPLAY_TEXT): if self.display_hash[dev] == hash(message) and not message.beep: do_handle = False else: self.display_hash[dev] = hash(message) if do_handle: logging.debug('(%s) handle DgtApi: %s', dev, message) if repr(message) == DgtApi.CLOCK_VERSION: logging.debug('(%s) clock registered', dev) self.clock_connected[dev] = True clk = (DgtApi.DISPLAY_MOVE, DgtApi.DISPLAY_TEXT, DgtApi.DISPLAY_TIME, DgtApi.CLOCK_SET, DgtApi.CLOCK_START, DgtApi.CLOCK_STOP) if repr(message) in clk and not self.clock_connected[dev]: logging.debug('(%s) clock still not registered => ignore %s', dev, message) return if hasattr(message, 'maxtime'): if repr(message) == DgtApi.DISPLAY_TEXT: if message.maxtime == 2.1: # 2.1=picochess message self.dgtmenu.enable_picochess_displayed(dev) if self.dgtmenu.inside_updt_menu(): if message.maxtime == 0.1: # 0.1=eBoard error logging.debug('(%s) inside update menu => board errors not displayed', dev) return if message.maxtime == 1.1: # 1.1=eBoard connect logging.debug('(%s) inside update menu => board connect not displayed', dev) return if message.maxtime > 0.1: # filter out "all the time" show and "eBoard error" messages self.maxtimer[dev] = Timer(message.maxtime * self.time_factor, self._stopped_maxtimer, [dev]) self.maxtimer[dev].start() logging.debug('(%s) showing %s for %.1f secs', dev, message, message.maxtime * self.time_factor) self.maxtimer_running[dev] = True if repr(message) == DgtApi.CLOCK_START and self.dgtmenu.inside_updt_menu(): logging.debug('(%s) inside update menu => clock not started', dev) return message.devs = {dev} # on new system, we only have ONE device each message - force this! DisplayDgt.show(message) else: logging.debug('(%s) hash ignore DgtApi: %s', dev, message)