-
+
-
+
-
+
@@ -113,7 +116,8 @@ export default {
keysDown: {},
stepXy: 200,
stepZz: 50,
- setPosition: this.$store.state.apiState.stage.position
+ setPosition: this.$store.state.apiState.stage.position,
+ isAutofocusing: false
}
},
@@ -210,6 +214,36 @@ export default {
}
},
+ runAutofocus: function(dz) {
+ if (!this.$store.state.moveLock) {
+ // Lock move requests
+ this.$store.commit('changeMoveLock', true);
+ axios.post(this.autofocusApiUri, {dz: dz})
+ .then(response => {
+ console.log("Autofocus Task ID: " + response.data[0].id)
+ this.isAutofocusing = true
+ // Start the store polling TaskId for success
+ self = this;
+ this.$store.dispatch('pollTask', [response.data[0].id, null, null])
+ .then(function() {
+ UIkit.notification({message: "Finished recalibration.", status: 'success'})
+ })
+ .catch(error => {
+ UIkit.notification({message: `
${error}`, status: 'danger'})
+ })
+ .finally(() => {
+ self.isAutofocusing = false
+ this.$store.commit('changeMoveLock', false) // Release the move lock
+ })
+ })
+ .catch(error => {
+ this.$store.dispatch('handleHTTPError', error); // Let store handle error
+ self.isAutofocusing = false
+ this.$store.commit('changeMoveLock', false) // Release the move lock
+ })
+ }
+ }
+
},
created: function () {
@@ -221,6 +255,9 @@ export default {
computed: {
positionApiUri: function () {
return this.$store.getters.uri + "/stage/position"
+ },
+ autofocusApiUri: function () {
+ return this.$store.getters.uri + "/plugin/default/autofocus/autofocus"
}
}