From 506222bcb87d98a67494f53cd78f8ef4e5a95859 Mon Sep 17 00:00:00 2001 From: Sven Augustin Date: Wed, 1 Jul 2020 11:27:28 +0200 Subject: [PATCH] moved the calc. of the progress bar pos. into a separate class --- slic/core/acquisition/broker_client.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/slic/core/acquisition/broker_client.py b/slic/core/acquisition/broker_client.py index ec5efffe9..e3ec6aeda 100644 --- a/slic/core/acquisition/broker_client.py +++ b/slic/core/acquisition/broker_client.py @@ -36,14 +36,14 @@ class BrokerClient: self.running = True - with tqdm(total=n_pulses) as pbar: + with stqdm(total=n_pulses) as pbar: while self.running: current_pulseid = get_current_pulseid() if current_pulseid > stop_pulseid: break sleep(self.wait_time) - delta_n = 1 + ((current_pulseid - start_pulseid) // rate_multiplicator) - pbar.n # +1 to start at 0 (otherwise starts at -1) - pbar.update(delta_n) + delta_n = (current_pulseid - start_pulseid) // rate_multiplicator + pbar.set(delta_n) self.running = False @@ -170,3 +170,14 @@ def aligned_pids(start, n, rm): +class stqdm(tqdm): + + def set(self, elapsed): + """ + update with elapsed n, i.e., the delta between start and current n + """ + increment = elapsed + 1 - self.n # +1 to start at 0 (otherwise starts at -1) + self.update(increment) + + +