Merge branch 'pr/3506' into maintenance
This commit is contained in:
commit
7c66f51395
3 files changed
+48
-10
No files matched your search
@@ -115,6 +115,7 @@ date of first contribution):
|
||||
* [Ludovico de Nittis](https://github.com/RyuzakiKK)
|
||||
* [Dominik Paľo](https://github.com/DominikPalo)
|
||||
* [Kelly Anderson](https://github.com/cbxbiker61)
|
||||
* [Jim Neill](https://github.com/jneilliii)
|
||||
|
||||
OctoPrint started off as a fork of [Cura](https://github.com/daid/Cura) by
|
||||
[Daid Braam](https://github.com/daid). Parts of its communication layer and
|
||||
|
||||
@@ -888,9 +888,11 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
printTimeLeft=int(printTimeLeft) if printTimeLeft is not None else None,
|
||||
printTimeLeftOrigin=printTimeLeftOrigin)
|
||||
|
||||
def _addTemperatureData(self, tools=None, bed=None, chamber=None):
|
||||
def _addTemperatureData(self, tools=None, bed=None, chamber=None, custom=None):
|
||||
if tools is None:
|
||||
tools = dict()
|
||||
if custom is None:
|
||||
custom = dict()
|
||||
|
||||
data = dict(time=int(time.time()))
|
||||
for tool in tools.keys():
|
||||
@@ -899,12 +901,15 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
data["bed"] = self._dict(actual=bed[0], target=bed[1])
|
||||
if chamber is not None and isinstance(chamber, tuple):
|
||||
data["chamber"] = self._dict(actual=chamber[0], target=chamber[1])
|
||||
for identifier, values in custom.items():
|
||||
data[identifier] = self._dict(actual=values[0], target=values[1])
|
||||
|
||||
self._temps.append(data)
|
||||
|
||||
self._temp = tools
|
||||
self._bedTemp = bed
|
||||
self._chamberTemp = chamber
|
||||
self._custom = custom
|
||||
|
||||
self._stateMonitor.add_temperature(self._dict(**data))
|
||||
|
||||
@@ -1055,8 +1060,13 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
"""
|
||||
self._addLog(to_unicode(message, "utf-8", errors="replace"))
|
||||
|
||||
def on_comm_temperature_update(self, temp, bedTemp, chamberTemp):
|
||||
self._addTemperatureData(tools=copy.deepcopy(temp), bed=copy.deepcopy(bedTemp), chamber=copy.deepcopy(chamberTemp))
|
||||
def on_comm_temperature_update(self, tools, bed, chamber, custom=None):
|
||||
if custom is None:
|
||||
custom = dict()
|
||||
self._addTemperatureData(tools=copy.deepcopy(tools),
|
||||
bed=copy.deepcopy(bed),
|
||||
chamber=copy.deepcopy(chamber),
|
||||
custom=copy.deepcopy(custom))
|
||||
|
||||
def on_comm_position_update(self, position, reason=None):
|
||||
payload = dict(reason=reason)
|
||||
|
||||
@@ -279,10 +279,13 @@ class PositionRecord(object):
|
||||
return dict((attr, getattr(self, attr)) for attr in attrs)
|
||||
|
||||
class TemperatureRecord(object):
|
||||
RESERVED_IDENTIFIER_REGEX = re.compile("[0-9]+|[bc]")
|
||||
|
||||
def __init__(self):
|
||||
self._tools = dict()
|
||||
self._bed = (None, None)
|
||||
self._chamber = (None, None)
|
||||
self._custom = dict()
|
||||
|
||||
def copy_from(self, other):
|
||||
self._tools = other.tools
|
||||
@@ -300,6 +303,12 @@ class TemperatureRecord(object):
|
||||
current = self._chamber
|
||||
self._chamber = self._to_new_tuple(current, actual, target)
|
||||
|
||||
def set_custom(self, identifier, actual=None, target=None):
|
||||
if self.RESERVED_IDENTIFIER_REGEX.match(identifier):
|
||||
raise ValueError("{} is a reserved identifier".format(identifier))
|
||||
current = self._custom.get(identifier, (None, None))
|
||||
self._custom[identifier] = self._to_new_tuple(current, actual, target)
|
||||
|
||||
@property
|
||||
def tools(self):
|
||||
return dict(self._tools)
|
||||
@@ -312,6 +321,10 @@ class TemperatureRecord(object):
|
||||
def chamber(self):
|
||||
return self._chamber
|
||||
|
||||
@property
|
||||
def custom(self):
|
||||
return dict(self._custom)
|
||||
|
||||
def as_script_dict(self):
|
||||
result = dict()
|
||||
|
||||
@@ -328,6 +341,11 @@ class TemperatureRecord(object):
|
||||
result["c"] = dict(actual=chamber[0],
|
||||
target=chamber[1])
|
||||
|
||||
custom = self.custom
|
||||
for identifier, data in custom.items():
|
||||
result[identifier] = dict(actual=data[0],
|
||||
target=data[1])
|
||||
|
||||
return result
|
||||
|
||||
@classmethod
|
||||
@@ -1580,22 +1598,31 @@ class MachineCom(object):
|
||||
if not tool in parsedTemps:
|
||||
if shared_nozzle:
|
||||
actual, target = parsedTemps[current_tool_key]
|
||||
del parsedTemps[current_tool_key]
|
||||
else:
|
||||
continue
|
||||
else:
|
||||
actual, target = parsedTemps[tool]
|
||||
del parsedTemps[tool]
|
||||
self.last_temperature.set_tool(n, actual=actual, target=target)
|
||||
|
||||
# bed temperature
|
||||
if "B" in parsedTemps:
|
||||
actual, target = parsedTemps["B"]
|
||||
del parsedTemps["B"]
|
||||
self.last_temperature.set_bed(actual=actual, target=target)
|
||||
|
||||
# chamber temperature
|
||||
if "C" in parsedTemps and (self._capability_supported(self.CAPABILITY_CHAMBER_TEMP) or self._printerProfileManager.get_current_or_default()["heatedChamber"]):
|
||||
actual, target = parsedTemps["C"]
|
||||
del parsedTemps["C"]
|
||||
self.last_temperature.set_chamber(actual=actual, target=target)
|
||||
|
||||
# all other injected temperatures
|
||||
for key in parsedTemps.keys():
|
||||
actual, target = parsedTemps[key]
|
||||
self.last_temperature.set_custom(key, actual=actual, target=target)
|
||||
|
||||
##~~ Serial monitor processing received messages
|
||||
|
||||
def _monitor(self):
|
||||
@@ -1866,7 +1893,7 @@ class MachineCom(object):
|
||||
self._heatupWaitStartTime = monotonic_time()
|
||||
|
||||
self._processTemperatures(line)
|
||||
self._callback.on_comm_temperature_update(self.last_temperature.tools, self.last_temperature.bed, self.last_temperature.chamber)
|
||||
self._callback.on_comm_temperature_update(self.last_temperature.tools, self.last_temperature.bed, self.last_temperature.chamber, self.last_temperature.custom)
|
||||
|
||||
elif supportRepetierTargetTemp and ('TargetExtr' in line or 'TargetBed' in line):
|
||||
matchExtr = regex_repetierTempExtr.match(line)
|
||||
@@ -1877,14 +1904,14 @@ class MachineCom(object):
|
||||
try:
|
||||
target = float(matchExtr.group(2))
|
||||
self.last_temperature.set_tool(toolNum, target=target)
|
||||
self._callback.on_comm_temperature_update(self.last_temperature.tools, self.last_temperature.bed, self.last_temperature.chamber)
|
||||
self._callback.on_comm_temperature_update(self.last_temperature.tools, self.last_temperature.bed, self.last_temperature.chamber, self.last_temperature.custom)
|
||||
except ValueError:
|
||||
pass
|
||||
elif matchBed is not None:
|
||||
try:
|
||||
target = float(matchBed.group(1))
|
||||
self.last_temperature.set_bed(target=target)
|
||||
self._callback.on_comm_temperature_update(self.last_temperature.tools, self.last_temperature.bed, self.last_temperature.chamber)
|
||||
self._callback.on_comm_temperature_update(self.last_temperature.tools, self.last_temperature.bed, self.last_temperature.chamber, self.last_temperature.custom)
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
@@ -3666,7 +3693,7 @@ class MachineCom(object):
|
||||
try:
|
||||
target = float(match.group("value"))
|
||||
self.last_temperature.set_tool(toolNum, target=target)
|
||||
self._callback.on_comm_temperature_update(self.last_temperature.tools, self.last_temperature.bed, self.last_temperature.chamber)
|
||||
self._callback.on_comm_temperature_update(self.last_temperature.tools, self.last_temperature.bed, self.last_temperature.chamber, self.last_temperature.custom)
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
@@ -3679,7 +3706,7 @@ class MachineCom(object):
|
||||
try:
|
||||
target = float(match.group("value"))
|
||||
self.last_temperature.set_bed(target=target)
|
||||
self._callback.on_comm_temperature_update(self.last_temperature.tools, self.last_temperature.bed, self.last_temperature.chamber)
|
||||
self._callback.on_comm_temperature_update(self.last_temperature.tools, self.last_temperature.bed, self.last_temperature.chamber, self.last_temperature.custom)
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
@@ -3692,7 +3719,7 @@ class MachineCom(object):
|
||||
try:
|
||||
target = float(match.group("value"))
|
||||
self.last_temperature.set_chamber(target=target)
|
||||
self._callback.on_comm_temperature_update(self.last_temperature.tools, self.last_temperature.bed, self.last_temperature.chamber)
|
||||
self._callback.on_comm_temperature_update(self.last_temperature.tools, self.last_temperature.bed, self.last_temperature.chamber, self.last_temperature.custom)
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
@@ -3880,7 +3907,7 @@ class MachineComPrintCallback(object):
|
||||
def on_comm_log(self, message):
|
||||
pass
|
||||
|
||||
def on_comm_temperature_update(self, temp, bedTemp, chamberTemp):
|
||||
def on_comm_temperature_update(self, temp, bedTemp, chamberTemp, customTemp):
|
||||
pass
|
||||
|
||||
def on_comm_position_update(self, position, reason=None):
|
||||
|
||||
Reference in new issue
Block a user