14 Commits

Author SHA1 Message Date
a236450cb5 add a bit scary warning
add a big scary warning to the settings page about software e-stops
2018-03-10 03:21:18 +10:00
9d9ff8824f added a little note about waiting in the settings
add a little note to the settings page about it waiting 3 seconds before reconnecting
2018-03-10 02:56:22 +10:00
beff41780b fix bizarre set of circumstances that could lead to malfunction of reconnect
If the setting to reconnect is unticked, and a user hits the e-stop button, and then ticks the box to reconnect, and then manually disconnects, the printer would automatically reconnect. This fixes that.

Also  added an "unknown status" to the button, since the status should always be known, if it's not then it's not, you know? Yeah, me either.
2018-03-10 02:41:37 +10:00
3666aa5e8d different handling of offline event detect
setting to null was giving javascript console errors. Changed it to just not do anything if the emergency button wasn't pressed.
2018-03-10 02:25:51 +10:00
15889e0dc7 unregister event disconnect
https://github.com/ntoff/OctoPrint-Estop/issues/4#issuecomment-371146397
2018-03-08 10:45:58 +10:00
62a6dac6e9 add connection cycle option
adds the option to disconnect / reconnect after sending M112.
May help break out of blocking commands by resetting some control boards
2018-03-01 12:04:10 +10:00
f8688d6415 Update README.md
remove colour from appearance code (it's not necessary for the plugin, it was just there as an example and may cause confusion)

update install instructions to include using the bundled plugin manager since the plugin is now registered
2017-12-05 10:23:28 +10:00
d59d041b0b Update readme appearance code
a couple of lines were using tabs instead of spaces
2017-12-05 09:36:13 +10:00
175f13bbde increment version 2017-12-02 07:44:42 +10:00
8a9a2fe401 icon tweak
not sure how I managed to screw that icon up so badly
2017-12-02 07:43:36 +10:00
8a2e732663 repo info thing 2017-12-02 07:42:58 +10:00
e8f9badc65 increment version 2017-11-10 00:22:58 +10:00
4f37707acb Update icon + add command setting
Update icon to new FA icon to be compatible with octoprint 1.3.5's move to an update font awesome

Add a setting to allow changing of the command in situations where the user may wish to issue some other command other than M112
2017-11-10 00:22:35 +10:00
33b2352afb Update README.md
remove the plugin manager bit from the install instructions as plugin isn't registered.
2017-08-12 12:50:19 +10:00
8 changed files with 130 additions and 30 deletions

View File

@ -10,8 +10,7 @@ That's the point of an EMERGENCY stop!
## Setup
Install via the bundled [Plugin Manager](https://github.com/foosel/OctoPrint/wiki/Plugin:-Plugin-Manager)
or manually using this URL:
Install via the bundled plugin manager, or manually using this URL:
https://github.com/ntoff/OctoPrint-Estop/archive/master.zip
@ -21,12 +20,11 @@ Once installed, you may wish to move the button to the top of the sidebar, you c
Find the "appearance" section, and add the plugin to the top of the sidebar order. If no other components have been previously rearranged, you may end up with only the plugin in the order list, this is fine, you don't need to add every item to the list (not adding them won't stop them from showing up).
appearance:
color: violet
components:
order:
sidebar:
- plugin_estop
appearance:
components:
order:
sidebar:
- plugin_estop
Please note: White spaces are critical inside the config.yaml file, special care must be taken when adding or removing entries that the correct layout is maintained. For more information on config.yaml and its appearance section, see here: http://docs.octoprint.org/en/master/configuration/config_yaml.html#appearance

View File

@ -3,11 +3,11 @@ layout: plugin
id: estop
title: Emergency STOP! button
description: Adds an emergency stop (gcode M112) button to the sidebar.
description: Adds an emergency stop button to the sidebar.
author: ntoff
license: AGPLv3
date: 2017-03-23
date: 2017-12-02
homepage: https://github.com/ntoff/OctoPrint-Estop
source: https://github.com/ntoff/OctoPrint-Estop
@ -21,10 +21,10 @@ tags:
screenshots:
- /assets/img/plugins/estop/enabled.PNG
- url: /assets/img/plugins/estop/enabled.PNG
alt: enabled
caption: Enabled (logged in and operational)
- /assets/img/plugins/estop/disabled.PNG
- url: /assets/img/plugins/estop/disabled.PNG
alt: disabled
caption: Disabled (logged out or non operational)
@ -42,4 +42,6 @@ compatibility:
- macos
---
Adds a nice big emergency stop button that sends M112 to the printer in the case of an emergency.
Adds a nice big emergency stop button that (by default) sends M112 to the printer in the case of an emergency. If your printer uses a different E-Stop command, there's a settings page entry to allow changing the command sent.
Please do be aware that this button is no substitute for human interaction in the case of a real emergency. How your printer responds to M112 depends entirely on its firmware.

View File

@ -3,8 +3,20 @@ from __future__ import absolute_import
import octoprint.plugin
class EstopPlugin(octoprint.plugin.AssetPlugin,
octoprint.plugin.TemplatePlugin):
class EstopPlugin(octoprint.plugin.StartupPlugin,
octoprint.plugin.AssetPlugin,
octoprint.plugin.TemplatePlugin,
octoprint.plugin.SettingsPlugin):
def get_settings_defaults(self):
return dict(
estopCommand = "M112",
estopReconnect = False)
def on_after_startup(self):
self.estopCommand = self._settings.get(["estopCommand"])
if (self.estopCommand != "M112"):
self._logger.warn("WARNING! EMERGENCY STOP COMMAND HAS BEEN CHANGED FROM DEFAULT \"M112\" TO \"" + self.estopCommand + "\"")
def get_assets(self):
return dict(
@ -13,8 +25,17 @@ class EstopPlugin(octoprint.plugin.AssetPlugin,
)
def get_template_configs(self):
return [
dict(type="sidebar", name="Emergency STOP!", icon="fa icon-print", template="estop_sidebar.jinja2", styles=["display: none"], data_bind="visible: loginState.isUser")
dict(type="sidebar", name="Emergency STOP!", icon="close", template="estop_sidebar.jinja2", styles=["display: none"], data_bind="visible: loginState.isUser"),
dict(type="settings", name="E-Stop Settings", template="estop_settings.jinja2", custom_bindings=False)
]
def on_settings_save(self, data):
s = self._settings
if "estopCommand" in data.keys():
s.set(["estopCommand"], data["estopCommand"])
if "estopReconnect" in data.keys():
s.setBoolean(["estopReconnect"], data["estopReconnect"])
s.save()
def get_update_information(self):
return dict(

View File

@ -76,4 +76,11 @@
}
#sidebar_plugin_estop {
display: block !important;
}
.estop-warning-icon {
color: #eb0000;
font-size: 2em !important;
}
.estop-warning {
font-style: italic;
}

View File

@ -5,39 +5,89 @@
$(function() {
function EstopViewModel(parameters) {
var self = this;
self.loginState = parameters[0];
self.printerState = parameters[1];
self.settings = parameters[2];
self.enableEstop = ko.pureComputed(function() {
self.estopCommand = ko.observable("M112");
self.estopReconnect = ko.observable(false);
self.emergencyCalled = ko.observable(false);
self.enableEstop = ko.pureComputed(function() {
return self.printerState.isOperational() && self.loginState.isUser();
});
self.estopState = ko.pureComputed(function() {
return self.loginState.isUser() > 0 ? "estop_sidebar" : "estop_sidebar_disabled";
});
self.reconnect = ko.pureComputed(function() {
return self.estopReconnect() && self.emergencyCalled();
})
self.buttonText = ko.pureComputed(function() {
if (self.enableEstop()) {
return gettext("EMERGENCY STOP");
} else {
}
else if (self.reconnect()) {
return gettext("Reconnecting...")
}
else if (!self.enableEstop()) {
return gettext("Offline");
}
else {
return gettext("Unknown Status");
}
});
self.sendEstopCommand = function () {
if (self.enableEstop()) {
OctoPrint.control.sendGcode("M112");
};
};
self.buttonTitle = ko.pureComputed(function() {
self.estopCommand(self.settings.settings.plugins.estop.estopCommand());
return gettext("Sends " + self.estopCommand() + " to the printer IMMEDIATELY");
});
self.onBeforeBinding = function () {
self.updateSettingsValues();
}
self.onSettingsHidden = function () {
self.updateSettingsValues();
}
self.updateSettingsValues = function () { //lazy way of making sure we have the latest version of the settings
self.estopCommand(self.settings.settings.plugins.estop.estopCommand());
self.estopReconnect(self.settings.settings.plugins.estop.estopReconnect());
}
self.onEventDisconnected = function () {
if (self.estopReconnect() && self.emergencyCalled()) {
self.timedReconnect = setTimeout(function() { //reconnect 3 seconds after detecting the printer is offline
self.emergencyCalled(false);
OctoPrint.connection.connect();
}, 3*1000); //3 seconds
}
}
self.sendEstopCommand = function () {
if (self.enableEstop()) {
self.estopCommand(self.settings.settings.plugins.estop.estopCommand());
OctoPrint.control.sendGcode(self.estopCommand());
if (self.estopReconnect()) {
self.emergencyCalled(true);
OctoPrint.connection.disconnect(); //normally octoprint would probably disconnect anyway, just calling this here in case the printer is in a blocking loop
}
}
}
}
OCTOPRINT_VIEWMODELS.push({
OCTOPRINT_VIEWMODELS.push({
construct: EstopViewModel,
dependencies: [
"loginStateViewModel",
"printerStateViewModel",
],
"loginStateViewModel",
"printerStateViewModel",
"settingsViewModel"],
elements: ["#sidebar_plugin_estop_wrapper"]
});
});

View File

@ -0,0 +1,22 @@
<h3>{{ _('E-Stop Settings') }}</h3>
<div>
<p>Here you can change the command issued to your printer when you press the emergency stop button.</p>
<form class="form-horizontal">
<div class="control-group">
<label class="control-label">{{ _('Emergency STOP! Command') }}</label>
<div class="controls">
<input type="text" class="input-block" data-bind="value: settings.plugins.estop.estopCommand">
<span class="help-block">Usually this is M112. Only change if you know what you're doing.</span>
</div>
</div>
<div class="control-group">
<label class="control-label">{{ _('Cycle the connection?') }}</label>
<div class="controls">
<input type="checkbox" class="input-block" data-bind="checked: settings.plugins.estop.estopReconnect">
<span class="help-block">Enabling this will attempt to automatically cycle the connection to the printer. This may cause the printer's control board to be reset and may help break out of blocking commands. Waits 3 seconds after the printer is "offline" before reconnecting.</span>
</div>
</div>
</form>
<span class="fa fa-exclamation-triangle estop-warning-icon"> </span>
<span class="estop-warning">A software emergency stop button is no substitute for a proper emergency stop button that physically cuts the power to the printer. How the printer responds to emergency stop commands, and connection cycling, will depend entirely on the printer's controller board and firmware. Never leave a printer unattended for extended periods of time.</span>
</div>

View File

@ -1,4 +1,4 @@
<div id="sidebar_estop_background" class="estop_sidebar" data-bind="css: estopState">
<button type="button" id="emergemcy_stop" title="send M112 estop gcode command" class="btn-estop" data-bind="text: buttonText, enable: enableEstop, click: function() { sendEstopCommand() }"></button>
<button type="button" id="emergemcy_stop" class="btn-estop" data-bind="attr: { title: buttonTitle }, text: buttonText, enable: enableEstop, click: function() { sendEstopCommand() }"></button>
</div>

View File

@ -14,7 +14,7 @@ plugin_package = "octoprint_estop"
plugin_name = "OctoPrint-Estop"
# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
plugin_version = "0.1.0"
plugin_version = "0.1.2"
# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
# module