Route all moves through the Move taskSubmitter
I've consolidated move code (except moveinimagecoordinates) so that it now all simulates clicking "submit" on the taskSubmitter.
This commit is contained in:
parent
77c43c824d
commit
30deedde9e
1 changed files with 42 additions and 45 deletions
|
|
@ -92,6 +92,7 @@
|
||||||
class="uk-input uk-form-small"
|
class="uk-input uk-form-small"
|
||||||
type="number"
|
type="number"
|
||||||
name="inputPositionX"
|
name="inputPositionX"
|
||||||
|
@keyup.enter="startMoveTask"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -104,6 +105,7 @@
|
||||||
class="uk-input uk-form-small"
|
class="uk-input uk-form-small"
|
||||||
type="number"
|
type="number"
|
||||||
name="inputPositionY"
|
name="inputPositionY"
|
||||||
|
@keyup.enter="startMoveTask"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -116,18 +118,23 @@
|
||||||
class="uk-input uk-form-small"
|
class="uk-input uk-form-small"
|
||||||
type="number"
|
type="number"
|
||||||
name="inputPositionZx"
|
name="inputPositionZx"
|
||||||
|
@keyup.enter="startMoveTask"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<button
|
<taskSubmitter
|
||||||
type="submit"
|
ref="moveTaskSubmitter"
|
||||||
class="uk-button uk-button-default uk-float-right uk-width-1-1"
|
:submit-url="absoluteMoveUri"
|
||||||
>
|
:submit-data="setPosition"
|
||||||
Move
|
:submit-label="'Move'"
|
||||||
</button>
|
:canTerminate="false"
|
||||||
|
@taskStarted="moveLock = true"
|
||||||
|
@finished="moveLock = false"
|
||||||
|
@error="modalError"
|
||||||
|
></taskSubmitter>
|
||||||
</p>
|
</p>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -230,11 +237,11 @@ export default {
|
||||||
baseUri: function() {
|
baseUri: function() {
|
||||||
return this.$store.getters.baseUri;
|
return this.$store.getters.baseUri;
|
||||||
},
|
},
|
||||||
moveActionUri: function() {
|
absoluteMoveUri: function() {
|
||||||
return `${this.$store.getters.baseUri}/stage/move_relative`;
|
return this.thingActionUrl("stage", "move_absolute");
|
||||||
},
|
},
|
||||||
zeroActionUri: function() {
|
zeroActionUri: function() {
|
||||||
return `${this.$store.getters.baseUri}/stage/zero`;
|
return this.thingActionUrl("stage", "zero");
|
||||||
},
|
},
|
||||||
positionStatusUri: function() {
|
positionStatusUri: function() {
|
||||||
return `${this.baseUri}/stage/position`;
|
return `${this.baseUri}/stage/position`;
|
||||||
|
|
@ -273,17 +280,17 @@ export default {
|
||||||
this.stepSize =
|
this.stepSize =
|
||||||
this.getLocalStorageObj("navigation_stepSize") || this.stepSize;
|
this.getLocalStorageObj("navigation_stepSize") || this.stepSize;
|
||||||
this.invert = this.getLocalStorageObj("navigation_invert") || this.invert;
|
this.invert = this.getLocalStorageObj("navigation_invert") || this.invert;
|
||||||
|
let self = this;
|
||||||
// A global signal listener to perform a move action
|
// A global signal listener to perform a move action
|
||||||
this.$root.$on("globalMoveEvent", (x, y, z, absolute) => {
|
this.$root.$on("globalMoveEvent", self.move);
|
||||||
this.moveRequest(x, y, z, absolute);
|
|
||||||
});
|
|
||||||
// A global signal listener to perform a move action in pixels
|
// A global signal listener to perform a move action in pixels
|
||||||
this.$root.$on("globalMoveInImageCoordinatesEvent", (x, y, absolute) => {
|
this.$root.$on("globalMoveInImageCoordinatesEvent", (x, y, absolute) => {
|
||||||
this.moveInImageCoordinatesRequest(x, y, absolute);
|
this.moveInImageCoordinatesRequest(x, y, absolute);
|
||||||
});
|
});
|
||||||
// A global signal listener to perform a move in multiples of a step size
|
// A global signal listener to perform a move in multiples of a step size
|
||||||
this.$root.$on("globalMoveStepEvent", (x_steps, y_steps, z_steps) => {
|
this.$root.$on("globalMoveStepEvent", (x_steps, y_steps, z_steps) => {
|
||||||
this.moveRequest(
|
this.$root.$emit(
|
||||||
|
"globalMoveEvent",
|
||||||
x_steps * this.stepSize.x * (this.invert.x ? -1 : 1),
|
x_steps * this.stepSize.x * (this.invert.x ? -1 : 1),
|
||||||
y_steps * this.stepSize.y * (this.invert.y ? -1 : 1),
|
y_steps * this.stepSize.y * (this.invert.y ? -1 : 1),
|
||||||
z_steps * this.stepSize.z * (this.invert.z ? -1 : 1),
|
z_steps * this.stepSize.z * (this.invert.z ? -1 : 1),
|
||||||
|
|
@ -292,7 +299,6 @@ export default {
|
||||||
});
|
});
|
||||||
// Update the current position in text boxes
|
// Update the current position in text boxes
|
||||||
this.updatePosition();
|
this.updatePosition();
|
||||||
// Look for autofocus plugin
|
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
|
|
@ -303,40 +309,31 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
handleSubmit: function() {
|
timeout(ms) {
|
||||||
this.moveRequest(
|
return new Promise(resolve => setTimeout(resolve, ms));
|
||||||
this.setPosition.x,
|
|
||||||
this.setPosition.y,
|
|
||||||
this.setPosition.z,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
|
async move(x, y, z, absolute) {
|
||||||
moveRequest: function(x, y, z, absolute) {
|
// Move the stage, by updating the controls and starting a move task
|
||||||
// If not movement-locked
|
// This is equivalent to clicking the "move" button.
|
||||||
if (!this.moveLock) {
|
if (this.moveLock) return; // Discard move requests if we're already moving
|
||||||
// Lock move requests
|
// NB moveLock is just boolean flag - it's not as safe as a "proper" lock.
|
||||||
this.moveLock = true;
|
this.moveLock = true; // This will also be set by the task submitter, but
|
||||||
let move_type = absolute ? "absolute" : "relative";
|
// setting it here avoids multiple moves being requested simultaneously.
|
||||||
// Send move request
|
if (absolute){
|
||||||
axios
|
this.setPosition = {"x": x, "y": y, "z": z}
|
||||||
.post(`${this.baseUri}/stage/move_${move_type}`, {
|
}else{
|
||||||
x: x,
|
this.setPosition = {
|
||||||
y: y,
|
"x": this.setPosition.x + x,
|
||||||
z: z
|
"y": this.setPosition.y + y,
|
||||||
})
|
"z": this.setPosition.z + z
|
||||||
.then(() => {
|
}
|
||||||
this.updatePosition(); // Update the position in text boxes
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
this.modalError(error); // Let mixin handle error
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
this.moveLock = false; // Release the move lock
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
await this.timeout(1); // Wait for Vue to update the position
|
||||||
|
this.startMoveTask();
|
||||||
|
},
|
||||||
|
startMoveTask() {
|
||||||
|
this.$refs.moveTaskSubmitter.startTask();
|
||||||
},
|
},
|
||||||
|
|
||||||
moveInImageCoordinatesRequest: function(x, y) {
|
moveInImageCoordinatesRequest: function(x, y) {
|
||||||
// If not movement-locked
|
// If not movement-locked
|
||||||
if (!this.moveLock) {
|
if (!this.moveLock) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue