From 4b028562d8f97b4b1a0e0ebd7b208386d8fe214c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 18 Jul 2019 15:16:01 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A7=20Expert=20parameters?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../comm/protocol/reprap/__init__.py | 37 +++++++++++++++---- .../comm/protocol/reprap/flavors/generic.py | 1 + .../comm/protocol/reprap/flavors/malyan.py | 3 +- .../comm/protocol/reprap/flavors/repetier.py | 2 + src/octoprint/comm/util/parameters.py | 4 +- .../static/js/app/viewmodels/connection.js | 33 +++++++++++++++-- .../templates/dialogs/connection.jinja2 | 32 ++++++++++++++-- 7 files changed, 96 insertions(+), 16 deletions(-) diff --git a/src/octoprint/comm/protocol/reprap/__init__.py b/src/octoprint/comm/protocol/reprap/__init__.py index a831ab429..4a8bdad46 100644 --- a/src/octoprint/comm/protocol/reprap/__init__.py +++ b/src/octoprint/comm/protocol/reprap/__init__.py @@ -140,9 +140,25 @@ class ReprapGcodeProtocol(Protocol, ThreeDPrinterProtocolMixin, MotorControlProt Value("never", title=gettext("Never"))]), SmallChoiceType("trigger_ok_after_resend", gettext("Trigger ok after resend"), - [Value("detect", title=gettext("As detected")), + [Value("detect", title=gettext("If detected as necessary")), Value("always", title=gettext("Always")), - Value("never", title=gettext("Never"))]), + Value("never", title=gettext("Never"))], + expert=True, + help=gettext("Some Marlin forks lack an acknowledging `ok` with their resend requests. Set this to \"Always\" or \"If detected as necessary\" if you run into communication stalls on resend requests.")), + BooleanType("unknown_requires_ack", + gettext("Unknown commands require `ok`")), + BooleanType("unknown_with_checksum", + gettext("Send unknown commands with line number & checksum")), + BooleanType("detect_external_heatups", + gettext("Try to detect externally triggered blocking heatups")), + BooleanType("block_while_dwelling", + gettext("Block all communication while a dwell command (`G4`) is active")), + BooleanType("sd_relative_path", + gettext("Select SD files by relative path")), + BooleanType("sd_always_available", + gettext("Always assume that the SD card is present")), + BooleanType("heatup_abortable", + gettext("Allow cancelling blocking heatups if the firmware supports it")), SmallListType("blocked_commands", gettext("Blocked commands"), help=gettext("Use this to specify commands that should never be sent to the printer. Just the G or M code, comma separated. Defaults to `M0` and `M1` since most firmware will block until a button on the controller has been pressed if it receives either of those two commands.")), @@ -154,13 +170,16 @@ class ReprapGcodeProtocol(Protocol, ThreeDPrinterProtocolMixin, MotorControlProt help=gettext("")), SmallListType("asynchronous_commands", gettext("Asynchronous commands"), - help=gettext("")), + help=gettext(""), + expert=True), SmallListType("pausing_commands", gettext("Pausing commands"), - help=gettext("")), + help=gettext(""), + expert=True), SmallListType("emergency_commands", gettext("Emergency commands"), - help=gettext("")) + help=gettext(""), + expert=True) ], help=gettext("You can override the firmware flavor default settings here. You usually should *not* need to do that. Only change anything if the defaults don't work for your printer."), advanced=True), @@ -241,7 +260,7 @@ class ReprapGcodeProtocol(Protocol, ThreeDPrinterProtocolMixin, MotorControlProt unit="sec", help=gettext("`busy` protocol support detected")), FloatType("connection_timeout", - gettext("Connection"), + gettext("Connection timeout"), default=10, unit="sec"), FloatType("detection_timeout", @@ -250,19 +269,21 @@ class ReprapGcodeProtocol(Protocol, ThreeDPrinterProtocolMixin, MotorControlProt unit="sec", help=""), FloatType("position_log_wait", - gettext("Position Log Wait"), + gettext("Position query"), default=10, unit="sec"), FloatType("baudrate_detection_pause", gettext("Initial baudrate detection pause"), + expert=True, default=1.0, unit="sec", help=gettext("Some controllers need a bit of a breather before baudrate detection after initial connect. If baudrate detection fails due to a hanging controller, try increasing this value.")), FloatType("resendok_timeout", gettext("Timeout for `ok` after resend detection"), + expert=True, default=.5, unit="sec", - help=gettext("Some firmwares do not send an `ok` after a resend request. This timeout configures how long OctoPrint will wait for one until it assumes this particular bug to be present and generate its own."))], + help=gettext("Some firmwares do not send an `ok` after a resend request. This timeout configures how long OctoPrint will wait for one until it assumes this particular bug to be present and generate its own."),)], advanced=True)] @staticmethod diff --git a/src/octoprint/comm/protocol/reprap/flavors/generic.py b/src/octoprint/comm/protocol/reprap/flavors/generic.py index 9ddb7af2e..b1bd47a0e 100644 --- a/src/octoprint/comm/protocol/reprap/flavors/generic.py +++ b/src/octoprint/comm/protocol/reprap/flavors/generic.py @@ -58,6 +58,7 @@ class GenericFlavor(with_metaclass(FlavorMeta, object)): trigger_ok_after_resend = "detect" sd_relative_path = False + sd_always_available = False checksum_requiring_commands = ["M110"] long_running_commands = ["G4", "G28", "G29", "G30", "G32", "M190", "M109", "M400", "M226"] diff --git a/src/octoprint/comm/protocol/reprap/flavors/malyan.py b/src/octoprint/comm/protocol/reprap/flavors/malyan.py index ab13bfff9..7ed86c58d 100644 --- a/src/octoprint/comm/protocol/reprap/flavors/malyan.py +++ b/src/octoprint/comm/protocol/reprap/flavors/malyan.py @@ -11,7 +11,8 @@ class MalyanFlavor(GenericFlavor): key = "malyan" name = "Malyan" - always_send_checksum = False + send_checksum = "printing" + block_while_dwelling = True sd_always_available = True diff --git a/src/octoprint/comm/protocol/reprap/flavors/repetier.py b/src/octoprint/comm/protocol/reprap/flavors/repetier.py index 29dc4b430..8f40ac09f 100644 --- a/src/octoprint/comm/protocol/reprap/flavors/repetier.py +++ b/src/octoprint/comm/protocol/reprap/flavors/repetier.py @@ -20,6 +20,8 @@ class RepetierFlavor(GenericFlavor): block_while_dwelling = True detect_external_heatups = False + sd_always_available = True + regex_tempextr = re.compile("targetextr(?P\d+):(?P%s)" % regex_positive_float_pattern) """Regex for matching target temp reporting from Repetier. diff --git a/src/octoprint/comm/util/parameters.py b/src/octoprint/comm/util/parameters.py index 43a3f0889..31f249542 100644 --- a/src/octoprint/comm/util/parameters.py +++ b/src/octoprint/comm/util/parameters.py @@ -21,7 +21,7 @@ def get_param_dict(data, options): class ParamType(object): type = "generic" - def __init__(self, name, title, default=None, advanced=False, warning=False, labels=None, help=None): + def __init__(self, name, title, default=None, advanced=False, expert=False, warning=False, labels=None, help=None): if labels is None: labels = [] @@ -29,6 +29,7 @@ class ParamType(object): self.title = title self.default = default self.advanced = advanced + self.expert = expert self.warning = warning self.labels = labels self.help = help @@ -38,6 +39,7 @@ class ParamType(object): title=self.title, default=self.default, advanced=self.advanced, + expert=self.expert, warning=self.warning, labels=self.labels, help=self.help, diff --git a/src/octoprint/static/js/app/viewmodels/connection.js b/src/octoprint/static/js/app/viewmodels/connection.js index 45d26eba1..f9007ce50 100644 --- a/src/octoprint/static/js/app/viewmodels/connection.js +++ b/src/octoprint/static/js/app/viewmodels/connection.js @@ -8,6 +8,18 @@ $(function() { self.printerProfiles = parameters[3]; self.access = parameters[4]; + var checkRecursively = function(params, check) { + return _.any(params, function(p) { + if (p.type === "group") { + return check(p) || checkRecursively(p.params, check); + } else if (p.type === "groupchoice" && p.group) { + return check(p) || check(p.group) || checkRecursively(p.group.params, check); + } else { + return check(p); + } + }); + }; + var convertValue = function(value, option, override) { if (override !== undefined) { value = override; @@ -32,6 +44,9 @@ $(function() { _.each(option.params, function (option) { extendOption(option, value[option.name]); }); + + option.advancedParameters = option.advanced || _.any(option.params, function(p) { return p.advanced }); + option.expertParameters = option.expert || _.any(option.params, function(p) { return p.expert }); } else { if (option.type === "groupchoice") { value = convertValue(value, option); @@ -57,7 +72,12 @@ $(function() { }); if (option.type === "groupchoice" && option.defaults) { - var updateDefaults = function() { + option.group.advancedParameters = option.group.advanced || _.any(option.group.params, function(p) { return p.advanced }); + option.group.expertParameters = option.group.expert || _.any(option.group.params, function(p) { return p.expert }); + + var updateDefaults = function(keepValue) { + keepValue = !!keepValue; + var choice = _.find(option.choices, function (c) { return c.value === option.value() }); @@ -67,13 +87,16 @@ $(function() { var d = option.defaults[choice.value][p.name]; if (d !== undefined) { p.defaultValue(convertValue(d, p, override ? override[p.name] : undefined)); + if (!keepValue) { + p.value(p.defaultValue()); + } } } }) } }; - option.value.subscribe(updateDefaults); - updateDefaults(); + option.value.subscribe(function() { updateDefaults() }); + updateDefaults(true); } } @@ -137,6 +160,7 @@ $(function() { self.selectedProtocol = ko.observable(undefined); self.protocolParameters = ko.observable(); self.advancedProtocolParameters = ko.observable(); + self.expertProtocolParameters = ko.observable(); self.showAdvancedProtocolOptions = function() { $("#connection_protocol_dialog").modal("show"); }; @@ -150,6 +174,7 @@ $(function() { } self.advancedProtocolParameters(_.any(self.protocolParameters(), function(p) { return p.advanced })); + self.expertProtocolParameters(_.any(self.protocolParameters(), function(p) { return p.expert })); }); // Transports @@ -158,6 +183,7 @@ $(function() { self.selectedTransport = ko.observable(undefined); self.transportParameters = ko.observableArray(); self.advancedTransportParameters = ko.observable(); + self.expertTransportParameters = ko.observable(); self.showAdvancedTransportOptions = function() { $("#connection_transport_dialog").modal("show"); }; @@ -171,6 +197,7 @@ $(function() { } self.advancedTransportParameters(_.any(self.transportParameters(), function(p) { return p.advanced })); + self.expertTransportParameters(_.any(self.transportParameters(), function(p) { return p.expert })); }); // Various other bits diff --git a/src/octoprint/templates/dialogs/connection.jinja2 b/src/octoprint/templates/dialogs/connection.jinja2 index fa5685626..84288c427 100644 --- a/src/octoprint/templates/dialogs/connection.jinja2 +++ b/src/octoprint/templates/dialogs/connection.jinja2 @@ -5,9 +5,22 @@