klippy_apis: add pause, resume and cancel print method
These methods may be called internally, which invoke the associated events. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
e05aeac884
commit
fe3b7456f6
|
@ -62,16 +62,13 @@ class KlippyAPI(Subscribable):
|
||||||
"/printer/firmware_restart", ['POST'], self._gcode_firmware_restart)
|
"/printer/firmware_restart", ['POST'], self._gcode_firmware_restart)
|
||||||
|
|
||||||
async def _gcode_pause(self, web_request: WebRequest) -> str:
|
async def _gcode_pause(self, web_request: WebRequest) -> str:
|
||||||
self.server.send_event("klippy_apis:pause_requested")
|
return await self.pause_print()
|
||||||
return await self._send_klippy_request("pause_resume/pause", {})
|
|
||||||
|
|
||||||
async def _gcode_resume(self, web_request: WebRequest) -> str:
|
async def _gcode_resume(self, web_request: WebRequest) -> str:
|
||||||
self.server.send_event("klippy_apis:resume_requested")
|
return await self.resume_print()
|
||||||
return await self._send_klippy_request("pause_resume/resume", {})
|
|
||||||
|
|
||||||
async def _gcode_cancel(self, web_request: WebRequest) -> str:
|
async def _gcode_cancel(self, web_request: WebRequest) -> str:
|
||||||
self.server.send_event("klippy_apis:cancel_requested")
|
return await self.cancel_print()
|
||||||
return await self._send_klippy_request("pause_resume/cancel", {})
|
|
||||||
|
|
||||||
async def _gcode_start_print(self, web_request: WebRequest) -> str:
|
async def _gcode_start_print(self, web_request: WebRequest) -> str:
|
||||||
filename: str = web_request.get_str('filename')
|
filename: str = web_request.get_str('filename')
|
||||||
|
@ -121,6 +118,27 @@ class KlippyAPI(Subscribable):
|
||||||
await self.klippy.wait_started()
|
await self.klippy.wait_started()
|
||||||
return await self.run_gcode(script)
|
return await self.run_gcode(script)
|
||||||
|
|
||||||
|
async def pause_print(
|
||||||
|
self, default: Union[SentinelClass, _T] = SENTINEL
|
||||||
|
) -> Union[_T, str]:
|
||||||
|
self.server.send_event("klippy_apis:pause_requested")
|
||||||
|
return await self._send_klippy_request(
|
||||||
|
"pause_resume/pause", {}, default)
|
||||||
|
|
||||||
|
async def resume_print(
|
||||||
|
self, default: Union[SentinelClass, _T] = SENTINEL
|
||||||
|
) -> Union[_T, str]:
|
||||||
|
self.server.send_event("klippy_apis:resume_requested")
|
||||||
|
return await self._send_klippy_request(
|
||||||
|
"pause_resume/resume", {}, default)
|
||||||
|
|
||||||
|
async def cancel_print(
|
||||||
|
self, default: Union[SentinelClass, _T] = SENTINEL
|
||||||
|
) -> Union[_T, str]:
|
||||||
|
self.server.send_event("klippy_apis:cancel_requested")
|
||||||
|
return await self._send_klippy_request(
|
||||||
|
"pause_resume/cancel", {}, default)
|
||||||
|
|
||||||
async def do_restart(self, gc: str) -> str:
|
async def do_restart(self, gc: str) -> str:
|
||||||
# WARNING: Do not call this method from within the following
|
# WARNING: Do not call this method from within the following
|
||||||
# event handlers:
|
# event handlers:
|
||||||
|
|
Loading…
Reference in New Issue