job_state; check stored state on disconnect
If Klipper disconnects while printing manually set the state to "error". Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
99b97afc7d
commit
44a5600038
|
@ -25,7 +25,17 @@ class JobState:
|
||||||
self.server = config.get_server()
|
self.server = config.get_server()
|
||||||
self.last_print_stats: Dict[str, Any] = {}
|
self.last_print_stats: Dict[str, Any] = {}
|
||||||
self.server.register_event_handler(
|
self.server.register_event_handler(
|
||||||
"server:klippy_started", self._handle_started)
|
"server:klippy_started", self._handle_started
|
||||||
|
)
|
||||||
|
self.server.register_event_handler(
|
||||||
|
"server:klippy_disconnect", self._handle_disconnect
|
||||||
|
)
|
||||||
|
|
||||||
|
def _handle_disconnect(self):
|
||||||
|
state = self.last_print_stats.get("state", "")
|
||||||
|
if state in ("printing", "paused"):
|
||||||
|
# set error state
|
||||||
|
self.last_print_stats["state"] = "error"
|
||||||
|
|
||||||
async def _handle_started(self, state: KlippyState) -> None:
|
async def _handle_started(self, state: KlippyState) -> None:
|
||||||
if state != KlippyState.READY:
|
if state != KlippyState.READY:
|
||||||
|
|
Loading…
Reference in New Issue