New custom control type "feedback"
Like "feedback_command", but without the buttonmaster
parent
6ab8b76859
commit
3e0abf1b20
|
@ -248,7 +248,7 @@ class Settings(object):
|
|||
return feedbackControls
|
||||
|
||||
def _getFeedbackControls(self, control=None):
|
||||
if control["type"] == "feedback_command":
|
||||
if control["type"] == "feedback_command" or control["type"] == "feedback":
|
||||
pattern = control["regex"]
|
||||
try:
|
||||
matcher = re.compile(pattern)
|
||||
|
|
|
@ -68,7 +68,7 @@ function ControlViewModel(loginStateViewModel, settingsViewModel) {
|
|||
for (var i = 0; i < control.input.length; i++) {
|
||||
control.input[i].value = control.input[i].default;
|
||||
}
|
||||
} else if (control.type == "feedback_command") {
|
||||
} else if (control.type == "feedback_command" || control.type == "feedback") {
|
||||
control.output = ko.observable("");
|
||||
self.feedbackControlLookup[control.name] = control.output;
|
||||
} else if (control.type == "section") {
|
||||
|
@ -162,6 +162,8 @@ function ControlViewModel(loginStateViewModel, settingsViewModel) {
|
|||
return "customControls_parametricCommandTemplate";
|
||||
case "feedback_command":
|
||||
return "customControls_feedbackCommandTemplate";
|
||||
case "feedback":
|
||||
return "customControls_feedbackTemplate";
|
||||
default:
|
||||
return "customControls_emptyTemplate";
|
||||
}
|
||||
|
|
|
@ -402,6 +402,11 @@
|
|||
<button class="btn" data-bind="text: name, enable: $root.isOperational() && $root.loginState.isUser(), click: function() { $root.sendCustomCommand($data) }"></button> <span data-bind="text: output"></span>
|
||||
</form>
|
||||
</script>
|
||||
<script type="text/html" id="customControls_feedbackTemplate">
|
||||
<div>
|
||||
<strong data-bind="text: name"></strong>: <span data-bind="text: output"></span>
|
||||
</div>
|
||||
</script>
|
||||
<script type="text/html" id="customControls_parametricCommandTemplate">
|
||||
<form class="form-inline">
|
||||
<!-- ko foreach: input -->
|
||||
|
|
|
@ -448,6 +448,7 @@ class MachineCom(object):
|
|||
def _monitor(self):
|
||||
feedbackControls = settings().getFeedbackControls()
|
||||
pauseTriggers = settings().getPauseTriggers()
|
||||
feedbackErrors = []
|
||||
|
||||
#Open the serial port.
|
||||
if self._port == 'AUTO':
|
||||
|
@ -606,9 +607,18 @@ class MachineCom(object):
|
|||
try:
|
||||
match = matcher.search(line)
|
||||
if match is not None:
|
||||
self._callback.mcReceivedRegisteredMessage(name, str.format(template, *(match.groups("n/a"))))
|
||||
format = None
|
||||
if isinstance(template, str):
|
||||
format = str.format
|
||||
elif isinstance(template, unicode):
|
||||
format = unicode.format
|
||||
|
||||
if format is not None:
|
||||
self._callback.mcReceivedRegisteredMessage(name, format(template, *(match.groups("n/a"))))
|
||||
except:
|
||||
# ignored on purpose
|
||||
if not name in feedbackErrors:
|
||||
self._logger.info("Something went wrong with feedbackControl \"%s\": " % name, exc_info=True)
|
||||
feedbackErrors.append(name)
|
||||
pass
|
||||
|
||||
##~~ Parsing for pause triggers
|
||||
|
|
Loading…
Reference in New Issue