estop plugin

This commit is contained in:
ntoff
2017-03-23 07:17:16 +10:00
parent 9150268fd8
commit 1fb15a0ea0
10 changed files with 307 additions and 0 deletions

View File

@ -0,0 +1,23 @@
# coding=utf-8
from __future__ import absolute_import
import octoprint.plugin
class EstopPlugin(octoprint.plugin.AssetPlugin,
octoprint.plugin.TemplatePlugin):
def get_assets(self):
return dict(
js=["js/estop.js"],
css=["css/estop.css"]
)
def get_template_configs(self):
return [dict(type="sidebar", name="Emergency STOP!", icon="fa fa-times")]
__plugin_name__ = "Emergency Stop Button"
def __plugin_load__():
global __plugin_implementation__
__plugin_implementation__ = EstopPlugin()

View File

@ -0,0 +1,63 @@
.estop_sidebar {
width:100%;
height:28px;
background-image: repeating-linear-gradient(
-45deg,
#000,
#000 4px,
#ff0 4px,
#ff0 8px
);
text-align: center;
vertical-align: middle;
}
.btn-estop {
width: 80%;
height: 28px;
color: #ffffff;
text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.25);
background-color: #eb0000;
background-image: -moz-linear-gradient(top, #ff0000, #cc0000);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ff0000), to(#cc0000));
background-image: -webkit-linear-gradient(top, #ff0000, #cc0000);
background-image: -o-linear-gradient(top, #ff0000, #cc0000);
background-image: linear-gradient(to bottom, #ff0000, #cc0000);
background-repeat: repeat-x;
border-color: #cc0000 #cc0000 #800000;
border-width: 0;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffff0000', endColorstr='#ffcc0000', GradientType=0);
filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
display: inline-block;
padding: 0px;
margin-bottom: 0;
font-size: 14px;
font-weight: bold;
line-height: 20px;
color: #fff;
text-align: center;
vertical-align: middle;
}
.btn-estop:hover {
text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.8);
background-color: #eb0000;
background-image: -moz-linear-gradient(top, #dd0000, #cc0000);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#dd0000), to(#cc0000));
background-image: -webkit-linear-gradient(top, #dd0000, #cc0000);
background-image: -o-linear-gradient(top, #dd0000, #cc0000);
background-image: linear-gradient(to bottom, #dd0000, #cc0000);
background-repeat: repeat-x;
border-color: #cc0000 #cc0000 #800000;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffff0000', endColorstr='#ffcc0000', GradientType=0);
filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
text-decoration: none;
}
.btn-estop:active {
text-decoration: overline underline;
}
.btn-estop:disabled {
text-shadow: 0px 0px 0 rgba(0, 0, 0, 0.0);
color: #555;
opacity: 0.8;
cursor: not-allowed;
}

View File

@ -0,0 +1,25 @@
/*
* Author: ntoff
* License: AGPLv3
*/
$(function() {
function EstopViewModel(parameters) {
var self = this;
//see if we're logged in and the printer is operational (for en/disable of button)
self.loginState = parameters[0];
self.terminal = parameters[1];
self.sendEstopCommand = function () {
OctoPrint.control.sendGcode("M112"); //should this ever be a variable? M112 universal?
};
}
OCTOPRINT_VIEWMODELS.push({
construct: EstopViewModel,
dependencies: [
"loginStateViewModel",
"terminalViewModel",
],
elements: ["#sidebar_plugin_estop"]
});
});

View File

@ -0,0 +1,4 @@
<div class="estop_sidebar">
<button type="button" id="emergemcy_stop" title="send M112 estop gcode command" class="btn-estop" data-bind="enable: terminal.isOperational() && loginState.isAdmin(), click: function() { sendEstopCommand() }"><i class="fa fa-times" size="+2"></i>{{ _(' EMERGENCY STOP ') }}<i class="fa fa-times" size="+2"></i></button>
</div>