Compare commits
7 Commits
master
...
reconnect-
Author | SHA1 | Date | |
---|---|---|---|
|
c8ae6e7dde | ||
|
a236450cb5 | ||
|
9d9ff8824f | ||
|
beff41780b | ||
|
3666aa5e8d | ||
|
15889e0dc7 | ||
|
62a6dac6e9 |
@ -9,7 +9,9 @@ class EstopPlugin(octoprint.plugin.StartupPlugin,
|
|||||||
octoprint.plugin.SettingsPlugin):
|
octoprint.plugin.SettingsPlugin):
|
||||||
|
|
||||||
def get_settings_defaults(self):
|
def get_settings_defaults(self):
|
||||||
return dict(estopCommand = "M112")
|
return dict(
|
||||||
|
estopCommand = "M112",
|
||||||
|
estopReconnect = False)
|
||||||
|
|
||||||
def on_after_startup(self):
|
def on_after_startup(self):
|
||||||
self.estopCommand = self._settings.get(["estopCommand"])
|
self.estopCommand = self._settings.get(["estopCommand"])
|
||||||
@ -27,6 +29,14 @@ class EstopPlugin(octoprint.plugin.StartupPlugin,
|
|||||||
dict(type="settings", name="E-Stop Settings", template="estop_settings.jinja2", custom_bindings=False)
|
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):
|
def get_update_information(self):
|
||||||
return dict(
|
return dict(
|
||||||
estop=dict(
|
estop=dict(
|
||||||
@ -45,7 +55,6 @@ class EstopPlugin(octoprint.plugin.StartupPlugin,
|
|||||||
)
|
)
|
||||||
|
|
||||||
__plugin_name__ = "Emergency Stop Button"
|
__plugin_name__ = "Emergency Stop Button"
|
||||||
__plugin_pythoncompat__ = ">=2.7,<4"
|
|
||||||
|
|
||||||
def __plugin_load__():
|
def __plugin_load__():
|
||||||
global __plugin_implementation__
|
global __plugin_implementation__
|
||||||
|
@ -77,3 +77,10 @@
|
|||||||
#sidebar_plugin_estop {
|
#sidebar_plugin_estop {
|
||||||
display: block !important;
|
display: block !important;
|
||||||
}
|
}
|
||||||
|
.estop-warning-icon {
|
||||||
|
color: #eb0000;
|
||||||
|
font-size: 2em !important;
|
||||||
|
}
|
||||||
|
.estop-warning {
|
||||||
|
font-style: italic;
|
||||||
|
}
|
@ -11,6 +11,8 @@ $(function() {
|
|||||||
self.settings = parameters[2];
|
self.settings = parameters[2];
|
||||||
|
|
||||||
self.estopCommand = ko.observable("M112");
|
self.estopCommand = ko.observable("M112");
|
||||||
|
self.estopReconnect = ko.observable(false);
|
||||||
|
self.emergencyCalled = ko.observable(false);
|
||||||
|
|
||||||
self.enableEstop = ko.pureComputed(function() {
|
self.enableEstop = ko.pureComputed(function() {
|
||||||
return self.printerState.isOperational() && self.loginState.isUser();
|
return self.printerState.isOperational() && self.loginState.isUser();
|
||||||
@ -20,12 +22,24 @@ $(function() {
|
|||||||
return self.loginState.isUser() > 0 ? "estop_sidebar" : "estop_sidebar_disabled";
|
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() {
|
self.buttonText = ko.pureComputed(function() {
|
||||||
if (self.enableEstop()) {
|
if (self.enableEstop()) {
|
||||||
return gettext("EMERGENCY STOP");
|
return gettext("EMERGENCY STOP");
|
||||||
} else {
|
}
|
||||||
|
else if (self.reconnect()) {
|
||||||
|
return gettext("Reconnecting...")
|
||||||
|
}
|
||||||
|
else if (!self.enableEstop()) {
|
||||||
return gettext("Offline");
|
return gettext("Offline");
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
return gettext("Unknown Status");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
self.buttonTitle = ko.pureComputed(function() {
|
self.buttonTitle = ko.pureComputed(function() {
|
||||||
@ -34,14 +48,36 @@ $(function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
self.onBeforeBinding = function () {
|
self.onBeforeBinding = function () {
|
||||||
//self.estopCommand(self.settings.settings.plugins.estop.estopCommand());
|
self.updateSettingsValues();
|
||||||
}
|
}
|
||||||
|
self.onSettingsHidden = function () {
|
||||||
|
self.updateSettingsValues();
|
||||||
|
}
|
||||||
|
|
||||||
|
self.updateSettingsValues = function () {
|
||||||
|
self.estopCommand(self.settings.settings.plugins.estop.estopCommand());
|
||||||
|
self.estopReconnect(self.settings.settings.plugins.estop.estopReconnect());
|
||||||
|
}
|
||||||
|
|
||||||
self.sendEstopCommand = function () {
|
self.sendEstopCommand = function () {
|
||||||
if (self.enableEstop()) {
|
if (self.enableEstop()) {
|
||||||
self.estopCommand(self.settings.settings.plugins.estop.estopCommand());
|
self.estopCommand(self.settings.settings.plugins.estop.estopCommand());
|
||||||
OctoPrint.control.sendGcode(self.estopCommand());
|
OctoPrint.control.sendGcode(self.estopCommand());
|
||||||
};
|
|
||||||
};
|
if (self.estopReconnect()) {
|
||||||
|
self.emergencyCalled(true);
|
||||||
|
OctoPrint.connection.disconnect();
|
||||||
|
self.onEventDisconnected = function () {
|
||||||
|
self.timedReconnect = setTimeout(function() {
|
||||||
|
self.emergencyCalled(false);
|
||||||
|
delete self.onEventDisconnected;
|
||||||
|
OctoPrint.connection.connect();
|
||||||
|
|
||||||
|
}, 3*1000); //3 seconds
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OCTOPRINT_VIEWMODELS.push({
|
OCTOPRINT_VIEWMODELS.push({
|
||||||
|
@ -9,5 +9,14 @@
|
|||||||
<span class="help-block">Usually this is M112. Only change if you know what you're doing.</span>
|
<span class="help-block">Usually this is M112. Only change if you know what you're doing.</span>
|
||||||
</div>
|
</div>
|
||||||
</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>
|
</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>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user