Use calibration_required property to conditionally render z cal step

This commit is contained in:
jaknapper 2026-07-07 12:23:15 +01:00 committed by Julian Stirling
parent 5875abbceb
commit f68515b17d
5 changed files with 50 additions and 12 deletions

View file

@ -166,6 +166,9 @@ class BaseStage(lt.Thing):
)
"""Used to convert coordinates between the program frame and the hardware frame."""
calibration_required: bool = lt.setting(default=False)
"""Whether calibration of the stage z axis is required."""
def update_position(self) -> None:
"""Update the position property from the stage."""
# Copy the position before the move.
@ -535,3 +538,8 @@ class BaseStage(lt.Thing):
This method provides the interface expected by the camera_stage_mapping.
"""
self.move_absolute(x=xyz_pos[0], y=xyz_pos[1], z=xyz_pos[2])
@lt.action
def mark_calibration_complete(self) -> None:
"""Mark stage calibration as complete."""
self.calibration_required = False

View file

@ -236,3 +236,6 @@ class SangaboardThing(BaseStage):
self._sangaboard.query(f"{led_command} {on_brightness}")
else:
self._sangaboard.query(f"{led_command} 0")
calibration_required: bool = lt.setting(default=True)
"""By default, Sangaboard stage will require calibration of z direction."""

View file

@ -28,7 +28,7 @@
<script>
import singleStepTask from "./calibrationWizardComponents/singleStepTask.vue";
import welcomeStep from "./calibrationWizardComponents/welcomeStep.vue";
import zMotorDirectionStep from "./calibrationWizardComponents/zMotorDirectionStep.vue";
import zMotorCalibrationTask from "./calibrationWizardComponents/zMotorCalibrationTask.vue";
import cameraCalibrationTask from "./calibrationWizardComponents/cameraCalibrationTask.vue";
import cameraStageMappingTask from "./calibrationWizardComponents/cameraStageMappingTask.vue";
import finalStep from "./calibrationWizardComponents/finalStep.vue";
@ -69,6 +69,7 @@ export default {
this.$refs["calibrationModalEl"].addEventListener("hidden", this.onHide);
// Check which Things are available on mount.
const allCalibrationTasks = {
stage: markRaw(zMotorCalibrationTask),
camera: markRaw(cameraCalibrationTask),
camera_stage_mapping: markRaw(cameraStageMappingTask),
};
@ -121,15 +122,6 @@ export default {
});
}
// Ask which way the z motor turns, right after the welcome screen but before any
// other tasks, so the stage is correctly oriented before anything else runs.
if (this.thingAvailable("stage") && this.thingDescription("stage").title != "DummyStage") {
tasks.push({
component: markRaw(singleStepTask),
props: { title: "Stage Calibration", stepComponent: zMotorDirectionStep },
});
}
// Add calibration task for each thing
for (const thing of thingsToCal) {
const taskComponent = this.availableCalibrationTasks[thing];

View file

@ -0,0 +1,29 @@
<template>
<singleStepTask
title="Stage Calibration"
:step-component="zMotorDirectionStep"
@next="$emit('next')"
@back="$emit('back')"
/>
</template>
<script>
import singleStepTask from "./singleStepTask.vue";
import zMotorDirectionStep from "./zMotorDirectionStep.vue";
export default {
name: "ZMotorCalibrationTask",
components: {
singleStepTask,
},
emits: ["next", "back"],
data() {
return {
zMotorDirectionStep,
};
},
};
</script>

View file

@ -69,7 +69,7 @@ export default {
},
mounted() {
this.$emit("awaiting-user", true);
this.checkCalibrationState();
},
methods: {
@ -94,7 +94,9 @@ export default {
},
// Once a direction is selected, advance
selectDir() {
this.$emit("advance");
this.invokeAction("stage", "mark_calibration_complete").then(() => {
this.$emit("advance");
});
},
// If motor moves clockwise, invert z direction, then progress to next step
triggerClockwise() {
@ -102,6 +104,10 @@ export default {
this.selectDir();
});
},
async checkCalibrationState() {
const needsCal = await this.readThingProperty("stage", "calibration_required");
this.$emit("awaiting-user", needsCal);
},
},
};
</script>