2017-07-23 18:20:27 +02:00
|
|
|
# coding=utf-8
|
2020-03-25 15:02:02 +01:00
|
|
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
2017-07-23 18:20:27 +02:00
|
|
|
|
|
|
|
import octoprint.plugin
|
|
|
|
|
2020-03-25 15:02:02 +01:00
|
|
|
|
2017-07-23 18:20:27 +02:00
|
|
|
class SimpleemergencystopPlugin(octoprint.plugin.StartupPlugin,
|
2020-03-25 15:02:02 +01:00
|
|
|
octoprint.plugin.TemplatePlugin,
|
|
|
|
octoprint.plugin.SettingsPlugin,
|
|
|
|
octoprint.plugin.AssetPlugin,
|
|
|
|
octoprint.plugin.SimpleApiPlugin):
|
2017-07-23 18:20:27 +02:00
|
|
|
def __init__(self):
|
|
|
|
self.emergencyGCODE = ""
|
|
|
|
|
|
|
|
def get_settings_defaults(self):
|
|
|
|
return dict(
|
2017-07-25 23:58:19 +02:00
|
|
|
emergencyGCODE="M112",
|
2020-03-25 20:44:23 +01:00
|
|
|
confirmationDialog=False,
|
2024-03-23 14:27:22 +01:00
|
|
|
big_button=False,
|
|
|
|
enableMargin=False,
|
|
|
|
marginValue=0,
|
2017-07-23 18:20:27 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
def on_settings_save(self, data):
|
2020-03-25 15:02:02 +01:00
|
|
|
octoprint.plugin.SettingsPlugin.on_settings_save(self, data)
|
2017-07-23 18:20:27 +02:00
|
|
|
self.emergencyGCODE = self._settings.get(["emergencyGCODE"])
|
|
|
|
|
|
|
|
def on_after_startup(self):
|
|
|
|
self.emergencyGCODE = self._settings.get(["emergencyGCODE"])
|
|
|
|
|
|
|
|
def get_template_configs(self):
|
|
|
|
return [
|
2020-03-25 15:02:02 +01:00
|
|
|
# dict(type="navbar", custom_bindings=False),
|
2017-07-23 18:20:27 +02:00
|
|
|
dict(type="settings", custom_bindings=False)
|
2020-03-25 15:02:02 +01:00
|
|
|
]
|
2017-07-23 18:20:27 +02:00
|
|
|
|
|
|
|
def get_api_commands(self):
|
|
|
|
return dict(
|
|
|
|
emergencyStop=[]
|
|
|
|
)
|
|
|
|
|
|
|
|
def on_api_command(self, command, data):
|
2020-03-25 15:02:02 +01:00
|
|
|
# check if there is a : in line
|
2017-10-15 23:28:28 +02:00
|
|
|
find_this = ":"
|
|
|
|
if find_this in str(self.emergencyGCODE):
|
|
|
|
|
2020-03-25 15:02:02 +01:00
|
|
|
# if : found then, split, then for each:
|
2017-10-15 23:28:28 +02:00
|
|
|
gcode_list = str(self.emergencyGCODE).split(':')
|
|
|
|
for gcode in gcode_list:
|
2020-03-25 15:02:02 +01:00
|
|
|
self._printer.commands(gcode)
|
2017-10-15 23:28:28 +02:00
|
|
|
else:
|
|
|
|
self._printer.commands(self.emergencyGCODE)
|
2017-07-23 18:20:27 +02:00
|
|
|
|
|
|
|
def get_assets(self):
|
|
|
|
|
|
|
|
return dict(
|
|
|
|
js=["js/simpleemergencystop.js"],
|
2020-03-25 20:43:41 +01:00
|
|
|
css=["css/simpleemergencystop.css", "css/fontawesome.all.min.css"]
|
2017-07-23 18:20:27 +02:00
|
|
|
)
|
|
|
|
|
2020-03-25 15:02:02 +01:00
|
|
|
# Softwareupdate hook
|
2017-07-23 18:20:27 +02:00
|
|
|
|
|
|
|
def get_update_information(self):
|
|
|
|
# Define the configuration for your plugin to use with the Software Update
|
|
|
|
# Plugin here. See https://github.com/foosel/OctoPrint/wiki/Plugin:-Software-Update
|
|
|
|
# for details.
|
|
|
|
return dict(
|
|
|
|
simpleemergencystop=dict(
|
|
|
|
displayName="Simple Emergency Stop",
|
|
|
|
displayVersion=self._plugin_version,
|
|
|
|
|
|
|
|
# version check: github repository
|
|
|
|
type="github_release",
|
|
|
|
user="BrokenFire",
|
|
|
|
repo="OctoPrint-SimpleEmergencyStop",
|
|
|
|
current=self._plugin_version,
|
|
|
|
|
|
|
|
# update method: pip
|
|
|
|
pip="https://github.com/BrokenFire/OctoPrint-SimpleEmergencyStop/archive/{target_version}.zip"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
# If you want your plugin to be registered within OctoPrint under a different name than what you defined in setup.py
|
|
|
|
# ("OctoPrint-PluginSkeleton"), you may define that here. Same goes for the other metadata derived from setup.py that
|
|
|
|
# can be overwritten via __plugin_xyz__ control properties. See the documentation for that.
|
|
|
|
__plugin_name__ = "Simple Emergency Stop"
|
2020-03-25 15:02:02 +01:00
|
|
|
__plugin_pythoncompat__ = ">=2.7,<4"
|
|
|
|
|
2017-07-23 18:20:27 +02:00
|
|
|
|
|
|
|
def __plugin_load__():
|
|
|
|
global __plugin_implementation__
|
|
|
|
__plugin_implementation__ = SimpleemergencystopPlugin()
|
|
|
|
|
|
|
|
global __plugin_hooks__
|
|
|
|
__plugin_hooks__ = {
|
|
|
|
"octoprint.plugin.softwareupdate.check_config": __plugin_implementation__.get_update_information
|
|
|
|
}
|