Updated camera stage mapping settings
This commit is contained in:
parent
c5c02eb029
commit
27b1f42935
1 changed files with 34 additions and 86 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<div id="CSMCalibrationSettings">
|
<div id="CSMCalibrationSettings">
|
||||||
<!--Show auto calibrate if default plugin is enabled-->
|
<!--Show auto calibrate if default plugin is enabled-->
|
||||||
<div v-if="'calibrate_xy' in recalibrationLinks" class="uk-margin-small">
|
<div v-if="'calibrate_xy' in actions" class="uk-margin-small">
|
||||||
<taskSubmitter
|
<taskSubmitter
|
||||||
:button-primary="true"
|
:button-primary="true"
|
||||||
:can-terminate="false"
|
:can-terminate="false"
|
||||||
|
|
@ -9,16 +9,15 @@
|
||||||
:confirmation-message="
|
:confirmation-message="
|
||||||
'Start recalibration of the stage to the camera? This may take a while, and the microscope will be locked during this time.'
|
'Start recalibration of the stage to the camera? This may take a while, and the microscope will be locked during this time.'
|
||||||
"
|
"
|
||||||
:submit-url="recalibrationLinks.calibrate_xy.href"
|
:submit-url="thingUri + 'calibrate_xy'"
|
||||||
:submit-label="'Auto-Calibrate using camera'"
|
:submit-label="'Auto-Calibrate using camera'"
|
||||||
@response="onRecalibrateResponse"
|
@response="onRecalibrateResponse"
|
||||||
@error="modalError"
|
@error="modalError"
|
||||||
>
|
/>
|
||||||
</taskSubmitter>
|
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
v-if="'get_calibration' in recalibrationLinks"
|
v-if="'last_calibration' in properties"
|
||||||
v-show="dataAvailable && showExtraSettings"
|
v-show="showExtraSettings"
|
||||||
type="button"
|
type="button"
|
||||||
class="uk-button uk-button-default uk-width-1-1"
|
class="uk-button uk-button-default uk-width-1-1"
|
||||||
@click="getCalibrationData()"
|
@click="getCalibrationData()"
|
||||||
|
|
@ -51,104 +50,53 @@ export default {
|
||||||
data: function() {
|
data: function() {
|
||||||
return {
|
return {
|
||||||
settings: null,
|
settings: null,
|
||||||
recalibrationLinks: {},
|
actions: {},
|
||||||
isCalibrating: false,
|
properties: {},
|
||||||
dataAvailable: false
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
settingsUri: function() {
|
thingUri: function() {
|
||||||
return `${this.$store.getters.baseUri}/api/v2/instrument/settings`;
|
return `${this.$store.getters.baseUri}/camera_stage_mapping/`;
|
||||||
},
|
|
||||||
pluginsUri: function() {
|
|
||||||
return `${this.$store.getters.baseUri}/api/v2/extensions`;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
this.updateSettings();
|
this.updateActions();
|
||||||
this.updateRecalibrationLinks();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
updateSettings: function() {
|
getCalibrationData: async function() {
|
||||||
// Update links
|
try {
|
||||||
axios
|
let response = await axios.get(this.thingUri + "last_calibration");
|
||||||
.get(this.settingsUri)
|
if (response.data == {}) {
|
||||||
.then(response => {
|
throw "No calibration data available.";
|
||||||
this.settings =
|
}
|
||||||
response.data.extensions["org.openflexure.camera_stage_mapping"];
|
const data = JSON.stringify(response.data);
|
||||||
})
|
const url = window.URL.createObjectURL(new Blob([data]));
|
||||||
.catch(error => {
|
const link = document.createElement("a");
|
||||||
this.modalError(error); // Let mixin handle error
|
link.href = url;
|
||||||
this.settings = {};
|
link.setAttribute("download", "csm_calibration.json");
|
||||||
});
|
document.body.appendChild(link);
|
||||||
},
|
link.click();
|
||||||
|
} catch (error) {
|
||||||
updateCalibrationDataAvailability: function() {
|
this.modalError(error); // Let mixin handle error
|
||||||
if ("get_calibration" in this.recalibrationLinks) {
|
|
||||||
axios
|
|
||||||
.get(this.recalibrationLinks.get_calibration.href)
|
|
||||||
.then(response => {
|
|
||||||
if (Object.keys(response.data).length === 0) {
|
|
||||||
this.dataAvailable = false;
|
|
||||||
} else {
|
|
||||||
this.dataAvailable = true;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
this.modalError(error); // Let mixin handle error
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
getCalibrationData: function() {
|
updateActions: async function() {
|
||||||
axios
|
try {
|
||||||
.get(this.recalibrationLinks.get_calibration.href)
|
let response = await axios.get(this.thingUri); // Get Thing Description
|
||||||
.then(response => {
|
console.log("CSM TD", response.data);
|
||||||
if (response.data != {}) {
|
this.actions = response.data.actions;
|
||||||
const data = JSON.stringify(response.data);
|
this.properties = response.data.properties;
|
||||||
const url = window.URL.createObjectURL(new Blob([data]));
|
} catch (error) {
|
||||||
const link = document.createElement("a");
|
this.modalError(error); // Let mixin handle error
|
||||||
link.href = url;
|
}
|
||||||
link.setAttribute("download", "csm_calibration.json");
|
|
||||||
document.body.appendChild(link);
|
|
||||||
link.click();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
this.modalError(error); // Let mixin handle error
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
updateRecalibrationLinks: function() {
|
|
||||||
axios
|
|
||||||
.get(this.pluginsUri) // Get a list of plugins
|
|
||||||
.then(response => {
|
|
||||||
var plugins = response.data;
|
|
||||||
var foundExtension = plugins.find(
|
|
||||||
e => e.title === "org.openflexure.camera_stage_mapping"
|
|
||||||
);
|
|
||||||
// if camera-stage mapping extension is enabled
|
|
||||||
if (foundExtension) {
|
|
||||||
// Get plugin action link
|
|
||||||
this.recalibrationLinks = foundExtension.links;
|
|
||||||
// Update whether calibration data is available
|
|
||||||
this.updateCalibrationDataAvailability();
|
|
||||||
} else {
|
|
||||||
this.recalibrationLinks = {};
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
this.modalError(error); // Let mixin handle error
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onRecalibrateResponse: function() {
|
onRecalibrateResponse: function() {
|
||||||
this.modalNotify("Finished stage-to-camera calibration.");
|
this.modalNotify("Finished stage-to-camera calibration.");
|
||||||
// Update local settings
|
|
||||||
this.updateSettings();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue