refactoring

This commit is contained in:
Martin Muehlhaeuser 2018-02-02 11:39:06 +00:00
parent 1f8f2677d5
commit 0195cbf2ba
1 changed files with 33 additions and 20 deletions

View File

@ -9,12 +9,15 @@ class KlipperPlugin(
octoprint.plugin.StartupPlugin, octoprint.plugin.StartupPlugin,
octoprint.plugin.TemplatePlugin, octoprint.plugin.TemplatePlugin,
octoprint.plugin.SettingsPlugin, octoprint.plugin.SettingsPlugin,
octoprint.plugin.AssetPlugin, octoprint.plugin.AssetPlugin):
octoprint.plugin.WizardPlugin):
#-- Startupt Plugin
def on_after_startup(self): def on_after_startup(self):
pass pass
#-- Settings Plugin
def get_settings_defaults(self): def get_settings_defaults(self):
return dict( return dict(
serialport="/tmp/printer", serialport="/tmp/printer",
@ -26,6 +29,8 @@ class KlipperPlugin(
probeSpeedZ=500, probeSpeedZ=500,
probePoints=[{'x':0, 'y':0}]) probePoints=[{'x':0, 'y':0}])
#-- Template Plugin
def get_template_configs(self): def get_template_configs(self):
return [ return [
# dict(type="navbar", custom_bindings=True), # dict(type="navbar", custom_bindings=True),
@ -35,9 +40,11 @@ class KlipperPlugin(
dict(type="tab", name="Klipper", template="klipper_tab_main.jinja2", suffix="_main", custom_bindings=True), dict(type="tab", name="Klipper", template="klipper_tab_main.jinja2", suffix="_main", custom_bindings=True),
dict(type="sidebar", dict(type="sidebar",
custom_bindings=True, custom_bindings=True,
replaces= "connection" if self._settings.get(["replace_connection_panel"]) else "") replaces= "connection" if self._settings.get_boolean(["replace_connection_panel"]) else "")
] ]
#-- Asset Plugin
def get_assets(self): def get_assets(self):
return dict( return dict(
js=["js/klipper.js", js=["js/klipper.js",
@ -48,6 +55,24 @@ class KlipperPlugin(
less=["css/klipper.less"] less=["css/klipper.less"]
) )
#-- GCODE Hook
def on_parse_gcode(self, comm, line, *args, **kwargs):
if "//" in line:
self.parsingReturn = True
self.message = self.message + line.strip('/')
else:
if self.parsingReturn:
self.parsingReturn = False
self.logInfo(self.message)
self.message = ""
if "!!" in line:
self.logError(line.strip('!'))
return line
#-- Helpers
parsingReturn = False parsingReturn = False
message = "" message = ""
@ -68,21 +93,9 @@ class KlipperPlugin(
message=error) message=error)
) )
def on_parse_gcode(self, comm, line, *args, **kwargs):
if "//" in line:
self.parsingReturn = True
self.message = self.message + line.strip('/')
else:
if self.parsingReturn:
self.parsingReturn = False
self.logInfo(self.message)
self.message = ""
if "!!" in line:
self.logError(line.strip('!'))
return line
def is_wizard_required(self):
return True;
__plugin_name__ = "Klipper" __plugin_name__ = "Klipper"