2017-03-22 22:17:16 +01:00
|
|
|
# coding=utf-8
|
|
|
|
from __future__ import absolute_import
|
|
|
|
|
|
|
|
import octoprint.plugin
|
|
|
|
|
2017-11-09 15:22:35 +01:00
|
|
|
class EstopPlugin(octoprint.plugin.StartupPlugin,
|
|
|
|
octoprint.plugin.AssetPlugin,
|
|
|
|
octoprint.plugin.TemplatePlugin,
|
|
|
|
octoprint.plugin.SettingsPlugin):
|
|
|
|
|
|
|
|
def get_settings_defaults(self):
|
2018-03-01 03:04:10 +01:00
|
|
|
return dict(
|
|
|
|
estopCommand = "M112",
|
|
|
|
estopReconnect = False)
|
2017-11-09 15:22:35 +01:00
|
|
|
|
|
|
|
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 + "\"")
|
2017-03-22 22:17:16 +01:00
|
|
|
|
|
|
|
def get_assets(self):
|
|
|
|
return dict(
|
|
|
|
js=["js/estop.js"],
|
|
|
|
css=["css/estop.css"]
|
|
|
|
)
|
|
|
|
def get_template_configs(self):
|
2017-03-24 07:18:17 +01:00
|
|
|
return [
|
2017-12-01 22:43:36 +01:00
|
|
|
dict(type="sidebar", name="Emergency STOP!", icon="close", template="estop_sidebar.jinja2", styles=["display: none"], data_bind="visible: loginState.isUser"),
|
2017-11-09 15:22:35 +01:00
|
|
|
dict(type="settings", name="E-Stop Settings", template="estop_settings.jinja2", custom_bindings=False)
|
2017-03-24 07:18:17 +01:00
|
|
|
]
|
2018-03-01 03:04:10 +01:00
|
|
|
|
|
|
|
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()
|
2017-04-19 17:51:09 +02:00
|
|
|
|
|
|
|
def get_update_information(self):
|
2017-04-19 17:36:10 +02:00
|
|
|
return dict(
|
2017-04-19 17:51:09 +02:00
|
|
|
estop=dict(
|
2017-04-19 17:36:10 +02:00
|
|
|
displayName="Emergency Stop Button",
|
|
|
|
displayVersion=self._plugin_version,
|
|
|
|
|
|
|
|
# version check: github repository
|
|
|
|
type="github_release",
|
|
|
|
user="ntoff",
|
|
|
|
repo="OctoPrint-Estop",
|
|
|
|
current=self._plugin_version,
|
|
|
|
|
|
|
|
# update method: pip
|
|
|
|
pip="https://github.com/ntoff/OctoPrint-Estop/archive/{target_version}.zip"
|
|
|
|
)
|
2017-04-19 17:51:09 +02:00
|
|
|
)
|
|
|
|
|
2017-03-22 22:17:16 +01:00
|
|
|
__plugin_name__ = "Emergency Stop Button"
|
|
|
|
|
2017-04-19 17:36:10 +02:00
|
|
|
def __plugin_load__():
|
|
|
|
global __plugin_implementation__
|
|
|
|
__plugin_implementation__ = __plugin_implementation__ = EstopPlugin()
|
|
|
|
|
|
|
|
global __plugin_hooks__
|
|
|
|
__plugin_hooks__ = {
|
|
|
|
"octoprint.plugin.softwareupdate.check_config": __plugin_implementation__.get_update_information
|
|
|
|
}
|