summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Baumann <derflob@derflob.de>2016-07-16 08:38:12 +1200
committerFlorian Baumann <derflob@derflob.de>2016-07-16 08:38:12 +1200
commite67270e849173be4f29214d06017dfe4141a1a83 (patch)
tree53418ab0733ea1aa651eeb830fa091449e5814b1
parent7a663ae5ad8f4570af08664f01803265544d2d83 (diff)
downloadxmpp-e67270e849173be4f29214d06017dfe4141a1a83.tar.gz
xmpp-e67270e849173be4f29214d06017dfe4141a1a83.tar.bz2
cmd move <position>
-rw-r--r--__init__.py25
1 files changed, 24 insertions, 1 deletions
diff --git a/__init__.py b/__init__.py
index f8cf974..1de2af3 100644
--- a/__init__.py
+++ b/__init__.py
@@ -297,9 +297,32 @@ class OctoXMPP(EventHandlerPlugin, SettingsPlugin):
msg.reply(body=reply).send()
+ def _cmd_move(self, msg, *coords):
+ if (self._printer.is_operational()):
+ if (self._printer.is_printing() and not self._printer.is_paused()):
+ reply = "You can't move the Printer while it's printing! Pause it first."
+ else:
+ pattern = re.compile(r"[{}][+-]?\d+(\.\d+)?".format("".join(self._printer.valid_axes + ('f',)), re.I)
+ valid_coords = True
+ for coord in coords:
+ if (not (coord and pattern.match(coord))):
+ reply = "Did not move. '{}' doesn't seem like a valid position of an axis".format(coord)
+ valid_coords = False
+ break
+
+ if (valid_coords):
+ gcode = "G1 {}".format(" ".join(coords))
+ reply = "Moving printer... ({})".format(gcode)
+ self._printer.commands(gcode)
+
+ else:
+ reply = "Printer not operational!"
+
+ msg.reply(body=reply).send()
+
__plugin_name__ = "OctoXMPP"
-__plugin_version__ = "0.2.0"
+__plugin_version__ = "0.2.1"
__plugin_description__ = "Control OctoPrint via XMPP messages."
__plugin_implementation__ = OctoXMPP()