Add a button to recentre the stage.

This commit is contained in:
Richard Bowman 2024-01-03 17:15:29 +00:00
parent 0e8340bb5b
commit 656e902198

View file

@ -71,7 +71,18 @@
<taskSubmitter <taskSubmitter
:submit-url="zeroActionUri" :submit-url="zeroActionUri"
:submit-label="'Zero Coordinates'" :submit-label="'Zero Coordinates'"
:canTerminate="false" :can-terminate="false"
@finished="updatePosition"
@error="modalError"
></taskSubmitter>
<taskSubmitter
:submit-url="recentreActionUri"
:submit-label="'Re-centre Stage'"
:can-terminate="false"
:requires-confirmation="true"
:confirmation-message="
'The stage will now move, and autofocus will be used to find the centre of motion. This requires a sample to be visible in the microscope. OK to proceed?'
"
@finished="updatePosition" @finished="updatePosition"
@error="modalError" @error="modalError"
></taskSubmitter> ></taskSubmitter>
@ -102,8 +113,8 @@
:submit-url="absoluteMoveUri" :submit-url="absoluteMoveUri"
:submit-data="setPosition" :submit-data="setPosition"
:submit-label="'Move'" :submit-label="'Move'"
:canTerminate="false" :can-terminate="false"
:pollInterval="0.05" :poll-interval="0.05"
@taskStarted="moveLock = true" @taskStarted="moveLock = true"
@finished="moveLock = false" @finished="moveLock = false"
@error="modalError" @error="modalError"
@ -216,6 +227,9 @@ export default {
zeroActionUri: function() { zeroActionUri: function() {
return this.thingActionUrl("stage", "set_zero_position"); return this.thingActionUrl("stage", "set_zero_position");
}, },
recentreActionUri: function() {
return this.thingActionUrl("auto_recentre_stage", "recentre");
},
positionStatusUri: function() { positionStatusUri: function() {
return `${this.baseUri}/stage/position`; return `${this.baseUri}/stage/position`;
}, },
@ -288,21 +302,21 @@ export default {
async move(x, y, z, absolute) { async move(x, y, z, absolute) {
// Move the stage, by updating the controls and starting a move task // Move the stage, by updating the controls and starting a move task
// This is equivalent to clicking the "move" button. // This is equivalent to clicking the "move" button.
if (this.moveLock) return; // Discard move requests if we're already moving if (this.moveLock) return; // Discard move requests if we're already moving
// NB moveLock is just boolean flag - it's not as safe as a "proper" lock. // NB moveLock is just boolean flag - it's not as safe as a "proper" lock.
this.moveLock = true; // This will also be set by the task submitter, but this.moveLock = true; // This will also be set by the task submitter, but
// setting it here avoids multiple moves being requested simultaneously. // setting it here avoids multiple moves being requested simultaneously.
if (absolute){ if (absolute) {
this.setPosition = {"x": x, "y": y, "z": z} this.setPosition = { x: x, y: y, z: z };
}else{ } else {
await this.updatePosition(); await this.updatePosition();
this.setPosition = { this.setPosition = {
"x": this.setPosition.x + x, x: this.setPosition.x + x,
"y": this.setPosition.y + y, y: this.setPosition.y + y,
"z": this.setPosition.z + z z: this.setPosition.z + z
} };
} }
await this.timeout(1); // Wait for Vue to update the position await this.timeout(1); // Wait for Vue to update the position
await this.startMoveTask(); await this.startMoveTask();
}, },
async startMoveTask() { async startMoveTask() {
@ -351,7 +365,7 @@ export default {
}, },
async updatePosition() { async updatePosition() {
this.setPosition = await this.readThingProperty("stage", "position") this.setPosition = await this.readThingProperty("stage", "position");
}, },
handleCaptureResponse: async function(response) { handleCaptureResponse: async function(response) {
@ -375,7 +389,6 @@ export default {
}; };
</script> </script>
<style scoped> <style scoped>
.input-and-buttons-container { .input-and-buttons-container {
display: flex; display: flex;