mirror of
https://github.com/Klipper3d/klipper.git
synced 2025-07-23 14:44:20 -06:00
bulk_sensor: Simplify the registration of internal clients in BatchBulkHelper
Previously, the BatchBulkHelper class was designed primarily to register webhook clients, and internal clients used a wrapper class that emulated a webhooks client. Change BatchBulkHelper to support regular internal callbacks, and introduce a new BatchWebhooksClient class that can translate these internal callback to webhooks client messages. This makes it easier to register internal clients that can process the bulk messages every batch interval. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
3370134593
commit
c716edafe2
5 changed files with 69 additions and 69 deletions
|
@ -157,8 +157,14 @@ class AngleCalibration:
|
|||
def do_calibration_moves(self):
|
||||
move = self.printer.lookup_object('force_move').manual_move
|
||||
# Start data collection
|
||||
angle_sensor = self.printer.lookup_object(self.name)
|
||||
cconn = angle_sensor.start_internal_client()
|
||||
msgs = []
|
||||
is_finished = False
|
||||
def handle_batch(msg):
|
||||
if is_finished:
|
||||
return False
|
||||
msgs.append(msg)
|
||||
return True
|
||||
self.printer.lookup_object(self.name).add_client(handle_batch)
|
||||
# Move stepper several turns (to allow internal sensor calibration)
|
||||
microsteps, full_steps = self.get_microsteps()
|
||||
mcu_stepper = self.mcu_stepper
|
||||
|
@ -190,13 +196,12 @@ class AngleCalibration:
|
|||
move(mcu_stepper, .5*rotation_dist + align_dist, move_speed)
|
||||
toolhead.wait_moves()
|
||||
# Finish data collection
|
||||
cconn.finalize()
|
||||
msgs = cconn.get_messages()
|
||||
is_finished = True
|
||||
# Correlate query responses
|
||||
cal = {}
|
||||
step = 0
|
||||
for msg in msgs:
|
||||
for query_time, pos in msg['params']['data']:
|
||||
for query_time, pos in msg['data']:
|
||||
# Add to step tracking
|
||||
while step < len(times) and query_time > times[step][1]:
|
||||
step += 1
|
||||
|
@ -462,8 +467,8 @@ class Angle:
|
|||
"spi_angle_end oid=%c sequence=%hu", oid=self.oid, cq=cmdqueue)
|
||||
def get_status(self, eventtime=None):
|
||||
return {'temperature': self.sensor_helper.last_temperature}
|
||||
def start_internal_client(self):
|
||||
return self.batch_bulk.add_internal_client()
|
||||
def add_client(self, client_cb):
|
||||
self.batch_bulk.add_client(client_cb)
|
||||
# Measurement decoding
|
||||
def _extract_samples(self, raw_samples):
|
||||
# Load variables to optimize inner loop below
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue