homing: Add EndstopMoveError wrapper around EndstopError

Allow an EndstopError to be raised without a destination position.
Introduce EndstopMoveError wrapper so that current callers can
continue to pass in a move destination.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2016-11-18 12:42:39 -05:00
parent 2b5b899d35
commit 4f30dce64f
4 changed files with 15 additions and 11 deletions

View File

@ -84,8 +84,9 @@ class CartKinematics:
and (end_pos[i] < self.limits[i][0]
or end_pos[i] > self.limits[i][1])):
if self.limits[i][0] > self.limits[i][1]:
raise homing.EndstopError(end_pos, "Must home axis first")
raise homing.EndstopError(end_pos)
raise homing.EndstopMoveError(
end_pos, "Must home axis first")
raise homing.EndstopMoveError(end_pos)
def check_move(self, move):
limits = self.limits
xpos, ypos = move.end_pos[:2]

View File

@ -118,11 +118,11 @@ class DeltaKinematics:
xy2 = end_pos[0]**2 + end_pos[1]**2
if xy2 > self.limit_xy2 or end_pos[2] < 0.:
if self.limit_xy2 < 0.:
raise homing.EndstopError(end_pos, "Must home first")
raise homing.EndstopError(end_pos)
raise homing.EndstopMoveError(end_pos, "Must home first")
raise homing.EndstopMoveError(end_pos)
if end_pos[2] > self.limit_z:
if end_pos[2] > self.max_z or xy2 > (self.max_z - end_pos[2])**2:
raise homing.EndstopError(end_pos)
raise homing.EndstopMoveError(end_pos)
def move_z(self, move_time, move):
if not move.axes_d[2]:
return

View File

@ -23,7 +23,8 @@ class PrinterExtruder:
self.need_motor_enable = True
def check_move(self, move):
if not self.heater.can_extrude:
raise homing.EndstopError(move.end_pos, "Extrude below minimum temp")
raise homing.EndstopMoveError(
move.end_pos, "Extrude below minimum temp")
if (not move.do_calc_junction
and not move.axes_d[0] and not move.axes_d[1]
and not move.axes_d[2]):

View File

@ -104,9 +104,11 @@ class QueryEndstops:
return False
class EndstopError(Exception):
def __init__(self, pos, msg="Move out of range"):
self.pos = pos
self.msg = msg
def __init__(self, msg="Endstop error"):
self._msg = msg
def __str__(self):
return "%s: %.3f %.3f %.3f [%.3f]" % (
self.msg, self.pos[0], self.pos[1], self.pos[2], self.pos[3])
return self._msg
def EndstopMoveError(pos, msg="Move out of range"):
return EndstopError("%s: %.3f %.3f %.3f [%.3f]" % (
msg, pos[0], pos[1], pos[2], pos[3]))