From cd578dc2e134f4f610eae5f668994590f33f2bb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 17 Oct 2016 10:29:16 +0200 Subject: [PATCH 1/2] Checking M109/M190 for R should actually check for R and not S Thanks @FHeilmann --- src/octoprint/util/comm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index 9f3b123e..91ce6c33 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -48,7 +48,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), From 696904bc49ab6e21d0731cdc652e3a8712086f8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 17 Oct 2016 10:41:39 +0200 Subject: [PATCH 2/2] Support M1{09|90} R in virtual printer too --- .../plugins/virtual_printer/virtual.py | 40 +++++++++++++------ 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/src/octoprint/plugins/virtual_printer/virtual.py b/src/octoprint/plugins/virtual_printer/virtual.py index 7f0b1457..86514473 100644 --- a/src/octoprint/plugins/virtual_printer/virtual.py +++ b/src/octoprint/plugins/virtual_printer/virtual.py @@ -237,10 +237,12 @@ class VirtualPrinter(object): #print "Send: %s" % (data.rstrip()) if 'M104' in data or 'M109' in data: - self._parseHotendCommand(data) + wait = support_r = 'M109' in data + self._parseHotendCommand(data, wait=wait, support_r=support_r) if 'M140' in data or 'M190' in data: - self._parseBedCommand(data) + wait = support_r = 'M190' in data + self._parseBedCommand(data, wait=wait, support_r=support_r) if 'M105' in data: self._processTemperatureQuery() @@ -523,7 +525,8 @@ class VirtualPrinter(object): output = "ok " + output self._output(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: @@ -538,21 +541,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._output("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._output("TargetBed:%d" % self.bedTargetTemp) @@ -717,19 +731,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)