mirror of https://github.com/Desuuuu/klipper.git
klippy: Don't log stats when the printer is idle
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
7a386cff7d
commit
b9623c1128
|
@ -136,17 +136,20 @@ class Printer:
|
||||||
def set_fileoutput(self, debugoutput, dictionary):
|
def set_fileoutput(self, debugoutput, dictionary):
|
||||||
self.debugoutput = debugoutput
|
self.debugoutput = debugoutput
|
||||||
self.dictionary = dictionary
|
self.dictionary = dictionary
|
||||||
def stats(self, eventtime):
|
def stats(self, eventtime, force_output=False):
|
||||||
if self.need_dump_debug:
|
if self.need_dump_debug:
|
||||||
# Call dump_debug here so it is executed in the main thread
|
# Call dump_debug here so it is executed in the main thread
|
||||||
self.gcode.dump_debug()
|
self.gcode.dump_debug()
|
||||||
self.need_dump_debug = False
|
self.need_dump_debug = False
|
||||||
|
toolhead = self.objects.get('toolhead')
|
||||||
|
if toolhead is None or self.mcu is None:
|
||||||
|
return
|
||||||
|
is_active, thstats = toolhead.stats(eventtime)
|
||||||
|
if not is_active and not force_output:
|
||||||
|
return
|
||||||
out = []
|
out = []
|
||||||
out.append(self.gcode.stats(eventtime))
|
out.append(self.gcode.stats(eventtime))
|
||||||
toolhead = self.objects.get('toolhead')
|
out.append(thstats)
|
||||||
if toolhead is not None:
|
|
||||||
out.append(toolhead.stats(eventtime))
|
|
||||||
if self.mcu is not None:
|
|
||||||
out.append(self.mcu.stats(eventtime))
|
out.append(self.mcu.stats(eventtime))
|
||||||
logging.info("Stats %.1f: %s" % (eventtime, ' '.join(out)))
|
logging.info("Stats %.1f: %s" % (eventtime, ' '.join(out)))
|
||||||
return eventtime + 1.
|
return eventtime + 1.
|
||||||
|
@ -238,14 +241,14 @@ class Printer:
|
||||||
def disconnect(self):
|
def disconnect(self):
|
||||||
try:
|
try:
|
||||||
if self.mcu is not None:
|
if self.mcu is not None:
|
||||||
self.stats(self.reactor.monotonic())
|
self.stats(self.reactor.monotonic(), force_output=True)
|
||||||
self.mcu.disconnect()
|
self.mcu.disconnect()
|
||||||
except:
|
except:
|
||||||
logging.exception("Unhandled exception during disconnect")
|
logging.exception("Unhandled exception during disconnect")
|
||||||
def firmware_restart(self):
|
def firmware_restart(self):
|
||||||
try:
|
try:
|
||||||
if self.mcu is not None:
|
if self.mcu is not None:
|
||||||
self.stats(self.reactor.monotonic())
|
self.stats(self.reactor.monotonic(), force_output=True)
|
||||||
self.mcu.microcontroller_restart()
|
self.mcu.microcontroller_restart()
|
||||||
self.mcu.disconnect()
|
self.mcu.disconnect()
|
||||||
except:
|
except:
|
||||||
|
|
|
@ -207,6 +207,7 @@ class ToolHead:
|
||||||
self.move_flush_time = config.getfloat(
|
self.move_flush_time = config.getfloat(
|
||||||
'move_flush_time', 0.050, above=0.)
|
'move_flush_time', 0.050, above=0.)
|
||||||
self.print_time = 0.
|
self.print_time = 0.
|
||||||
|
self.last_print_end_time = self.reactor.monotonic()
|
||||||
self.need_check_stall = -1.
|
self.need_check_stall = -1.
|
||||||
self.print_stall = 0
|
self.print_stall = 0
|
||||||
self.synch_print_time = True
|
self.synch_print_time = True
|
||||||
|
@ -258,6 +259,7 @@ class ToolHead:
|
||||||
def reset_print_time(self):
|
def reset_print_time(self):
|
||||||
self._flush_lookahead(must_synch=True)
|
self._flush_lookahead(must_synch=True)
|
||||||
self.print_time = 0.
|
self.print_time = 0.
|
||||||
|
self.last_print_end_time = self.reactor.monotonic()
|
||||||
self.need_check_stall = -1.
|
self.need_check_stall = -1.
|
||||||
self.forced_synch = False
|
self.forced_synch = False
|
||||||
self._reset_motor_off()
|
self._reset_motor_off()
|
||||||
|
@ -366,11 +368,12 @@ class ToolHead:
|
||||||
buffer_time = 0.
|
buffer_time = 0.
|
||||||
print_time = self.print_time
|
print_time = self.print_time
|
||||||
if print_time:
|
if print_time:
|
||||||
buffer_time = self.printer.mcu.get_print_buffer_time(
|
is_active = True
|
||||||
eventtime, print_time)
|
buffer_time = max(0., self.printer.mcu.get_print_buffer_time(
|
||||||
if buffer_time < 0.:
|
eventtime, print_time))
|
||||||
buffer_time = 0.
|
else:
|
||||||
return "print_time=%.3f buffer_time=%.3f print_stall=%d" % (
|
is_active = eventtime < self.last_print_end_time + 60.
|
||||||
|
return is_active, "print_time=%.3f buffer_time=%.3f print_stall=%d" % (
|
||||||
print_time, buffer_time, self.print_stall)
|
print_time, buffer_time, self.print_stall)
|
||||||
def force_shutdown(self):
|
def force_shutdown(self):
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue