diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2019-01-08 10:55:18 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2019-01-08 10:59:43 -0500 |
commit | 797367b9f5652df4103d7185567c8d749a8afbff (patch) | |
tree | 347768577a2a400b8c511d486d4eca8d4b2c339c /klippy/extras/statistics.py | |
parent | f4be0ac7be6ec1e94264a7b2f86484e4bcd607ed (diff) | |
download | kutter-797367b9f5652df4103d7185567c8d749a8afbff.tar.gz kutter-797367b9f5652df4103d7185567c8d749a8afbff.tar.xz kutter-797367b9f5652df4103d7185567c8d749a8afbff.zip |
klippy: Convert printer_state("ready") to an event handler
Convert all users of the printer_state("ready") handler to register a
"klippy:ready" event handler instead.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/extras/statistics.py')
-rw-r--r-- | klippy/extras/statistics.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/klippy/extras/statistics.py b/klippy/extras/statistics.py index 639bcad3..84186ed1 100644 --- a/klippy/extras/statistics.py +++ b/klippy/extras/statistics.py @@ -11,13 +11,13 @@ class PrinterStats: reactor = self.printer.get_reactor() self.stats_timer = reactor.register_timer(self.generate_stats) self.stats_cb = [] - def printer_state(self, state): - if state == 'ready': - self.stats_cb = [o.stats for n, o in self.printer.lookup_objects() - if hasattr(o, 'stats')] - if self.printer.get_start_args().get('debugoutput') is None: - reactor = self.printer.get_reactor() - reactor.update_timer(self.stats_timer, reactor.NOW) + self.printer.register_event_handler("klippy:ready", self.handle_ready) + def handle_ready(self): + self.stats_cb = [o.stats for n, o in self.printer.lookup_objects() + if hasattr(o, 'stats')] + if self.printer.get_start_args().get('debugoutput') is None: + reactor = self.printer.get_reactor() + reactor.update_timer(self.stats_timer, reactor.NOW) def generate_stats(self, eventtime): stats = [cb(eventtime) for cb in self.stats_cb] if max([s[0] for s in stats]): |