Merge branch 'stage-setting-buttons' into 'v3'

Add recentre and ROM test buttons to stage settings

Closes #502

See merge request openflexure/openflexure-microscope-server!482
This commit is contained in:
Julian Stirling 2026-02-18 16:46:20 +00:00
commit 6f997cc990
2 changed files with 41 additions and 6 deletions

View file

@ -260,7 +260,7 @@ class RangeofMotionThing(lt.Thing):
# Stage may have crashed during a large move. Move stage back until motion # Stage may have crashed during a large move. Move stage back until motion
# is detected # is detected
self.logger.info("Moving stage back until motion is detect") self.logger.info("Moving stage back until motion is detected")
self._move_back_until_motion_detected(axis=axis, direction=direction) self._move_back_until_motion_detected(axis=axis, direction=direction)
# Replace final position. # Replace final position.
@ -331,8 +331,8 @@ class RangeofMotionThing(lt.Thing):
# Note the second return, the direction, is meaningless here. # Note the second return, the direction, is meaningless here.
return True, 1 return True, 1
self.logger.info( self.logger.info(
f"Estimated centre {abs(img_perc):.0f}% of a field of view away, " f"Estimated centre {abs(img_perc):.0f}% of a field of view away. "
"that is too far to move in one move." "Moving towards centre."
) )
# Else calculate the desired direction in image coordinates. # Else calculate the desired direction in image coordinates.
direction = self._img_dir_from_stage_coords(estimate, axis) direction = self._img_dir_from_stage_coords(estimate, axis)
@ -497,7 +497,7 @@ class RangeofMotionThing(lt.Thing):
abs_min_offset=abs_min_offset, abs_min_offset=abs_min_offset,
) )
parasitic_motion = _parasitic_motion_detected(movement, offset) parasitic_motion = _parasitic_motion_detected(movement, offset)
self.logger.info(f"Offset measured as {offset[axis]}") self.logger.info(f"Offset measured as {int(offset[axis])}")
self._rom_data.record_movement(self._stage.position, offset) self._rom_data.record_movement(self._stage.position, offset)
if abs(offset[axis]) < abs_min_offset or parasitic_motion: if abs(offset[axis]) < abs_min_offset or parasitic_motion:
@ -532,7 +532,7 @@ class RangeofMotionThing(lt.Thing):
for i in range(max_moves): for i in range(max_moves):
# Increment movement # Increment movement
self.logger.info(f"Testing with step size {movement[axis]}") self.logger.info(f"Testing with step size {int(movement[axis])}")
# Run an autofocus every 3 steps # Run an autofocus every 3 steps
run_autofocus = i % 3 == 2 run_autofocus = i % 3 == 2
@ -540,7 +540,7 @@ class RangeofMotionThing(lt.Thing):
movement=movement, perform_autofocus=run_autofocus movement=movement, perform_autofocus=run_autofocus
) )
self.logger.info(f"Offset measured as {abs(offset[axis])}") self.logger.info(f"Offset measured as {int(abs(offset[axis]))}")
if abs(offset[axis]) > motion_minimum: if abs(offset[axis]) > motion_minimum:
self.logger.info("Motion detected.") self.logger.info("Motion detected.")
return return

View file

@ -23,6 +23,38 @@
</div> </div>
</div> </div>
</div> </div>
<div v-if="stageMeasureAvailable" class="uk-width-large">
<h4>Stage Measurement Tools</h4>
<div class="uk-margin">
<action-button
class="uk-width-1-2"
thing="stage_measure"
action="perform_recentre"
submit-label="Recentre Stage"
:button-primary="true"
:can-terminate="true"
:requires-confirmation="true"
:confirmation-message="'Start recalibration of the stage to find the centre of the range of motion?<br><br>Calibration requires a large, dense, flat sample with a variety of features.<br>Microscope will be locked while this runs'"
:modal-progress="true"
:stream-with-modal="true"
/>
</div>
<div class="uk-margin">
<action-button
class="uk-width-1-2"
thing="stage_measure"
action="perform_rom_test"
submit-label="Run ROM Test"
:button-primary="true"
:can-terminate="true"
:requires-confirmation="true"
:confirmation-message="'Start recalibration of the stage to find the range of motion in steps?<br><br>Calibration requires a large, dense, flat sample with a variety of features.<br>Microscope will be locked while this runs'"
:modal-progress="true"
:stream-with-modal="true"
/>
</div>
</div>
</div> </div>
</div> </div>
</template> </template>
@ -48,6 +80,9 @@ export default {
stageType: function () { stageType: function () {
return this.thingDescription("stage").title; return this.thingDescription("stage").title;
}, },
stageMeasureAvailable() {
return this.thingAvailable("stage_measure");
},
}, },
mounted() { mounted() {