diff options
| author | sbahling <sbahling@mudgum.net> | 2018-11-05 22:42:58 +0100 |
|---|---|---|
| committer | sbahling <sbahling@mudgum.net> | 2018-11-05 22:42:58 +0100 |
| commit | 9f09708e01476cc25806cfd38490cefa01ce6027 (patch) | |
| tree | 834ba6217124324f2b5e3d7edefba61c25eef8ec /tascam_fw_console | |
| parent | 0539dd22863cf43f51f1eb490ac2ee0edc24bab6 (diff) | |
| download | tascam-fw-osc-9f09708e01476cc25806cfd38490cefa01ce6027.tar.gz tascam-fw-osc-9f09708e01476cc25806cfd38490cefa01ce6027.tar.xz tascam-fw-osc-9f09708e01476cc25806cfd38490cefa01ce6027.zip | |
code cleanup
Diffstat (limited to 'tascam_fw_console')
| -rw-r--r-- | tascam_fw_console/console.py | 17 |
1 files changed, 12 insertions, 5 deletions
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, |
