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.
This commit is contained in:
Ghostkeeper 2017-02-24 14:53:00 +01:00
parent 537de489bf
commit d60014fa30
No known key found for this signature in database
GPG key ID: C5F96EE2BC0F7E75

View file

@ -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)