From 6d3b1b7f131e15e465b9419c83536a0dd7083c1f Mon Sep 17 00:00:00 2001 From: Nicanor Romero Venier Date: Wed, 26 Aug 2015 17:55:34 +0200 Subject: [PATCH] Added possibility of never sending checksums Within the settings/features there is now a block of radio buttons where the user can select whether to send checksums only when printing, always or never. In order to maintain backward compatibility in the settings, this is stored in two variables, alwaysSendChecksum and neverSendChecksum. If both are False, it is assumed that checksums are sent only when printing, being this the default value. --- src/octoprint/server/api/settings.py | 2 ++ src/octoprint/settings.py | 1 + .../static/js/app/viewmodels/settings.js | 10 ++++++--- .../dialogs/settings/features.jinja2 | 21 ++++++++++++------- src/octoprint/util/comm.py | 3 ++- 5 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/octoprint/server/api/settings.py b/src/octoprint/server/api/settings.py index 78858407..ff48336c 100644 --- a/src/octoprint/server/api/settings.py +++ b/src/octoprint/server/api/settings.py @@ -63,6 +63,7 @@ def getSettings(): "temperatureGraph": s.getBoolean(["feature", "temperatureGraph"]), "waitForStart": s.getBoolean(["feature", "waitForStartOnConnect"]), "alwaysSendChecksum": s.getBoolean(["feature", "alwaysSendChecksum"]), + "neverSendChecksum": s.getBoolean(["feature", "neverSendChecksum"]), "sdSupport": s.getBoolean(["feature", "sdSupport"]), "sdAlwaysAvailable": s.getBoolean(["feature", "sdAlwaysAvailable"]), "swallowOkAfterResend": s.getBoolean(["feature", "swallowOkAfterResend"]), @@ -211,6 +212,7 @@ def _saveSettings(data): if "temperatureGraph" in data["feature"].keys(): s.setBoolean(["feature", "temperatureGraph"], data["feature"]["temperatureGraph"]) if "waitForStart" in data["feature"].keys(): s.setBoolean(["feature", "waitForStartOnConnect"], data["feature"]["waitForStart"]) if "alwaysSendChecksum" in data["feature"].keys(): s.setBoolean(["feature", "alwaysSendChecksum"], data["feature"]["alwaysSendChecksum"]) + if "neverSendChecksum" in data["feature"].keys(): s.setBoolean(["feature", "neverSendChecksum"], data["feature"]["neverSendChecksum"]) if "sdSupport" in data["feature"].keys(): s.setBoolean(["feature", "sdSupport"], data["feature"]["sdSupport"]) if "sdAlwaysAvailable" in data["feature"].keys(): s.setBoolean(["feature", "sdAlwaysAvailable"], data["feature"]["sdAlwaysAvailable"]) if "swallowOkAfterResend" in data["feature"].keys(): s.setBoolean(["feature", "swallowOkAfterResend"], data["feature"]["swallowOkAfterResend"]) diff --git a/src/octoprint/settings.py b/src/octoprint/settings.py index 2419b8e4..2181c834 100644 --- a/src/octoprint/settings.py +++ b/src/octoprint/settings.py @@ -143,6 +143,7 @@ default_settings = { "temperatureGraph": True, "waitForStartOnConnect": False, "alwaysSendChecksum": False, + "neverSendChecksum": False, "sendChecksumWithUnknownCommands": False, "unknownCommandsNeedAck": False, "sdSupport": True, diff --git a/src/octoprint/static/js/app/viewmodels/settings.js b/src/octoprint/static/js/app/viewmodels/settings.js index 561fbb5a..ea485b45 100644 --- a/src/octoprint/static/js/app/viewmodels/settings.js +++ b/src/octoprint/static/js/app/viewmodels/settings.js @@ -113,7 +113,7 @@ $(function() { self.feature_gcodeViewer = ko.observable(undefined); self.feature_temperatureGraph = ko.observable(undefined); self.feature_waitForStart = ko.observable(undefined); - self.feature_alwaysSendChecksum = ko.observable(undefined); + self.feature_sendChecksum = ko.observable("print"); self.feature_sdSupport = ko.observable(undefined); self.feature_sdAlwaysAvailable = ko.observable(undefined); self.feature_swallowOkAfterResend = ko.observable(undefined); @@ -525,7 +525,9 @@ $(function() { // some special read functions for various observables var specialMappings = { feature: { - externalHeatupDetection: function() { return !self.feature_disableExternalHeatupDetection() } + externalHeatupDetection: function() { return !self.feature_disableExternalHeatupDetection()}, + alwaysSendChecksum: function() { return self.feature_sendChecksum() == "always"}, + neverSendChecksum: function() { return self.feature_sendChecksum() == "never"} }, serial: { additionalPorts : function() { return commentableLinesToArray(self.serial_additionalPorts()) }, @@ -614,7 +616,9 @@ $(function() { } }, feature: { - externalHeatupDetection: function(value) { self.feature_disableExternalHeatupDetection(!value) } + externalHeatupDetection: function(value) { self.feature_disableExternalHeatupDetection(!value) }, + alwaysSendChecksum: function(value) { if (value) { self.feature_sendChecksum("always")}}, + neverSendChecksum: function(value) { if (value) { self.feature_sendChecksum("never")}} }, serial: { additionalPorts : function(value) { self.serial_additionalPorts(value.join("\n"))}, diff --git a/src/octoprint/templates/dialogs/settings/features.jinja2 b/src/octoprint/templates/dialogs/settings/features.jinja2 index 97a5864f..abb0c38a 100644 --- a/src/octoprint/templates/dialogs/settings/features.jinja2 +++ b/src/octoprint/templates/dialogs/settings/features.jinja2 @@ -41,13 +41,6 @@ -
-
- -
-
+
+ +
+ + + +
+
diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index 5e03842a..719f5b2a 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -240,6 +240,7 @@ class MachineCom(object): self._hello_command = settings().get(["serial", "helloCommand"]) self._alwaysSendChecksum = settings().getBoolean(["feature", "alwaysSendChecksum"]) + self._neverSendChecksum = settings().getBoolean(["feature", "neverSendChecksum"]) self._sendChecksumWithUnknownCommands = settings().getBoolean(["feature", "sendChecksumWithUnknownCommands"]) self._unknownCommandsNeedAck = settings().getBoolean(["feature", "unknownCommandsNeedAck"]) self._currentLine = 1 @@ -1617,7 +1618,7 @@ class MachineCom(object): # now comes the part where we increase line numbers and send stuff - no turning back now command_requiring_checksum = gcode is not None and gcode in self._checksum_requiring_commands command_allowing_checksum = gcode is not None or self._sendChecksumWithUnknownCommands - checksum_enabled = self.isPrinting() or self._alwaysSendChecksum + checksum_enabled = self._alwaysSendChecksum or (self.isPrinting() and not self._neverSendChecksum) if command_requiring_checksum or (command_allowing_checksum and checksum_enabled): linenumber = self._currentLine