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

View file

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