🚧 Expert parameters

This commit is contained in:
Gina Häußge committed 2019-07-18 15:16:01 +02:00
1 parent 395dce457d
commit 4b028562d8
7 files changed
+96 -16

No files matched your search

+29 -8
View File
@@ -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
@@ -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"]
@@ -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
@@ -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<toolnum>\d+):(?P<target>%s)" % regex_positive_float_pattern)
"""Regex for matching target temp reporting from Repetier.
+3 -1
View File
@@ -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,
@@ -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
@@ -5,9 +5,22 @@
</div>
<div class="modal-body">
<form class="form-horizontal" action="javascript:void(0)">
<!-- ko foreach: protocolParameters -->
<!-- ko template: { name: 'connection_dialog_template_' + $data.type, data: $data } --><!-- /ko -->
<!-- /ko -->
<!-- ko foreach: protocolParameters -->
<!-- ko if: !expert -->
<!-- ko template: { name: 'connection_dialog_template_' + $data.type, data: $data } --><!-- /ko -->
<!-- /ko -->
<!-- /ko -->
<div class="advanced_options" data-bind="visible: expertProtocolParameters">
<div><small><a class="muted FNORD" href="#" data-bind="toggleContent: { class: 'fa-caret-right fa-caret-down', parent: '.advanced_options', container: '.hide' }"><i class="fa fa-caret-right"></i> Advanced options</a></small></div>
<div class="hide">
<!-- ko foreach: protocolParameters -->
<!-- ko if: expert -->
<!-- ko template: { name: 'connection_dialog_template_' + $data.type, data: $data } --><!-- /ko -->
<!-- /ko -->
<!-- /ko -->
</div>
</div>
</form>
</div>
<div class="modal-footer">
@@ -159,7 +172,20 @@
<legend data-bind="markdownInline: $data.title"></legend>
<p data-bind="visible: $data.help, markdownInline: $data.help"></p>
<!-- ko foreach: params -->
<!-- ko if: !expert -->
<!-- ko template: { name: 'connection_dialog_template_' + $data.type, data: $data } --><!-- /ko -->
<!-- /ko -->
<!-- /ko -->
<div class="advanced_options" data-bind="visible: expertParameters">
<div><small><a href="#" class="muted FNORD" data-bind="toggleContent: { class: 'fa-caret-right fa-caret-down', parent: '.advanced_options', container: '.hide' }"><i class="fa fa-caret-right"></i> {{ _('Advanced options') }}</a></small></div>
<div class="hide">
<!-- ko foreach: params -->
<!-- ko if: expert -->
<!-- ko template: { name: 'connection_dialog_template_' + $data.type, data: $data } --><!-- /ko -->
<!-- /ko -->
<!-- /ko -->
</div>
</div>
</fieldset>
</script>