2017-03-22 22:17:16 +01:00
|
|
|
# coding=utf-8
|
|
|
|
from __future__ import absolute_import
|
|
|
|
|
|
|
|
import octoprint.plugin
|
|
|
|
|
2020-05-13 16:39:49 +02:00
|
|
|
|
2017-11-09 15:22:35 +01:00
|
|
|
class EstopPlugin(octoprint.plugin.StartupPlugin,
|
2020-05-13 16:39:49 +02:00
|
|
|
octoprint.plugin.AssetPlugin,
|
|
|
|
octoprint.plugin.TemplatePlugin,
|
|
|
|
octoprint.plugin.SettingsPlugin):
|
2017-11-09 15:22:35 +01:00
|
|
|
|
|
|
|
def get_settings_defaults(self):
|
2020-05-13 16:39:49 +02:00
|
|
|
return dict(estopCommand="M112")
|
2017-11-09 15:22:35 +01:00
|
|
|
|
|
|
|
def on_after_startup(self):
|
|
|
|
self.estopCommand = self._settings.get(["estopCommand"])
|
|
|
|
if (self.estopCommand != "M112"):
|
2020-05-13 16:39:49 +02:00
|
|
|
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"]
|
|
|
|
)
|
2020-05-13 16:39:49 +02:00
|
|
|
|
2017-03-22 22:17:16 +01:00
|
|
|
def get_template_configs(self):
|
2017-03-24 07:18:17 +01:00
|
|
|
return [
|
2020-05-13 16:39:49 +02: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)
|
2020-05-13 16:39:49 +02:00
|
|
|
]
|
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
|
|
|
)
|
|
|
|
|
2020-05-13 16:39:49 +02:00
|
|
|
|
2017-03-22 22:17:16 +01:00
|
|
|
__plugin_name__ = "Emergency Stop Button"
|
2020-05-13 16:39:49 +02:00
|
|
|
__plugin_pythoncompat__ = ">=2.7,<4" # python 2 and 3
|
|
|
|
|
2017-03-22 22:17:16 +01:00
|
|
|
|
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
|
2020-05-13 16:39:49 +02:00
|
|
|
}
|