Initial comm protocol gcode hooks

This commit is contained in:
Dattas Moonchaser 2014-09-12 10:23:08 -06:00
parent 26e9a17c6b
commit 9e9da5355c

View file

@ -13,6 +13,7 @@ import threading
import Queue as queue
import logging
import serial
import octoprint.plugin
from collections import deque
@ -151,6 +152,10 @@ class MachineCom(object):
self._resendDelta = None
self._lastLines = deque([], 50)
# hooks
self._pluginManager = octoprint.plugin.plugin_manager()
self._gcode_hooks = self._pluginManager.get_hooks("octoprint.comm.protocol.gcode")
# SD status data
self._sdAvailable = False
self._sdFileList = False
@ -1089,6 +1094,10 @@ class MachineCom(object):
return
if not self.isStreaming():
for hook in self._gcode_hooks:
hook_cmd = self._gcode_hooks[hook](self, cmd)
if hook_cmd and isinstance(hook_cmd, basestring):
cmd = hook_cmd
gcode = self._regex_command.search(cmd)
if gcode:
gcode = gcode.group(1)