diff --git a/src/octoprint/plugins/virtual_printer/virtual.py b/src/octoprint/plugins/virtual_printer/virtual.py index 8da71cfa..e972d55d 100644 --- a/src/octoprint/plugins/virtual_printer/virtual.py +++ b/src/octoprint/plugins/virtual_printer/virtual.py @@ -310,11 +310,15 @@ class VirtualPrinter(object): def _gcode_M104(self, data): self._parseHotendCommand(data) - _gcode_M109 = _gcode_M104 + + def _gcode_M109(self, data): + self._parseHotendCommand(data, wait=True, support_r=True) def _gcode_M140(self, data): self._parseBedCommand(data) - _gcode_M190 = _gcode_M140 + + def _gcode_M140(self, data): + self._parseBedCommand(data, wait=True, support_r=True) def _gcode_M105(self, data): self._processTemperatureQuery() @@ -642,7 +646,8 @@ class VirtualPrinter(object): output = "ok " + output self._send(output) - def _parseHotendCommand(self, line): + def _parseHotendCommand(self, line, wait=False, support_r=False): + only_wait_if_higher = True tool = 0 toolMatch = re.search('T([0-9]+)', line) if toolMatch: @@ -657,21 +662,32 @@ class VirtualPrinter(object): try: self.targetTemp[tool] = float(re.search('S([0-9]+)', line).group(1)) except: - pass + if support_r: + try: + self.targetTemp[tool] = float(re.search('R([0-9]+)', line).group(1)) + only_wait_if_higher = False + except: + pass - if "M109" in line: - self._waitForHeatup("tool%d" % tool) + if wait: + self._waitForHeatup("tool%d" % tool, only_wait_if_higher) if settings().getBoolean(["devel", "virtualPrinter", "repetierStyleTargetTemperature"]): self._send("TargetExtr%d:%d" % (tool, self.targetTemp[tool])) - def _parseBedCommand(self, line): + def _parseBedCommand(self, line, wait=False, support_r=False): + only_wait_if_higher = True try: self.bedTargetTemp = float(re.search('S([0-9]+)', line).group(1)) except: - pass + if support_r: + try: + self.bedTargetTemp = float(re.search('R([0-9]+)', line).group(1)) + only_wait_if_higher = False + except: + pass - if "M190" in line: - self._waitForHeatup("bed") + if wait: + self._waitForHeatup("bed", only_wait_if_higher) if settings().getBoolean(["devel", "virtualPrinter", "repetierStyleTargetTemperature"]): self._send("TargetBed:%d" % self.bedTargetTemp) @@ -836,19 +852,19 @@ class VirtualPrinter(object): self._sdPrinter = None self._output("Done printing file") - def _waitForHeatup(self, heater): + def _waitForHeatup(self, heater, only_wait_if_higher): delta = 1 delay = 1 try: if heater.startswith("tool"): toolNum = int(heater[len("tool"):]) - while not self._killed and (self.temp[toolNum] < self.targetTemp[toolNum] - delta or self.temp[toolNum] > self.targetTemp[toolNum] + delta): + while not self._killed and (self.temp[toolNum] < self.targetTemp[toolNum] - delta or (not only_wait_if_higher and self.temp[toolNum] > self.targetTemp[toolNum] + delta)): self._simulateTemps(delta=delta) self._output("T:%0.2f" % self.temp[toolNum]) time.sleep(delay) elif heater == "bed": - while not self._killed and (self.bedTemp < self.bedTargetTemp - delta or self.bedTemp > self.bedTargetTemp + delta): + while not self._killed and (self.bedTemp < self.bedTargetTemp - delta or (not only_wait_if_higher and self.bedTemp > self.bedTargetTemp + delta)): self._simulateTemps(delta=delta) self._output("B:%0.2f" % self.bedTemp) time.sleep(delay) diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index b796e4c1..95af69b1 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -51,7 +51,7 @@ regex_float = re.compile(regex_float_pattern) regexes_parameters = dict( floatP=re.compile("(^|[^A-Za-z])[Pp](?P%s)" % regex_float_pattern), - floatR=re.compile("(^|[^A-Za-z])[Ss](?P%s)" % regex_float_pattern), + floatR=re.compile("(^|[^A-Za-z])[Rr](?P%s)" % regex_float_pattern), floatS=re.compile("(^|[^A-Za-z])[Ss](?P%s)" % regex_float_pattern), floatZ=re.compile("(^|[^A-Za-z])[Zz](?P%s)" % regex_float_pattern), intN=re.compile("(^|[^A-Za-z])[Nn](?P%s)" % regex_int_pattern),