🚸 Event & notifications for suppressed commands
Seems to confuse people with incorrectly configured printer profiles, see various forum threads and issues on the issue tracker. This will hopefully make such cases more transparent, though a bit spammy (hence there's also a setting).
This commit is contained in:
1 parent
4dea9f08ef
commit
79814905fa
7 files changed
+164
-19
No files matched your search
@@ -606,6 +606,32 @@ ToolChange
|
||||
|
||||
.. versionadded:: 1.3.5
|
||||
|
||||
CommandSuppressed
|
||||
A command was suppressed by OctoPrint due to according configuration and will not be
|
||||
sent to the printer.
|
||||
|
||||
Payload:
|
||||
|
||||
* ``command``: the command that was suppressed
|
||||
* ``message``: a message containing an explanation of the command suppression
|
||||
* ``severity``: a severity level, either ``warn`` or ``info`` - ``warn`` indicates
|
||||
that the command was suppressed probably due to a misconfiguration either inside
|
||||
OctoPrint or the firmware and that it should be investigated by the user
|
||||
|
||||
.. versionadded:: 1.5.0
|
||||
|
||||
InvalidToolReported
|
||||
The firmware reported a tool as invalid upon trying to select it. It has thus been marked
|
||||
as invalid and further attempts to select said tool will result in the tool command
|
||||
to get suppressed (and ``SuppressedCommand`` to be generated).
|
||||
|
||||
Payload:
|
||||
|
||||
* ``tool``: the tool number that was reported as invalid by the firmware
|
||||
* ``fallback``: the tool number that OctoPrint will revert to
|
||||
|
||||
.. versionadded:: 1.5.0
|
||||
|
||||
.. _sec-events-available_events-timelapses:
|
||||
|
||||
Timelapses
|
||||
|
||||
@@ -104,6 +104,8 @@ class Events(object):
|
||||
FIRMWARE_DATA = "FirmwareData"
|
||||
TOOL_CHANGE = "ToolChange"
|
||||
REGISTERED_MESSAGE_RECEIVED = "RegisteredMessageReceived"
|
||||
COMMAND_SUPPRESSED = "CommandSuppressed"
|
||||
INVALID_TOOL_REPORTED = "InvalidToolReported"
|
||||
|
||||
# Timelapse
|
||||
CAPTURE_START = "CaptureStart"
|
||||
|
||||
@@ -218,6 +218,7 @@ def getSettings():
|
||||
"blockWhileDwelling": s.getBoolean(["serial", "blockWhileDwelling"]),
|
||||
"useParityWorkaround": s.get(["serial", "useParityWorkaround"]),
|
||||
"sanityCheckTools": s.getBoolean(["serial", "sanityCheckTools"]),
|
||||
"notifySuppressedCommands": s.get(["serial", "notifySuppressedCommands"]),
|
||||
"sendM112OnError": s.getBoolean(["serial", "sendM112OnError"]),
|
||||
"disableSdPrintingDetection": s.getBoolean(
|
||||
["serial", "disableSdPrintingDetection"]
|
||||
@@ -797,6 +798,10 @@ def _saveSettings(data):
|
||||
s.setBoolean(
|
||||
["serial", "sanityCheckTools"], data["serial"]["sanityCheckTools"]
|
||||
)
|
||||
if "notifySuppressedCommands" in data["serial"]:
|
||||
value = data["serial"]["notifySuppressedCommands"]
|
||||
if value in ("info", "warn", "never"):
|
||||
s.set(["serial", "notifySuppressedCommands"], value)
|
||||
if "sendM112OnError" in data["serial"]:
|
||||
s.setBoolean(["serial", "sendM112OnError"], data["serial"]["sendM112OnError"])
|
||||
if "disableSdPrintingDetection" in data["serial"]:
|
||||
|
||||
@@ -161,6 +161,7 @@ default_settings = {
|
||||
"disableSdPrintingDetection": False,
|
||||
"ackMax": 1,
|
||||
"sanityCheckTools": True,
|
||||
"notifySuppressedCommands": "warn",
|
||||
"capabilities": {
|
||||
"autoreport_temp": True,
|
||||
"autoreport_sdstatus": True,
|
||||
|
||||
@@ -509,6 +509,54 @@ $(function () {
|
||||
self.onBrowserTabVisibilityChange = function (status) {
|
||||
self.updateOutput();
|
||||
};
|
||||
|
||||
self.onEventCommandSuppressed = function (payload) {
|
||||
var setting = self.settings.settings.serial.notifySuppressedCommands();
|
||||
|
||||
if (
|
||||
setting === "never" ||
|
||||
(setting === "warn" && payload.severity === "info")
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
var severity = payload.severity;
|
||||
if (severity === "warn") {
|
||||
severity = "error";
|
||||
} else if (severity === "info") {
|
||||
severity = "warn";
|
||||
}
|
||||
|
||||
var text =
|
||||
"<p>" +
|
||||
gettext(
|
||||
"The command <code>%(command)s</code> was not sent " +
|
||||
"to the printer:"
|
||||
) +
|
||||
"</p><p><pre>%(message)s</pre></p>";
|
||||
|
||||
new PNotify({
|
||||
title: gettext("Suppressed command"),
|
||||
text: _.sprintf(text, payload),
|
||||
type: severity,
|
||||
hide: false
|
||||
});
|
||||
};
|
||||
|
||||
self.onEventInvalidToolReported = function (payload) {
|
||||
new PNotify({
|
||||
title: gettext("Invalid tool reported"),
|
||||
text: _.sprintf(
|
||||
gettext(
|
||||
"Your printer reported tool T%(tool)d as invalid, " +
|
||||
"reverting back to T%(fallback)d"
|
||||
),
|
||||
payload
|
||||
),
|
||||
type: "error",
|
||||
hide: false
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
OCTOPRINT_VIEWMODELS.push({
|
||||
|
||||
@@ -500,6 +500,20 @@
|
||||
<span class="help-block">{{ _('If enabled, OctoPrint will not send tool commands to your printer that exceed the number of extruders configured in the active printer profile, or for which the firmware has reported an "invalid extruder" error. Only uncheck this if OctoPrint or your firmware mistakingly mark valid tools as invalid and be sure to investigate the reason for that, it might be a misconfiguration you need to correct for proper operation.') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label">{{ _('Display notifications for suppressed commands')}}</label>
|
||||
<div class="controls">
|
||||
<label class="radio">
|
||||
<input type="radio" name="notifySuppressedCommandsGroup" value="info" data-bind="checked: settings.serial.notifySuppressedCommands" id="settings-serialNotifySuppressedCommands"> {{ _('Show notifications of severity "info" and "warning"') }}
|
||||
</label>
|
||||
<label class="radio">
|
||||
<input type="radio" name="notifySuppressedCommandsGroup" value="warn" data-bind="checked: settings.serial.notifySuppressedCommands" id="settings-serialNotifySuppressedCommands"> {{ _('Show notifications of severity "warning"') }}
|
||||
</label>
|
||||
<label class="radio">
|
||||
<input type="radio" name="notifySuppressedCommandsGroup" value="never" data-bind="checked: settings.serial.notifySuppressedCommands" id="settings-serialNotifySuppressedCommands"> {{ _('Never show notifications') }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+68
-19
@@ -2683,11 +2683,16 @@ class MachineCom(object):
|
||||
|
||||
if self._sanity_check_tools:
|
||||
# log to terminal and remember as invalid
|
||||
self._log(
|
||||
"T{} reported as invalid, reverting to T{}".format(
|
||||
invalid_tool, fallback_tool
|
||||
)
|
||||
message = "T{} reported as invalid, reverting to T{}".format(
|
||||
invalid_tool, fallback_tool
|
||||
)
|
||||
self._log("Warn: " + message)
|
||||
self._logger.warning(message)
|
||||
eventManager().fire(
|
||||
Events.INVALID_TOOL_REPORTED,
|
||||
{"tool": invalid_tool, "fallback": fallback_tool},
|
||||
)
|
||||
|
||||
self._knownInvalidTools.add(invalid_tool)
|
||||
|
||||
# we actually do send a T command here instead of just settings self._currentTool just in case
|
||||
@@ -4684,9 +4689,19 @@ class MachineCom(object):
|
||||
new_tool = int(toolMatch.group("value"))
|
||||
|
||||
if not self._validate_tool(new_tool):
|
||||
self._log(
|
||||
message = (
|
||||
"Not queuing T{}, that tool doesn't exist according to the printer profile or "
|
||||
"was reported as invalid by the firmware".format(new_tool)
|
||||
"was reported as invalid by the firmware. Make sure your "
|
||||
"printer profile is set up correctly.".format(new_tool)
|
||||
)
|
||||
self._log("Warn: " + message)
|
||||
eventManager().fire(
|
||||
Events.COMMAND_SUPPRESSED,
|
||||
{
|
||||
"command": cmd,
|
||||
"message": message,
|
||||
"severity": "warn",
|
||||
},
|
||||
)
|
||||
return (None,)
|
||||
|
||||
@@ -4718,9 +4733,21 @@ class MachineCom(object):
|
||||
if toolMatch:
|
||||
new_tool = int(toolMatch.group("value"))
|
||||
if not self._validate_tool(new_tool):
|
||||
self._log(
|
||||
"Not sending T{}, that tool doesn't exist according to the printer profile or "
|
||||
"was reported as invalid by the firmware".format(new_tool)
|
||||
message = (
|
||||
"Not sending T{}, that tool doesn't exist according to "
|
||||
"the printer profile or was reported as invalid by the "
|
||||
"firmware. Make sure your printer profile is set up "
|
||||
"correctly.".format(new_tool)
|
||||
)
|
||||
self._log("Warn: " + message)
|
||||
self._logger.warning(message)
|
||||
eventManager().fire(
|
||||
Events.COMMAND_SUPPRESSED,
|
||||
{
|
||||
"command": cmd,
|
||||
"message": message,
|
||||
"severity": "warn",
|
||||
},
|
||||
)
|
||||
return (None,)
|
||||
|
||||
@@ -4798,8 +4825,16 @@ class MachineCom(object):
|
||||
self, cmd, cmd_type=None, gcode=None, subcode=None, *args, **kwargs
|
||||
):
|
||||
if not self._printerProfileManager.get_current_or_default()["heatedBed"]:
|
||||
self._log(
|
||||
'Warn: Not sending "{}", printer profile has no heated bed'.format(cmd)
|
||||
message = (
|
||||
'Not sending "{}", printer profile has no heated bed. Either '
|
||||
"configure a heated bed or remove bed commands from your "
|
||||
"GCODE.".format(cmd)
|
||||
)
|
||||
self._log("Warn: " + message)
|
||||
self._logger.warning(message)
|
||||
eventManager().fire(
|
||||
Events.COMMAND_SUPPRESSED,
|
||||
{"command": cmd, "message": message, "severity": "warn"},
|
||||
)
|
||||
return (None,) # Don't send bed commands if we don't have a heated bed
|
||||
|
||||
@@ -4809,10 +4844,16 @@ class MachineCom(object):
|
||||
self, cmd, cmd_type=None, gcode=None, subcode=None, *args, **kwargs
|
||||
):
|
||||
if not self._printerProfileManager.get_current_or_default()["heatedChamber"]:
|
||||
self._log(
|
||||
'Warn: Not sending "{}", printer profile has no heated chamber'.format(
|
||||
cmd
|
||||
)
|
||||
message = (
|
||||
'Not sending "{}", printer profile has no heated chamber. Either '
|
||||
"configure a heated chamber or remove chamber commands from your "
|
||||
"GCODE.".format(cmd)
|
||||
)
|
||||
self._log("Warn: " + message)
|
||||
self._logger.warning(message)
|
||||
eventManager().fire(
|
||||
Events.COMMAND_SUPPRESSED,
|
||||
{"command": cmd, "message": message, "severity": "warn"},
|
||||
)
|
||||
return (
|
||||
None,
|
||||
@@ -5136,10 +5177,18 @@ class MachineCom(object):
|
||||
self.setPause(True)
|
||||
|
||||
if gcode in self._blocked_commands:
|
||||
self._logger.info(
|
||||
"Not sending {} to printer, it's configured as a blocked command".format(
|
||||
gcode
|
||||
)
|
||||
message = "Not sending {} to printer, it's configured as a blocked command".format(
|
||||
gcode
|
||||
)
|
||||
self._log("Info: " + message)
|
||||
self._logger.info(message)
|
||||
eventManager().fire(
|
||||
Events.COMMAND_SUPPRESSED,
|
||||
{
|
||||
"command": cmd,
|
||||
"message": message,
|
||||
"severity": "warn",
|
||||
},
|
||||
)
|
||||
return (None,)
|
||||
|
||||
|
||||
Reference in new issue
Block a user