toolhead: Rename _full_flush() to flush_step_generation() and use globally
Update code that modifies the low-level kinematics handlers to first call toolhead.flush_step_generation(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
7c80e8d533
commit
2843c85019
|
@ -144,6 +144,8 @@ class BLTouchEndstopWrapper:
|
||||||
self.send_cmd(None)
|
self.send_cmd(None)
|
||||||
self.sync_print_time()
|
self.sync_print_time()
|
||||||
self.mcu_endstop.home_prepare()
|
self.mcu_endstop.home_prepare()
|
||||||
|
toolhead = self.printer.lookup_object('toolhead')
|
||||||
|
toolhead.flush_step_generation()
|
||||||
self.start_mcu_pos = [(s, s.get_mcu_position())
|
self.start_mcu_pos = [(s, s.get_mcu_position())
|
||||||
for s in self.mcu_endstop.get_steppers()]
|
for s in self.mcu_endstop.get_steppers()]
|
||||||
def home_finalize(self):
|
def home_finalize(self):
|
||||||
|
|
|
@ -71,10 +71,11 @@ class ForceMove:
|
||||||
toolhead.dwell(STALL_TIME)
|
toolhead.dwell(STALL_TIME)
|
||||||
def manual_move(self, stepper, dist, speed, accel=0.):
|
def manual_move(self, stepper, dist, speed, accel=0.):
|
||||||
toolhead = self.printer.lookup_object('toolhead')
|
toolhead = self.printer.lookup_object('toolhead')
|
||||||
print_time = toolhead.get_last_move_time()
|
toolhead.flush_step_generation()
|
||||||
prev_sk = stepper.set_stepper_kinematics(self.stepper_kinematics)
|
prev_sk = stepper.set_stepper_kinematics(self.stepper_kinematics)
|
||||||
stepper.set_position((0., 0., 0.))
|
stepper.set_position((0., 0., 0.))
|
||||||
axis_r, accel_t, cruise_t, cruise_v = calc_move_time(dist, speed, accel)
|
axis_r, accel_t, cruise_t, cruise_v = calc_move_time(dist, speed, accel)
|
||||||
|
print_time = toolhead.get_last_move_time()
|
||||||
self.trapq_append(self.trapq, print_time, accel_t, cruise_t, accel_t,
|
self.trapq_append(self.trapq, print_time, accel_t, cruise_t, accel_t,
|
||||||
0., 0., 0., axis_r, 0., 0., 0., cruise_v, accel)
|
0., 0., 0., axis_r, 0., 0., 0., cruise_v, accel)
|
||||||
print_time += accel_t + cruise_t + accel_t
|
print_time += accel_t + cruise_t + accel_t
|
||||||
|
|
|
@ -82,7 +82,7 @@ class ManualProbeHelper:
|
||||||
toolhead_pos = self.toolhead.get_position()
|
toolhead_pos = self.toolhead.get_position()
|
||||||
if toolhead_pos == self.last_toolhead_pos:
|
if toolhead_pos == self.last_toolhead_pos:
|
||||||
return self.last_kinematics_pos
|
return self.last_kinematics_pos
|
||||||
self.toolhead.get_last_move_time()
|
self.toolhead.flush_step_generation()
|
||||||
kin = self.toolhead.get_kinematics()
|
kin = self.toolhead.get_kinematics()
|
||||||
for s in kin.get_steppers():
|
for s in kin.get_steppers():
|
||||||
s.set_tag_position(s.get_commanded_position())
|
s.set_tag_position(s.get_commanded_position())
|
||||||
|
|
|
@ -35,6 +35,7 @@ class ZAdjustHelper:
|
||||||
msg = "Making the following Z adjustments:\n%s" % ("\n".join(stepstrs),)
|
msg = "Making the following Z adjustments:\n%s" % ("\n".join(stepstrs),)
|
||||||
gcode.respond_info(msg)
|
gcode.respond_info(msg)
|
||||||
# Disable Z stepper movements
|
# Disable Z stepper movements
|
||||||
|
toolhead.flush_step_generation()
|
||||||
for s in self.z_steppers:
|
for s in self.z_steppers:
|
||||||
s.set_trapq(None)
|
s.set_trapq(None)
|
||||||
# Move each z stepper (sorted from lowest to highest) until they match
|
# Move each z stepper (sorted from lowest to highest) until they match
|
||||||
|
@ -45,6 +46,7 @@ class ZAdjustHelper:
|
||||||
for i in range(len(positions)-1):
|
for i in range(len(positions)-1):
|
||||||
stepper_offset, stepper = positions[i]
|
stepper_offset, stepper = positions[i]
|
||||||
next_stepper_offset, next_stepper = positions[i+1]
|
next_stepper_offset, next_stepper = positions[i+1]
|
||||||
|
toolhead.flush_step_generation()
|
||||||
stepper.set_trapq(toolhead.get_trapq())
|
stepper.set_trapq(toolhead.get_trapq())
|
||||||
curpos[2] = z_low + next_stepper_offset
|
curpos[2] = z_low + next_stepper_offset
|
||||||
try:
|
try:
|
||||||
|
@ -52,11 +54,13 @@ class ZAdjustHelper:
|
||||||
toolhead.set_position(curpos)
|
toolhead.set_position(curpos)
|
||||||
except:
|
except:
|
||||||
logging.exception("ZAdjustHelper adjust_steppers")
|
logging.exception("ZAdjustHelper adjust_steppers")
|
||||||
|
toolhead.flush_step_generation()
|
||||||
for s in self.z_steppers:
|
for s in self.z_steppers:
|
||||||
s.set_trapq(toolhead.get_trapq())
|
s.set_trapq(toolhead.get_trapq())
|
||||||
raise
|
raise
|
||||||
# Z should now be level - do final cleanup
|
# Z should now be level - do final cleanup
|
||||||
last_stepper_offset, last_stepper = positions[-1]
|
last_stepper_offset, last_stepper = positions[-1]
|
||||||
|
toolhead.flush_step_generation()
|
||||||
last_stepper.set_trapq(toolhead.get_trapq())
|
last_stepper.set_trapq(toolhead.get_trapq())
|
||||||
curpos[2] += first_stepper_offset
|
curpos[2] += first_stepper_offset
|
||||||
toolhead.set_position(curpos)
|
toolhead.set_position(curpos)
|
||||||
|
|
|
@ -41,13 +41,14 @@ class Homing:
|
||||||
for mcu_endstop, name in endstops:
|
for mcu_endstop, name in endstops:
|
||||||
mcu_endstop.home_prepare()
|
mcu_endstop.home_prepare()
|
||||||
# Note start location
|
# Note start location
|
||||||
print_time = self.toolhead.get_last_move_time()
|
self.toolhead.flush_step_generation()
|
||||||
kin = self.toolhead.get_kinematics()
|
kin = self.toolhead.get_kinematics()
|
||||||
for s in kin.get_steppers():
|
for s in kin.get_steppers():
|
||||||
s.set_tag_position(s.get_commanded_position())
|
s.set_tag_position(s.get_commanded_position())
|
||||||
start_mcu_pos = [(s, name, s.get_mcu_position())
|
start_mcu_pos = [(s, name, s.get_mcu_position())
|
||||||
for es, name in endstops for s in es.get_steppers()]
|
for es, name in endstops for s in es.get_steppers()]
|
||||||
# Start endstop checking
|
# Start endstop checking
|
||||||
|
print_time = self.toolhead.get_last_move_time()
|
||||||
self.endstops_pending = len(endstops)
|
self.endstops_pending = len(endstops)
|
||||||
for mcu_endstop, name in endstops:
|
for mcu_endstop, name in endstops:
|
||||||
min_step_dist = min([s.get_step_dist()
|
min_step_dist = min([s.get_step_dist()
|
||||||
|
@ -71,6 +72,7 @@ class Homing:
|
||||||
if error is None:
|
if error is None:
|
||||||
error = "Failed to home %s: %s" % (name, str(e))
|
error = "Failed to home %s: %s" % (name, str(e))
|
||||||
# Determine stepper halt positions
|
# Determine stepper halt positions
|
||||||
|
self.toolhead.flush_step_generation()
|
||||||
end_mcu_pos = [(s, name, spos, s.get_mcu_position())
|
end_mcu_pos = [(s, name, spos, s.get_mcu_position())
|
||||||
for s, name, spos in start_mcu_pos]
|
for s, name, spos in start_mcu_pos]
|
||||||
if probe_pos:
|
if probe_pos:
|
||||||
|
@ -123,6 +125,7 @@ class Homing:
|
||||||
self.homing_move(movepos, endstops, hi.second_homing_speed,
|
self.homing_move(movepos, endstops, hi.second_homing_speed,
|
||||||
verify_movement=self.verify_retract)
|
verify_movement=self.verify_retract)
|
||||||
# Signal home operation complete
|
# Signal home operation complete
|
||||||
|
self.toolhead.flush_step_generation()
|
||||||
kin = self.toolhead.get_kinematics()
|
kin = self.toolhead.get_kinematics()
|
||||||
for s in kin.get_steppers():
|
for s in kin.get_steppers():
|
||||||
s.set_tag_position(s.get_commanded_position())
|
s.set_tag_position(s.get_commanded_position())
|
||||||
|
|
|
@ -123,7 +123,7 @@ class CartKinematics:
|
||||||
# Dual carriage support
|
# Dual carriage support
|
||||||
def _activate_carriage(self, carriage):
|
def _activate_carriage(self, carriage):
|
||||||
toolhead = self.printer.lookup_object('toolhead')
|
toolhead = self.printer.lookup_object('toolhead')
|
||||||
toolhead.get_last_move_time()
|
toolhead.flush_step_generation()
|
||||||
dc_rail = self.dual_carriage_rails[carriage]
|
dc_rail = self.dual_carriage_rails[carriage]
|
||||||
dc_axis = self.dual_carriage_axis
|
dc_axis = self.dual_carriage_axis
|
||||||
self.rails[dc_axis].set_trapq(None)
|
self.rails[dc_axis].set_trapq(None)
|
||||||
|
|
|
@ -320,7 +320,7 @@ class ToolHead:
|
||||||
self._update_drip_move_time(next_move_time)
|
self._update_drip_move_time(next_move_time)
|
||||||
else:
|
else:
|
||||||
self._update_move_time(next_move_time)
|
self._update_move_time(next_move_time)
|
||||||
def _full_flush(self):
|
def flush_step_generation(self):
|
||||||
# Transition from "Flushed"/"Priming"/main state to "Flushed" state
|
# Transition from "Flushed"/"Priming"/main state to "Flushed" state
|
||||||
self.move_queue.flush()
|
self.move_queue.flush()
|
||||||
self.special_queuing_state = "Flushed"
|
self.special_queuing_state = "Flushed"
|
||||||
|
@ -331,7 +331,7 @@ class ToolHead:
|
||||||
self._update_move_time(self.print_time, lazy=False)
|
self._update_move_time(self.print_time, lazy=False)
|
||||||
def _flush_lookahead(self):
|
def _flush_lookahead(self):
|
||||||
if self.special_queuing_state:
|
if self.special_queuing_state:
|
||||||
return self._full_flush()
|
return self.flush_step_generation()
|
||||||
self.move_queue.flush()
|
self.move_queue.flush()
|
||||||
def get_last_move_time(self):
|
def get_last_move_time(self):
|
||||||
self._flush_lookahead()
|
self._flush_lookahead()
|
||||||
|
@ -374,7 +374,7 @@ class ToolHead:
|
||||||
# Running normally - reschedule check
|
# Running normally - reschedule check
|
||||||
return eventtime + buffer_time - self.buffer_time_low
|
return eventtime + buffer_time - self.buffer_time_low
|
||||||
# Under ran low buffer mark - flush lookahead queue
|
# Under ran low buffer mark - flush lookahead queue
|
||||||
self._full_flush()
|
self.flush_step_generation()
|
||||||
if print_time != self.print_time:
|
if print_time != self.print_time:
|
||||||
self.idle_flush_print_time = self.print_time
|
self.idle_flush_print_time = self.print_time
|
||||||
except:
|
except:
|
||||||
|
@ -385,7 +385,8 @@ class ToolHead:
|
||||||
def get_position(self):
|
def get_position(self):
|
||||||
return list(self.commanded_pos)
|
return list(self.commanded_pos)
|
||||||
def set_position(self, newpos, homing_axes=()):
|
def set_position(self, newpos, homing_axes=()):
|
||||||
self._flush_lookahead()
|
self.flush_step_generation()
|
||||||
|
self.trapq_free_moves(self.trapq, self.reactor.NEVER)
|
||||||
self.commanded_pos[:] = newpos
|
self.commanded_pos[:] = newpos
|
||||||
self.kin.set_position(newpos, homing_axes)
|
self.kin.set_position(newpos, homing_axes)
|
||||||
def move(self, newpos, speed):
|
def move(self, newpos, speed):
|
||||||
|
@ -445,7 +446,7 @@ class ToolHead:
|
||||||
try:
|
try:
|
||||||
self.move(newpos, speed)
|
self.move(newpos, speed)
|
||||||
except homing.CommandError as e:
|
except homing.CommandError as e:
|
||||||
self._full_flush()
|
self.flush_step_generation()
|
||||||
raise
|
raise
|
||||||
# Transmit move in "drip" mode
|
# Transmit move in "drip" mode
|
||||||
try:
|
try:
|
||||||
|
@ -454,7 +455,7 @@ class ToolHead:
|
||||||
self.move_queue.reset()
|
self.move_queue.reset()
|
||||||
self.trapq_free_moves(self.trapq, self.reactor.NEVER)
|
self.trapq_free_moves(self.trapq, self.reactor.NEVER)
|
||||||
# Exit "Drip" state
|
# Exit "Drip" state
|
||||||
self._full_flush()
|
self.flush_step_generation()
|
||||||
def signal_drip_mode_end(self):
|
def signal_drip_mode_end(self):
|
||||||
self.drip_completion.complete(True)
|
self.drip_completion.complete(True)
|
||||||
# Misc commands
|
# Misc commands
|
||||||
|
|
Loading…
Reference in New Issue