From 39920c95f3acb3c29c3b4076228936ab674483d6 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 24 Feb 2017 17:14:54 +0100 Subject: [PATCH] Interpret cancelling pre-heat properly If someone on a different computer cancels the pre-heat, this is now correctly updated locally. Contributes to issue CURA-3360. --- .../NetworkPrinterOutputDevice.py | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py index bdcd24105a..456783c91b 100644 --- a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py +++ b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py @@ -533,16 +533,27 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): self._updatePrinterState(self._json_printer_state["status"]) try: - remaining_preheat_time = self._json_printer_state["bed"]["pre_heat"]["remaining"] + is_preheating = self._json_printer_state["bed"]["pre_heat"]["active"] except KeyError: #Old firmware doesn't support that. - pass #Don't update the time. + pass #Don't update the pre-heat remaining time. else: - #Only update if time estimate is significantly off (>5000ms). - #Otherwise we get issues with latency causing the timer to count inconsistently. - if abs(self._preheat_bed_timer.remainingTime() - remaining_preheat_time * 1000) > 5000: - self._preheat_bed_timer.setInterval(remaining_preheat_time * 1000) - self._preheat_bed_timer.start() - self.preheatBedRemainingTimeChanged.emit() + if is_preheating: + try: + remaining_preheat_time = self._json_printer_state["bed"]["pre_heat"]["remaining"] + except KeyError: #Error in firmware. If "active" is supported, "remaining" should also be supported. + pass #Anyway, don't update. + else: + #Only update if time estimate is significantly off (>5000ms). + #Otherwise we get issues with latency causing the timer to count inconsistently. + if abs(self._preheat_bed_timer.remainingTime() - remaining_preheat_time * 1000) > 5000: + self._preheat_bed_timer.setInterval(remaining_preheat_time * 1000) + self._preheat_bed_timer.start() + self.preheatBedRemainingTimeChanged.emit() + else: #Not pre-heating. Must've cancelled. + if self._preheat_bed_timer.isActive(): + self._preheat_bed_timer.setInterval(0) + self._preheat_bed_timer.stop() + self.preheatBedRemainingTimeChanged.emit() def close(self):