From d60014fa30e3ba5a86a517d20da2f0c9ed96ea3b Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 24 Feb 2017 14:53:00 +0100 Subject: [PATCH] Sync remaining pre-heat time with printer If multiple instances of Cura are running or Cura is restarted, it now properly syncs the remaining pre-heat time with the printer, so that all instances display the proper time. There's still a bug in here that pressing cancel has no effect the first time since the remaining pre-heat time is updated immediately from the printer before the command to cancel got through remotely. I'll see what I can do to amend that. Also, cancelling is not yet synced. Contributes to issue CURA-3360. --- .../UM3NetworkPrinting/NetworkPrinterOutputDevice.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py index a95a63995d..bdcd24105a 100644 --- a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py +++ b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py @@ -532,6 +532,18 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): self._updateHeadPosition(head_x, head_y, head_z) self._updatePrinterState(self._json_printer_state["status"]) + try: + remaining_preheat_time = self._json_printer_state["bed"]["pre_heat"]["remaining"] + except KeyError: #Old firmware doesn't support that. + pass #Don't update the 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() + def close(self): Logger.log("d", "Closing connection of printer %s with ip %s", self._key, self._address)