From 9f09708e01476cc25806cfd38490cefa01ce6027 Mon Sep 17 00:00:00 2001 From: sbahling Date: Mon, 5 Nov 2018 22:42:58 +0100 Subject: code cleanup --- tascam_fw_console/console.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'tascam_fw_console') diff --git a/tascam_fw_console/console.py b/tascam_fw_console/console.py index e13615d..858ee17 100644 --- a/tascam_fw_console/console.py +++ b/tascam_fw_console/console.py @@ -57,27 +57,34 @@ class ConsoleStatus(): class RunningStatusThread(): def __init__(self, console, interval=0.1): - """ Constructor - :type interval: int - :param interval: Check interval, in seconds + """ Background thread that will poll the console status data and + pass it to all objects in the callbacks set. If the callback set + is empty, polling doesn't happen. + Objects added to the callback set must have a status_callback() + method, a status_quadlet attribute containing the index of the + quadlet of interest, and a status_bits attribute containing a 2 member + iterable with the start and end bits of the quadlet of interest. + + :param console: Console object + :type interval: float + :param interval: Poll interval, in seconds """ self.console = console self.interval = interval self.callbacks = set() - self.last_status = [] thread = threading.Thread(target=self.run) thread.daemon = True # Daemonize thread thread.start() # Start the execution def add_callback(self, obj): + self.callbacks.add(obj) def remove_callback(self, obj): self.callbacks.remove(obj) def run(self): - """ Method that runs forever """ while True: for obj in self.callbacks: value = self.console.status.field(obj.status_quadlet, -- cgit v1.2.3