always reinit printer on state changes

This commit is contained in:
alfrix 2022-11-16 16:07:48 -03:00
parent b68cfa40fd
commit 18d8f835a9
3 changed files with 6 additions and 11 deletions

View File

@ -260,7 +260,7 @@ class MoonrakerApi:
)
def object_subscription(self, updates):
logging.debug(f"Sending printer.objects.subscribe: {updates}")
logging.debug("Sending printer.objects.subscribe")
return self._ws.send_method(
"printer.objects.subscribe",
updates

View File

@ -51,7 +51,6 @@ class Printer:
self.output_pin_count = None
def reinit(self, printer_info, data):
logging.debug(f"Moonraker object status: {data}")
self.config = data['configfile']['config']
self.extrudercount = 0
self.tempdevcount = 0
@ -164,8 +163,9 @@ class Printer:
def change_state(self, state):
if state not in list(self.state_callbacks): # disconnected, startup, ready, shutdown, error, paused, printing
return
logging.debug(f"Changing state from '{self.state}' to '{state}'")
self.state = state
if state != self.state:
logging.debug(f"Changing state from '{self.state}' to '{state}'")
self.state = state
if self.state_callbacks[state] is not None:
logging.debug(f"Adding callback for state: {state}")
Gdk.threads_add_idle(

View File

@ -704,14 +704,15 @@ class KlipperScreen(Gtk.Window):
if self.is_updating():
self.update_queue.append([callback])
else:
self.init_printer()
callback()
def state_disconnected(self, msg=None):
logging.debug("### Going to disconnected")
self.printer.state = "disconnected"
self.close_screensaver()
msg = _("Klipper has disconnected") if msg is None else msg
self.printer_initializing(msg)
self.init_printer()
def state_error(self):
self.close_screensaver()
@ -742,7 +743,6 @@ class KlipperScreen(Gtk.Window):
# Do not return to main menu if completing a job, timeouts/user input will return
if "job_status" in self._cur_panels:
return
self.init_printer()
self.printer_ready()
def state_startup(self):
@ -915,11 +915,6 @@ class KlipperScreen(Gtk.Window):
self.printer_initializing("Unable to get printer info from moonraker")
return False
data = self.apiclient.send_request("printer/objects/query?" + "&".join(PRINTER_BASE_STATUS_OBJECTS))
if data is False:
self.printer_initializing("Error getting printer object data")
return False
config = self.apiclient.send_request("printer/objects/query?configfile")
if config is False:
self.printer_initializing("Error getting printer configuration")