Cleaned up settling time maths to only calculate once

This commit is contained in:
jaknapper 2025-05-20 14:42:02 +01:00 committed by Julian Stirling
parent 35e1d6cdee
commit 628fd145f3

View file

@ -318,7 +318,7 @@ class AutofocusThing(Thing):
logger=logger, logger=logger,
) )
captured_time = time.time() captured_time = time.time()
# There's an unnecessary move up at the end of the stack
if capture_count + 1 < images_to_capture: if capture_count + 1 < images_to_capture:
stage.move_relative(z=stack_dz) stage.move_relative(z=stack_dz)
moved_time = time.time() moved_time = time.time()
@ -332,11 +332,10 @@ class AutofocusThing(Thing):
logger=logger, logger=logger,
) )
saved_time = time.time() saved_time = time.time()
if saved_time - start_time < SETTLING_TIME: time_remaining = SETTLING_TIME - (saved_time - start_time)
time.sleep(SETTLING_TIME - (saved_time - start_time)) if time_remaining > 0:
logger.info( time.sleep(time_remaining)
f"Settled for an extra {round(SETTLING_TIME - (saved_time - start_time), 3)} seconds" logger.info(f"Settled for an extra {round(time_remaining, 3)} seconds")
)
logger.debug(f"Capturing took {round(captured_time - start_time, 2)} s") logger.debug(f"Capturing took {round(captured_time - start_time, 2)} s")
logger.debug(f"Resizing took {round(downsampled_time - moved_time, 2)} s") logger.debug(f"Resizing took {round(downsampled_time - moved_time, 2)} s")
logger.debug(f"Saving took {round(saved_time - downsampled_time, 2)} s") logger.debug(f"Saving took {round(saved_time - downsampled_time, 2)} s")