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.
This commit is contained in:
parent
15889e0dc7
commit
3666aa5e8d
@ -12,6 +12,7 @@ $(function() {
|
|||||||
|
|
||||||
self.estopCommand = ko.observable("M112");
|
self.estopCommand = ko.observable("M112");
|
||||||
self.estopReconnect = ko.observable(false);
|
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();
|
||||||
@ -21,10 +22,18 @@ $(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 {
|
||||||
return gettext("Offline");
|
return gettext("Offline");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -46,21 +55,27 @@ $(function() {
|
|||||||
self.estopReconnect(self.settings.settings.plugins.estop.estopReconnect());
|
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 () {
|
self.sendEstopCommand = function () {
|
||||||
if (self.enableEstop()) {
|
if (self.enableEstop()) {
|
||||||
|
self.emergencyCalled(true);
|
||||||
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()) { //cycle the connection (if enabled) to reset the control board
|
if (self.estopReconnect()) {
|
||||||
OctoPrint.connection.disconnect(); //send a disconnect, maybe useful for breaking out of blocking commands.
|
OctoPrint.connection.disconnect(); //normally octoprint would probably disconnect anyway, just calling this here in case the printer is in a blocking loop
|
||||||
|
}
|
||||||
self.onEventDisconnected = function () { //wait until octoprint has disconnected
|
|
||||||
self.onEventDisconnected = null; //unregister event handler
|
|
||||||
OctoPrint.connection.connect(); //reconnect
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OCTOPRINT_VIEWMODELS.push({
|
OCTOPRINT_VIEWMODELS.push({
|
||||||
|
Loading…
Reference in New Issue
Block a user