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>
This commit is contained in:
Kevin O'Connor 2018-02-05 13:52:05 -05:00
parent 08874b9c91
commit 0a5b07f9da
5 changed files with 12 additions and 20 deletions

View file

@ -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: