aboutsummaryrefslogtreecommitdiffstats
path: root/klippy
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2018-02-05 13:52:05 -0500
committerKevin O'Connor <kevin@koconnor.net>2018-02-05 13:52:05 -0500
commit0a5b07f9dafb19fca4305aa141dbae9e7571977b (patch)
treec04804beb5c21220ec31328a395ad4ba6f2eab62 /klippy
parent08874b9c91544c012763766c51b6a0c279972140 (diff)
downloadkutter-0a5b07f9dafb19fca4305aa141dbae9e7571977b.tar.gz
kutter-0a5b07f9dafb19fca4305aa141dbae9e7571977b.tar.xz
kutter-0a5b07f9dafb19fca4305aa141dbae9e7571977b.zip
klippy: Allow any stats producer to determine when stats are needed
Instead of using the toolhead class to determine if stats should be reported, allow every printer object with a stats() callback to determine if stats are needed. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy')
-rw-r--r--klippy/gcode.py2
-rw-r--r--klippy/heater.py2
-rw-r--r--klippy/klippy.py10
-rw-r--r--klippy/mcu.py4
-rw-r--r--klippy/toolhead.py14
5 files changed, 12 insertions, 20 deletions
diff --git a/klippy/gcode.py b/klippy/gcode.py
index 21a27252..e4dfb106 100644
--- a/klippy/gcode.py
+++ b/klippy/gcode.py
@@ -77,7 +77,7 @@ class GCodeParser:
self.move_with_transform = transform.move
self.position_with_transform = transform.get_position
def stats(self, eventtime):
- return "gcodein=%d" % (self.bytes_read,)
+ return False, "gcodein=%d" % (self.bytes_read,)
def printer_state(self, state):
if state == 'shutdown':
if not self.is_printer_ready:
diff --git a/klippy/heater.py b/klippy/heater.py
index 632ae88e..a3ca1913 100644
--- a/klippy/heater.py
+++ b/klippy/heater.py
@@ -194,7 +194,7 @@ class PrinterHeater:
target_temp = self.target_temp
last_temp = self.last_temp
last_pwm_value = self.last_pwm_value
- return '%s: target=%.0f temp=%.0f pwm=%.3f' % (
+ return False, '%s: target=%.0f temp=%.0f pwm=%.3f' % (
self.name, target_temp, last_temp, last_pwm_value)
diff --git a/klippy/klippy.py b/klippy/klippy.py
index fba527a2..90370f6d 100644
--- a/klippy/klippy.py
+++ b/klippy/klippy.py
@@ -173,14 +173,10 @@ class Printer:
if self.bglogger is not None:
self.bglogger.set_rollover_info(name, info)
def _stats(self, eventtime, force_output=False):
- toolhead = self.objects.get('toolhead')
- if toolhead is None:
- return eventtime + 1.
- is_active = toolhead.check_active(eventtime)
- if not is_active and not force_output:
- return eventtime + 1.
stats = [cb(eventtime) for cb in self.stats_cb]
- logging.info("Stats %.1f: %s", eventtime, ' '.join(stats))
+ if max([s[0] for s in stats] + [force_output]):
+ logging.info("Stats %.1f: %s", eventtime,
+ ' '.join([s[1] for s in stats]))
return eventtime + 1.
def _try_load_module(self, config, section):
if section in self.objects:
diff --git a/klippy/mcu.py b/klippy/mcu.py
index 87c590a8..ce85c4c8 100644
--- a/klippy/mcu.py
+++ b/klippy/mcu.py
@@ -747,8 +747,8 @@ class MCU:
msg = "%s: mcu_awake=%.03f mcu_task_avg=%.06f mcu_task_stddev=%.06f" % (
self._name, self._mcu_tick_awake, self._mcu_tick_avg,
self._mcu_tick_stddev)
- return ' '.join([msg, self._serial.stats(eventtime),
- self._clocksync.stats(eventtime)])
+ return False, ' '.join([msg, self._serial.stats(eventtime),
+ self._clocksync.stats(eventtime)])
def printer_state(self, state):
if state == 'connect':
self._connect()
diff --git a/klippy/toolhead.py b/klippy/toolhead.py
index cd760616..1b5021c0 100644
--- a/klippy/toolhead.py
+++ b/klippy/toolhead.py
@@ -358,17 +358,13 @@ class ToolHead:
self.move_queue.set_extruder(extruder)
self.commanded_pos[3] = extrude_pos
# Misc commands
- def check_active(self, eventtime):
+ def stats(self, eventtime):
for m in self.all_mcus:
m.check_active(self.print_time, eventtime)
- if not self.sync_print_time:
- return True
- return self.print_time + 60. > self.mcu.estimated_print_time(eventtime)
- def stats(self, eventtime):
- est_print_time = self.mcu.estimated_print_time(eventtime)
- buffer_time = max(0., self.print_time - est_print_time)
- return "print_time=%.3f buffer_time=%.3f print_stall=%d" % (
- self.print_time, buffer_time, self.print_stall)
+ buffer_time = self.print_time - self.mcu.estimated_print_time(eventtime)
+ is_active = buffer_time > -60. or not self.sync_print_time
+ return is_active, "print_time=%.3f buffer_time=%.3f print_stall=%d" % (
+ self.print_time, max(buffer_time, 0.), self.print_stall)
def printer_state(self, state):
if state == 'shutdown':
try: