From a50db4b08ec2c1c562fd2c38f6d2d799d0c53f65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 17 Jul 2017 15:40:08 +0200 Subject: [PATCH] Options to disable position logging on cancel/pause Provided as a workaround for people who don't want the associated minimal delay in cancelling/pausing. See #1946 --- docs/features/gcode_scripts.rst | 6 ++++++ src/octoprint/server/api/settings.py | 4 ++++ src/octoprint/settings.py | 2 ++ src/octoprint/static/js/app/viewmodels/settings.js | 2 ++ .../dialogs/settings/serialconnection.jinja2 | 12 ++++++++++++ src/octoprint/util/comm.py | 13 +++++++++++-- 6 files changed, 37 insertions(+), 2 deletions(-) diff --git a/docs/features/gcode_scripts.rst b/docs/features/gcode_scripts.rst index 6b14a616..9c12a35c 100644 --- a/docs/features/gcode_scripts.rst +++ b/docs/features/gcode_scripts.rst @@ -87,6 +87,9 @@ There are a few additional template variables available for the following specif * ``pause_position``: Position reported by the printer via ``M114`` immediately before the print was paused. See ``last_position`` above for the structure to expect here. + + **Please note:** This will not be available if you disable + "Log position on pause" under Settings > Serial > Advanced options! * ``pause_temperature``: Last known temperature values when the print was paused. See ``last_temperature`` above for the structure to expect here. @@ -94,6 +97,9 @@ There are a few additional template variables available for the following specif * ``cancel_position``: Position reported by the printer via ``M114`` immediately before the print was cancelled. See ``last_position`` above for the structure to expect here. + + **Please note:** This will not be available if you disable + "Log position on cancel" under Settings > Serial > Advanced options! * ``cancel_temperature``: Last known temperature values when the print was cancelled. See ``last_temperature`` above for the structure to expect here. diff --git a/src/octoprint/server/api/settings.py b/src/octoprint/server/api/settings.py index 65eefc9d..0e39ecb6 100644 --- a/src/octoprint/server/api/settings.py +++ b/src/octoprint/server/api/settings.py @@ -154,6 +154,8 @@ def getSettings(): "ignoreErrorsFromFirmware": s.getBoolean(["serial", "ignoreErrorsFromFirmware"]), "disconnectOnErrors": s.getBoolean(["serial", "disconnectOnErrors"]), "triggerOkForM29": s.getBoolean(["serial", "triggerOkForM29"]), + "logPositionOnPause": s.getBoolean(["serial", "logPositionOnPause"]), + "logPositionOnCancel": s.getBoolean(["serial", "logPositionOnCancel"]), "supportResendsWithoutOk": s.getBoolean(["serial", "supportResendsWithoutOk"]), "maxTimeoutsIdle": s.getInt(["serial", "maxCommunicationTimeouts", "idle"]), "maxTimeoutsPrinting": s.getInt(["serial", "maxCommunicationTimeouts", "printing"]), @@ -365,6 +367,8 @@ def _saveSettings(data): if "disconnectOnErrors" in data["serial"]: s.setBoolean(["serial", "disconnectOnErrors"], data["serial"]["disconnectOnErrors"]) if "triggerOkForM29" in data["serial"]: s.setBoolean(["serial", "triggerOkForM29"], data["serial"]["triggerOkForM29"]) if "supportResendsWithoutOk" in data["serial"]: s.setBoolean(["serial", "supportResendsWithoutOk"], data["serial"]["supportResendsWithoutOk"]) + if "logPositionOnPause" in data["serial"]: s.setBoolean(["serial", "logPositionOnPause"], data["serial"]["logPositionOnPause"]) + if "logPositionOnCancel" in data["serial"]: s.setBoolean(["serial", "logPositionOnCancel"], data["serial"]["logPositionOnCancel"]) if "maxTimeoutsIdle" in data["serial"]: s.setInt(["serial", "maxCommunicationTimeouts", "idle"], data["serial"]["maxTimeoutsIdle"]) if "maxTimeoutsPrinting" in data["serial"]: s.setInt(["serial", "maxCommunicationTimeouts", "printing"], data["serial"]["maxTimeoutsPrinting"]) if "maxTimeoutsLong" in data["serial"]: s.setInt(["serial", "maxCommunicationTimeouts", "long"], data["serial"]["maxTimeoutsLong"]) diff --git a/src/octoprint/settings.py b/src/octoprint/settings.py index 269fa3de..75908a66 100644 --- a/src/octoprint/settings.py +++ b/src/octoprint/settings.py @@ -112,6 +112,8 @@ default_settings = { "ignoreErrorsFromFirmware": False, "logResends": True, "supportResendsWithoutOk": False, + "logPositionOnPause": True, + "logPositionOnCancel": True, # command specific flags "triggerOkForM29": True diff --git a/src/octoprint/static/js/app/viewmodels/settings.js b/src/octoprint/static/js/app/viewmodels/settings.js index 15a34ac6..16b2ceb0 100644 --- a/src/octoprint/static/js/app/viewmodels/settings.js +++ b/src/octoprint/static/js/app/viewmodels/settings.js @@ -173,6 +173,8 @@ $(function() { self.serial_disconnectOnErrors = ko.observable(undefined); self.serial_triggerOkForM29 = ko.observable(undefined); self.serial_supportResendsWithoutOk = ko.observable(undefined); + self.serial_logPositionOnPause = ko.observable(undefined); + self.serial_logPositionOnCancel = ko.observable(undefined); self.serial_maxTimeoutsIdle = ko.observable(undefined); self.serial_maxTimeoutsPrinting = ko.observable(undefined); self.serial_maxTimeoutsLong = ko.observable(undefined); diff --git a/src/octoprint/templates/dialogs/settings/serialconnection.jinja2 b/src/octoprint/templates/dialogs/settings/serialconnection.jinja2 index 528889eb..6860d50b 100644 --- a/src/octoprint/templates/dialogs/settings/serialconnection.jinja2 +++ b/src/octoprint/templates/dialogs/settings/serialconnection.jinja2 @@ -151,6 +151,18 @@ {{ _('Simulate an additional ok for resend requests') }} +
+ +
+
+ +
diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index 0cbaf9fe..f8c50eec 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -461,6 +461,9 @@ class MachineCom(object): self._record_pause_data = False self._record_cancel_data = False + self._log_position_on_pause = settings().getBoolean(["serial", "logPositionOnPause"]) + self._log_position_on_cancel = settings().getBoolean(["serial", "logPositionOnCancel"]) + # print job self._currentFile = None @@ -944,7 +947,10 @@ class MachineCom(object): except: pass - self.sendCommand("M400", on_sent=_on_M400_sent) + if self._log_position_on_cancel: + self.sendCommand("M400", on_sent=_on_M400_sent) + else: + self._cancel_preparation_done() def _pause_preparation_done(self): self._callback.on_comm_print_job_paused() @@ -991,7 +997,10 @@ class MachineCom(object): self._record_pause_data = True self.sendCommand("M114") - self.sendCommand("M400", on_sent=_on_M400_sent) + if self._log_position_on_pause: + self.sendCommand("M400", on_sent=_on_M400_sent) + else: + self._pause_preparation_done() def getSdFiles(self): return self._sdFiles