From ef2e38b870357e74fd69710fa3b09fa38604feff Mon Sep 17 00:00:00 2001 From: ruipeng <1041589370@qq.com> Date: Thu, 19 Dec 2024 11:01:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8F=96=E6=B6=88=E6=89=93?= =?UTF-8?q?=E5=8D=B0=E5=AE=8F=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- moonraker/components/job_state.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/moonraker/components/job_state.py b/moonraker/components/job_state.py index 098382f..42b97eb 100644 --- a/moonraker/components/job_state.py +++ b/moonraker/components/job_state.py @@ -54,6 +54,7 @@ class JobState: logging.info(f"Job state initialized: {state}") async def _status_update(self, data: Dict[str, Any], _: float) -> None: + kapis: KlippyAPI = self.server.lookup_component('klippy_apis') if 'print_stats' not in data: return ps = data['print_stats'] @@ -78,6 +79,8 @@ class JobState: f"Job State Changed - Prev State: {old_state}, " f"New State: {new_state}" ) + if new_state == "cancelled": + await kapis.run_gcode("_CANCEL_PRINT_BASE") # NOTE: Individual job_state events are DEPRECATED. New modules # should register handlers for "job_state: status_changed" and # match against the JobEvent object provided.