printer: Optimize print states and more print state logging

This commit is contained in:
Jordan Ruthe 2021-01-20 15:35:01 -05:00
parent fc074c350f
commit a51360f372
2 changed files with 10 additions and 9 deletions

View File

@ -106,18 +106,19 @@ class Printer:
self.evaluate_state()
def evaluate_state(self):
wh_state = self.data['webhooks']['state'] # possible values: startup, ready, shutdown, error
wh_state = self.data['webhooks']['state'].lower() # possible values: startup, ready, shutdown, error
idle_state = self.data['idle_timeout']['state'].lower() # possible values: Idle, printing, ready
print_state = self.data['print_stats']['state'] # possible values: complete, paused, printing, standby
print_state = self.data['print_stats']['state'].lower() # possible values: complete, paused, printing, standby
logger.debug("State evaluations: %s %s %s" % (wh_state, idle_state, print_state))
if wh_state == "ready":
new_state = "ready"
if idle_state == "printing" and print_state != "printing": # Not printing a file, toolhead moving
new_state = "busy"
elif idle_state == "printing" and print_state == "printing":
new_state = "printing"
elif print_state == "paused":
if print_state == "paused":
new_state = "paused"
elif idle_state == "printing" and print_state != "printing": # Not printing a file, toolhead moving
new_state = "busy"
elif idle_state == "printing":
new_state = "printing"
if new_state != "busy":
self.change_state(new_state)

View File

@ -424,8 +424,8 @@ class KlipperScreen(Gtk.Window):
logger.debug("Received notify_klippy_disconnected")
self.printer.change_state("disconnected")
return
#elif action == "notify_klippy_ready":
# self.printer.change_state("ready")
elif action == "notify_klippy_ready":
self.printer.change_state("ready")
elif action == "notify_status_update" and self.printer.get_state() != "shutdown":
self.printer.process_update(data)
elif action == "notify_filelist_changed":