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:
Kevin O'Connor 2019-11-13 23:34:21 -05:00
parent 7c80e8d533
commit 2843c85019
7 changed files with 21 additions and 10 deletions

View File

@ -144,6 +144,8 @@ class BLTouchEndstopWrapper:
self.send_cmd(None)
self.sync_print_time()
self.mcu_endstop.home_prepare()
toolhead = self.printer.lookup_object('toolhead')
toolhead.flush_step_generation()
self.start_mcu_pos = [(s, s.get_mcu_position())
for s in self.mcu_endstop.get_steppers()]
def home_finalize(self):

View File

@ -71,10 +71,11 @@ class ForceMove:
toolhead.dwell(STALL_TIME)
def manual_move(self, stepper, dist, speed, accel=0.):
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)
stepper.set_position((0., 0., 0.))
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,
0., 0., 0., axis_r, 0., 0., 0., cruise_v, accel)
print_time += accel_t + cruise_t + accel_t

View File

@ -82,7 +82,7 @@ class ManualProbeHelper:
toolhead_pos = self.toolhead.get_position()
if toolhead_pos == self.last_toolhead_pos:
return self.last_kinematics_pos
self.toolhead.get_last_move_time()
self.toolhead.flush_step_generation()
kin = self.toolhead.get_kinematics()
for s in kin.get_steppers():
s.set_tag_position(s.get_commanded_position())

View File

@ -35,6 +35,7 @@ class ZAdjustHelper:
msg = "Making the following Z adjustments:\n%s" % ("\n".join(stepstrs),)
gcode.respond_info(msg)
# Disable Z stepper movements
toolhead.flush_step_generation()
for s in self.z_steppers:
s.set_trapq(None)
# 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):
stepper_offset, stepper = positions[i]
next_stepper_offset, next_stepper = positions[i+1]
toolhead.flush_step_generation()
stepper.set_trapq(toolhead.get_trapq())
curpos[2] = z_low + next_stepper_offset
try:
@ -52,11 +54,13 @@ class ZAdjustHelper:
toolhead.set_position(curpos)
except:
logging.exception("ZAdjustHelper adjust_steppers")
toolhead.flush_step_generation()
for s in self.z_steppers:
s.set_trapq(toolhead.get_trapq())
raise
# Z should now be level - do final cleanup
last_stepper_offset, last_stepper = positions[-1]
toolhead.flush_step_generation()
last_stepper.set_trapq(toolhead.get_trapq())
curpos[2] += first_stepper_offset
toolhead.set_position(curpos)

View File

@ -41,13 +41,14 @@ class Homing:
for mcu_endstop, name in endstops:
mcu_endstop.home_prepare()
# Note start location
print_time = self.toolhead.get_last_move_time()
self.toolhead.flush_step_generation()
kin = self.toolhead.get_kinematics()
for s in kin.get_steppers():
s.set_tag_position(s.get_commanded_position())
start_mcu_pos = [(s, name, s.get_mcu_position())
for es, name in endstops for s in es.get_steppers()]
# Start endstop checking
print_time = self.toolhead.get_last_move_time()
self.endstops_pending = len(endstops)
for mcu_endstop, name in endstops:
min_step_dist = min([s.get_step_dist()
@ -71,6 +72,7 @@ class Homing:
if error is None:
error = "Failed to home %s: %s" % (name, str(e))
# Determine stepper halt positions
self.toolhead.flush_step_generation()
end_mcu_pos = [(s, name, spos, s.get_mcu_position())
for s, name, spos in start_mcu_pos]
if probe_pos:
@ -123,6 +125,7 @@ class Homing:
self.homing_move(movepos, endstops, hi.second_homing_speed,
verify_movement=self.verify_retract)
# Signal home operation complete
self.toolhead.flush_step_generation()
kin = self.toolhead.get_kinematics()
for s in kin.get_steppers():
s.set_tag_position(s.get_commanded_position())

View File

@ -123,7 +123,7 @@ class CartKinematics:
# Dual carriage support
def _activate_carriage(self, carriage):
toolhead = self.printer.lookup_object('toolhead')
toolhead.get_last_move_time()
toolhead.flush_step_generation()
dc_rail = self.dual_carriage_rails[carriage]
dc_axis = self.dual_carriage_axis
self.rails[dc_axis].set_trapq(None)

View File

@ -320,7 +320,7 @@ class ToolHead:
self._update_drip_move_time(next_move_time)
else:
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
self.move_queue.flush()
self.special_queuing_state = "Flushed"
@ -331,7 +331,7 @@ class ToolHead:
self._update_move_time(self.print_time, lazy=False)
def _flush_lookahead(self):
if self.special_queuing_state:
return self._full_flush()
return self.flush_step_generation()
self.move_queue.flush()
def get_last_move_time(self):
self._flush_lookahead()
@ -374,7 +374,7 @@ class ToolHead:
# Running normally - reschedule check
return eventtime + buffer_time - self.buffer_time_low
# Under ran low buffer mark - flush lookahead queue
self._full_flush()
self.flush_step_generation()
if print_time != self.print_time:
self.idle_flush_print_time = self.print_time
except:
@ -385,7 +385,8 @@ class ToolHead:
def get_position(self):
return list(self.commanded_pos)
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.kin.set_position(newpos, homing_axes)
def move(self, newpos, speed):
@ -445,7 +446,7 @@ class ToolHead:
try:
self.move(newpos, speed)
except homing.CommandError as e:
self._full_flush()
self.flush_step_generation()
raise
# Transmit move in "drip" mode
try:
@ -454,7 +455,7 @@ class ToolHead:
self.move_queue.reset()
self.trapq_free_moves(self.trapq, self.reactor.NEVER)
# Exit "Drip" state
self._full_flush()
self.flush_step_generation()
def signal_drip_mode_end(self):
self.drip_completion.complete(True)
# Misc commands