Get FOV from server
This commit is contained in:
parent
936bebc55e
commit
b561513c4f
1 changed files with 36 additions and 16 deletions
|
|
@ -29,7 +29,10 @@ var fovY = 3146;
|
||||||
|
|
||||||
window.onload = function() {
|
window.onload = function() {
|
||||||
setHostFromInput()
|
setHostFromInput()
|
||||||
getStagePositions()
|
|
||||||
|
// TODO: Use getConfig as a connection check. Handle connection timeout.
|
||||||
|
getConfig(updateConfigValues)
|
||||||
|
getState(updateStateValues)
|
||||||
updateTextBoxes()
|
updateTextBoxes()
|
||||||
getCaptures()
|
getCaptures()
|
||||||
}
|
}
|
||||||
|
|
@ -124,26 +127,43 @@ function updateTextBoxes() {
|
||||||
document.getElementById('stageVelocityInput').value = stageVelocity;
|
document.getElementById('stageVelocityInput').value = stageVelocity;
|
||||||
document.getElementById('focusVelocityText').value = focusVelocity;
|
document.getElementById('focusVelocityText').value = focusVelocity;
|
||||||
document.getElementById('focusVelocityInput').value = focusVelocity;
|
document.getElementById('focusVelocityInput').value = focusVelocity;
|
||||||
|
|
||||||
document.getElementById('fovXText').value = fovX;
|
|
||||||
document.getElementById('fovYText').value = fovY;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateStagePositions(response) {
|
function updatePositionValues(state) {
|
||||||
document.getElementById('x_abs').value = response.x;
|
document.getElementById('x_abs').value = state.stage.position.x;
|
||||||
document.getElementById('y_abs').value = response.y;
|
document.getElementById('y_abs').value = state.stage.position.y;
|
||||||
document.getElementById('z_abs').value = response.z;
|
document.getElementById('z_abs').value = state.stage.position.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getStagePositions() {
|
function updateFovValues(config) {
|
||||||
function updatePositionCallback(response, status) {
|
document.getElementById('fovXText').value = config.fov.x;
|
||||||
console.log(status, response);
|
document.getElementById('fovYText').value = config.fov.y;
|
||||||
updateStagePositions(response);
|
}
|
||||||
|
|
||||||
|
function updateStateValues(state){
|
||||||
|
updatePositionValues(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateConfigValues(config){
|
||||||
|
updateFovValues(config)
|
||||||
|
}
|
||||||
|
|
||||||
|
function getState(callback) {
|
||||||
|
function getStateCallback(response, status) {
|
||||||
|
callback(response);
|
||||||
}
|
}
|
||||||
safeRequest("GET", baseURI+"/stage/position", null, updatePositionCallback, false)
|
safeRequest("GET", baseURI+"/state", null, getStateCallback, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
function getConfig(callback) {
|
||||||
|
function getConfigCallback(response, status) {
|
||||||
|
callback(response);
|
||||||
|
}
|
||||||
|
safeRequest("GET", baseURI+"/config", null, getConfigCallback, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Capture methods
|
// Capture methods
|
||||||
|
// TODO: Explicit callback. Roll into class.
|
||||||
function newCapture(filename, keep_on_disk, use_video_port, bayer, resizeWidth=null, resizeHeight=null) {
|
function newCapture(filename, keep_on_disk, use_video_port, bayer, resizeWidth=null, resizeHeight=null) {
|
||||||
// Make a position request
|
// Make a position request
|
||||||
function newCaptureCallback(response, status) {
|
function newCaptureCallback(response, status) {
|
||||||
|
|
@ -228,7 +248,7 @@ function setStagePositions(x_abs, y_abs, z_abs) {
|
||||||
alert("Error moving stage.");
|
alert("Error moving stage.");
|
||||||
}
|
}
|
||||||
console.log(status, response);
|
console.log(status, response);
|
||||||
updateStagePositions(response);
|
updatePositionValues(response);
|
||||||
}
|
}
|
||||||
safeRequest("POST", baseURI+"/stage/position", { "absolute": true, "x": x_abs, "y": y_abs, "z": z_abs}, absMoveCallback)
|
safeRequest("POST", baseURI+"/stage/position", { "absolute": true, "x": x_abs, "y": y_abs, "z": z_abs}, absMoveCallback)
|
||||||
}
|
}
|
||||||
|
|
@ -240,7 +260,7 @@ function moveStagePositions(x_rel, y_rel, z_rel) {
|
||||||
alert("Error moving stage.");
|
alert("Error moving stage.");
|
||||||
}
|
}
|
||||||
console.log(status, response);
|
console.log(status, response);
|
||||||
updateStagePositions(response);
|
updatePositionValues(response);
|
||||||
}
|
}
|
||||||
safeRequest("POST", baseURI+"/stage/position", { "absolute": false, "x": x_rel, "y": y_rel, "z": z_rel}, relMoveCallback)
|
safeRequest("POST", baseURI+"/stage/position", { "absolute": false, "x": x_rel, "y": y_rel, "z": z_rel}, relMoveCallback)
|
||||||
}
|
}
|
||||||
|
|
@ -255,7 +275,7 @@ function setStagePositionsFromInput() {
|
||||||
// Standard callback for user-controller movement
|
// Standard callback for user-controller movement
|
||||||
function keyMoveCallback(response, status) {
|
function keyMoveCallback(response, status) {
|
||||||
console.log(status, response);
|
console.log(status, response);
|
||||||
updateStagePositions(response);
|
updatePositionValues(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Methods for input events
|
// Methods for input events
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue