🎨 Refactored for better code reuse
This commit is contained in:
1 parent
44b4c6cc40
commit
bd58138acf
1 file changed
+17
-23
+17
-23
@@ -3556,7 +3556,7 @@ class MachineCom(object):
|
||||
self._resendDelta = None
|
||||
|
||||
def _gcode_M112_queuing(self, cmd, cmd_type=None, gcode=None, subcode=None, *args, **kwargs):
|
||||
self._logger.info("Force-sending M112 to the printer")
|
||||
self._logger.info(u"Force-sending M112 to the printer")
|
||||
|
||||
# emergency stop, jump the queue with the M112, regardless of whether the EMERGENCY_PARSER capability is
|
||||
# available or not
|
||||
@@ -3590,30 +3590,10 @@ class MachineCom(object):
|
||||
return None,
|
||||
|
||||
def _gcode_M108_queuing(self, cmd, gcode=None, *args, **kwargs):
|
||||
# only jump the queue with M108 if the EMERGENCY_PARSER capability is available
|
||||
if not self._capability_support.get(self.CAPABILITY_EMERGENCY_PARSER, False) or not self._firmware_capabilities.get(self.CAPABILITY_EMERGENCY_PARSER, False):
|
||||
return
|
||||
|
||||
self._logger.info("Force-sending M108 to the printer")
|
||||
self._do_send(cmd, gcode=gcode)
|
||||
|
||||
# use up an ok since we will get one back for this command and don't want to get out of sync
|
||||
self._clear_to_send.clear()
|
||||
|
||||
return None,
|
||||
self._emergency_force_send(cmd, u"Force-sending M108 to the printer", gcode=gcode, *args, **kwargs)
|
||||
|
||||
def _gcode_M410_queuing(self, cmd, gcode=None, *args, **kwargs):
|
||||
# only jump the queue with M410 if the EMERGENCY_PARSER capability is available
|
||||
if not self._capability_support.get(self.CAPABILITY_EMERGENCY_PARSER, False) or not self._firmware_capabilities.get(self.CAPABILITY_EMERGENCY_PARSER, False):
|
||||
return
|
||||
|
||||
self._logger.info("Force-sending M410 to the printer")
|
||||
self._do_send(cmd, gcode=gcode)
|
||||
|
||||
# use up an ok since we will get one back for this command and don't want to get out of sync
|
||||
self._clear_to_send.clear()
|
||||
|
||||
return None,
|
||||
self._emergency_force_send(cmd, u"Force-sending M410 to the printer", gcode=gcode, *args, **kwargs)
|
||||
|
||||
def _gcode_M114_queued(self, *args, **kwargs):
|
||||
self._reset_position_timers()
|
||||
@@ -3633,6 +3613,20 @@ class MachineCom(object):
|
||||
self._timeout = self._get_new_communication_timeout() + _timeout
|
||||
self._dwelling_until = time.time() + _timeout
|
||||
|
||||
def _emergency_force_send(self, cmd, message, gcode=None, *args, **kwargs):
|
||||
# only jump the queue with our command if the EMERGENCY_PARSER capability is available
|
||||
if not self._capability_support.get(self.CAPABILITY_EMERGENCY_PARSER, False) \
|
||||
or not self._firmware_capabilities.get(self.CAPABILITY_EMERGENCY_PARSER, False):
|
||||
return
|
||||
|
||||
self._logger.info(message)
|
||||
self._do_send(cmd, gcode=gcode)
|
||||
|
||||
# use up an ok since we will get one back for this command and don't want to get out of sync
|
||||
self._clear_to_send.clear()
|
||||
|
||||
return None,
|
||||
|
||||
def _validate_tool(self, tool):
|
||||
return tool < self._printerProfileManager.get_current_or_default()["extruder"]["count"] and not tool in self._knownInvalidTools
|
||||
|
||||
|
||||
Reference in new issue
Block a user