Fix target temperature propagation from comm layer
When setting the tracked target temperature from a sent temperature command, the changes in tracked temperature were not propagated from the comm layer to registered callbacks. But since the standard printer also didn't make a copy of the mutable dict of tool temperatures, those were in fact updated even without propagation in the printer implementation when the values in the comm layer got updated, whereas the bed temperature - an immutable tupel - was not. Two wrongs sometimes do in fact make a right. In this case that led to target temperature changes on the tools immediately reflecting in printer.get_current_temperatures after the command was sent, but changes to the bed target taking until the next M105 response to propagate. Decoupling the data structures and adding propagation commands to the comm layer solves this issue. Fixes #1543
This commit is contained in:
parent
c863562d12
commit
bc5044b125
2 changed files with 4 additions and 2 deletions
|
|
@ -292,7 +292,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
|||
|
||||
def set_temperature(self, heater, value):
|
||||
if not PrinterInterface.valid_heater_regex.match(heater):
|
||||
raise ValueError("heater must match \"tool[0-9]+\" or \"bed\": {heater}".format(type=heater))
|
||||
raise ValueError("heater must match \"tool[0-9]+\" or \"bed\": {heater}".format(heater=heater))
|
||||
|
||||
if not isinstance(value, (int, long, float)) or value < 0:
|
||||
raise ValueError("value must be a valid number >= 0: {value}".format(value=value))
|
||||
|
|
@ -915,7 +915,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
|||
self._addLog(to_unicode(message, "utf-8", errors="replace"))
|
||||
|
||||
def on_comm_temperature_update(self, temp, bedTemp):
|
||||
self._addTemperatureData(temp, bedTemp)
|
||||
self._addTemperatureData(copy.deepcopy(temp), copy.deepcopy(bedTemp))
|
||||
|
||||
def on_comm_state_change(self, state):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -2141,6 +2141,7 @@ class MachineCom(object):
|
|||
self._temp[toolNum] = (actual, target)
|
||||
else:
|
||||
self._temp[toolNum] = (None, target)
|
||||
self._callback.on_comm_temperature_update(self._temp, self._bedTemp)
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
|
|
@ -2154,6 +2155,7 @@ class MachineCom(object):
|
|||
self._bedTemp = (actual, target)
|
||||
else:
|
||||
self._bedTemp = (None, target)
|
||||
self._callback.on_comm_temperature_update(self._temp, self._bedTemp)
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue