Basic action commands are working
This commit is contained in:
1 parent
afe224ae08
commit
31fbebdbb9
2 files changed
+44
-3
No files matched your search
@@ -193,14 +193,19 @@ class ReprapGcodeProtocol(Protocol, ThreeDPrinterProtocolMixin, MotorControlProt
|
||||
self._last_lines = LineHistory(maxlen = 50)
|
||||
self._last_communication_error = None
|
||||
|
||||
# TODO GCODE Hooks
|
||||
self._gcode_hooks = dict(queuing=dict(),
|
||||
queued=dict(),
|
||||
sending=dict(),
|
||||
sent=dict())
|
||||
|
||||
# TODO atcommand hooks
|
||||
self._atcommand_hooks = dict(queuing=dict(),
|
||||
sending=dict())
|
||||
|
||||
# TODO action hooks
|
||||
self._action_hooks = dict()
|
||||
|
||||
# temperature polling
|
||||
self._temperature_poller = None
|
||||
|
||||
@@ -742,6 +747,37 @@ class ReprapGcodeProtocol(Protocol, ThreeDPrinterProtocolMixin, MotorControlProt
|
||||
|
||||
self._set_busy_protocol_interval(interval=busy_interval)
|
||||
|
||||
def _on_comm_action_command(self, line, lower_line, action):
|
||||
if action == "cancel":
|
||||
self.process_protocol_log("Cancelling on request of the printer...")
|
||||
self.cancel_processing()
|
||||
elif action == "pause":
|
||||
self.process_protocol_log("Pausing on request of the printer...")
|
||||
self.pause_processing()
|
||||
elif action == "paused":
|
||||
self.process_protocol_log("Printer signalled that it paused, switching state...")
|
||||
# TODO disable local handling
|
||||
self.pause_processing()
|
||||
elif action == "resume":
|
||||
self.process_protocol_log("Resuming on request of the printer...")
|
||||
self.resume_processing()
|
||||
elif action == "resumed":
|
||||
self.process_protocol_log("Printer signalled that it resumed, switching state...")
|
||||
# TODO disable local handling
|
||||
self.resume_processing()
|
||||
elif action == "disconnect":
|
||||
self.process_protocol_log("Disconnecting on request of the printer...")
|
||||
# TODO inform printer about forced disconnect
|
||||
self.disconnect()
|
||||
else:
|
||||
for hook in self._action_hooks:
|
||||
try:
|
||||
self._action_hooks[hook](self, line, action)
|
||||
except:
|
||||
self._logger.exception("Error while calling hook {} with action command {}".format(self._action_hooks[hook],
|
||||
action))
|
||||
continue
|
||||
|
||||
def _on_message_temperature(self, max_tool_num, temperatures, heatup_detected):
|
||||
if heatup_detected:
|
||||
self._logger.debug("Externally triggered heatup detected")
|
||||
@@ -940,7 +976,7 @@ class ReprapGcodeProtocol(Protocol, ThreeDPrinterProtocolMixin, MotorControlProt
|
||||
|
||||
try:
|
||||
if isinstance(entry, tuple):
|
||||
if not len(entry) == 3:
|
||||
if not len(entry) == 2:
|
||||
# something with that entry is broken, ignore it and fetch
|
||||
# the next one
|
||||
continue
|
||||
|
||||
@@ -135,8 +135,8 @@ class GenericFlavor(object):
|
||||
return lower_line.startswith("resend") or lower_line.startswith("rs")
|
||||
|
||||
@classmethod
|
||||
def comm_debug(cls, line, lower_line, state, flags):
|
||||
return line.startswith("//")
|
||||
def comm_action_command(cls, line, lower_line, state, flags):
|
||||
return line.startswith("//") and line[2:].strip().startswith("action:")
|
||||
|
||||
@classmethod
|
||||
def comm_error(cls, line, lower_line, state, flags):
|
||||
@@ -232,6 +232,11 @@ class GenericFlavor(object):
|
||||
def parse_comm_timeout(cls, line, lower_line, state, flags):
|
||||
return dict(line=line, lower_line=lower_line)
|
||||
|
||||
@classmethod
|
||||
def parse_comm_action_command(cls, line, lower_line, state, flags):
|
||||
action = line[2:].strip()[len("action:"):].strip()
|
||||
return dict(line=line, lower_line=lower_line, action=action)
|
||||
|
||||
@classmethod
|
||||
def parse_error_communication(cls, line, lower_line, state, flags):
|
||||
if "line number" in lower_line or "expected line" in lower_line:
|
||||
|
||||
Reference in new issue
Block a user