From cfbcf567399449beff2e9db8b22ab0f2c289c0e5 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 7 Feb 2017 13:18:41 +0100 Subject: [PATCH] Add function to pre-head bed This makes a PUT-request to the printer with the new API function call. Contributes to issue CURA-3161. --- .../UM3NetworkPrinting/NetworkPrinterOutputDevice.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py index 32ebd354ee..99d07a8b81 100644 --- a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py +++ b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py @@ -240,6 +240,18 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): def ipAddress(self): return self._address + ## Pre-heats the heated bed of the printer. + # + # \param temperature The temperature to heat the bed to, in degrees + # Celsius. + # \param duration How long the bed should stay warm, in seconds. + def preheatBed(self, temperature, duration): + url = QUrl("http://" + self._address + self._api_prefix + "printer/bed/pre_heat") + data = """{"temperature": "{temperature}", "timeout": "{timeout}"}""".format(temperature=temperature, timeout=duration) + put_request = QNetworkRequest(url) + put_request.setHeader(QNetworkRequest.ContentTypeHeader, "application/json") + self._manager.put(put_request, data.encode()) + def _stopCamera(self): self._camera_timer.stop() if self._image_reply: