improves error handling when there is no sensor data
This commit is contained in:
parent
1bde599b46
commit
5fb76a76ca
@ -53,6 +53,9 @@ window.addEventListener("load", function(evt) {
|
|||||||
.then(results => results.json())
|
.then(results => results.json())
|
||||||
.then(console.log);
|
.then(console.log);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
document.getElementById("tracking state").innerHTML = "Tracking state: LIVE"
|
||||||
|
|
||||||
checkBoxSmartphone.disabled = true;
|
checkBoxSmartphone.disabled = true;
|
||||||
checkBoxUblox.disabled = true;
|
checkBoxUblox.disabled = true;
|
||||||
|
|
||||||
@ -66,23 +69,22 @@ window.addEventListener("load", function(evt) {
|
|||||||
//console.log(evt.data)
|
//console.log(evt.data)
|
||||||
console.log("JSON geparsed onmessage", dat)
|
console.log("JSON geparsed onmessage", dat)
|
||||||
|
|
||||||
|
try{
|
||||||
if(checkBoxSmartphone.checked && !checkBoxUblox.checked){
|
if(!(dat.SOURCE_TCP.Orientation[0] === 0) && !(dat.SOURCE_TCP.Orientation[1] === 0) && !(dat.SOURCE_TCP.Orientation[2] === 0)){
|
||||||
try{
|
document.getElementById("gyroscopeTCP").style.transform = `rotateX(${dat.SOURCE_TCP.Orientation[0]}deg) rotateY(${dat.SOURCE_TCP.Orientation[1]}deg) rotateZ(${dat.SOURCE_TCP.Orientation[2]}deg)`
|
||||||
if(!(dat.SOURCE_TCP.Orientation[0] === 0) && !(dat.SOURCE_TCP.Orientation[1] === 0) && !(dat.SOURCE_TCP.Orientation[2] === 0)){
|
}
|
||||||
document.getElementById("gyroscopeTCP").style.transform = `rotateX(${dat.SOURCE_TCP.Orientation[0]}deg) rotateY(${dat.SOURCE_TCP.Orientation[1]}deg) rotateZ(${dat.SOURCE_TCP.Orientation[2]}deg)`
|
if(!(dat.SOURCE_TCP.Position[1] === 0) && !(dat.SOURCE_TCP.Position[0] === 0)){
|
||||||
}
|
document.getElementById("TCPlong").innerHTML = "Smartphone long: " + dat.SOURCE_TCP.Position[1]
|
||||||
if(!(dat.SOURCE_TCP.Position[1] === 0) && !(dat.SOURCE_TCP.Position[0] === 0)){
|
document.getElementById("TCPlat").innerHTML = "Smartphone lat: " + dat.SOURCE_TCP.Position[0]
|
||||||
document.getElementById("TCPlong").innerHTML = "Smartphone long: " + dat.SOURCE_TCP.Position[1]
|
updateMapTCP(dat.SOURCE_TCP.Position[1], dat.SOURCE_TCP.Position[0])
|
||||||
document.getElementById("TCPlat").innerHTML = "Smartphone lat: " + dat.SOURCE_TCP.Position[0]
|
map.panTo([dat.SOURCE_TCP.Position[1], dat.SOURCE_TCP.Position[0]])
|
||||||
updateMapTCP(dat.SOURCE_TCP.Position[1], dat.SOURCE_TCP.Position[0])
|
|
||||||
map.panTo([dat.SOURCE_TCP.Position[1], dat.SOURCE_TCP.Position[0]])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch{}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if(checkBoxUblox.checked && !checkBoxSmartphone.checked){
|
catch{
|
||||||
|
console.log("no TCP data")
|
||||||
|
}
|
||||||
|
|
||||||
|
try{
|
||||||
if(!(dat.SOURCE_SERIAL.Orientation[0] === 0) && /*!(dat.SOURCE_SERIAL.Orientation[1] === 0) &&*/ !(dat.SOURCE_SERIAL.Orientation[2] === 0)){
|
if(!(dat.SOURCE_SERIAL.Orientation[0] === 0) && /*!(dat.SOURCE_SERIAL.Orientation[1] === 0) &&*/ !(dat.SOURCE_SERIAL.Orientation[2] === 0)){
|
||||||
document.getElementById("gyroscopeSERIAL").style.transform = `rotateX(${dat.SOURCE_SERIAL.Orientation[0]}deg) rotateY(${dat.SOURCE_SERIAL.Orientation[1]}deg) rotateZ(${dat.SOURCE_SERIAL.Orientation[2]}deg)`
|
document.getElementById("gyroscopeSERIAL").style.transform = `rotateX(${dat.SOURCE_SERIAL.Orientation[0]}deg) rotateY(${dat.SOURCE_SERIAL.Orientation[1]}deg) rotateZ(${dat.SOURCE_SERIAL.Orientation[2]}deg)`
|
||||||
}
|
}
|
||||||
@ -92,34 +94,22 @@ window.addEventListener("load", function(evt) {
|
|||||||
updateMapSERIAL(dat.SOURCE_SERIAL.Position[1], dat.SOURCE_SERIAL.Position[0])
|
updateMapSERIAL(dat.SOURCE_SERIAL.Position[1], dat.SOURCE_SERIAL.Position[0])
|
||||||
map.panTo([dat.SOURCE_SERIAL.Position[1], dat.SOURCE_SERIAL.Position[0]])
|
map.panTo([dat.SOURCE_SERIAL.Position[1], dat.SOURCE_SERIAL.Position[0]])
|
||||||
}
|
}
|
||||||
|
}catch{
|
||||||
|
console.log("no serial data")
|
||||||
}
|
}
|
||||||
if(checkBoxSmartphone.checked && checkBoxUblox.checked){
|
|
||||||
try{
|
|
||||||
if(!(dat.SOURCE_TCP.Position[1] === 0) && !(dat.SOURCE_TCP.Position[0] === 0)){
|
|
||||||
document.getElementById("TCPlong").innerHTML = "Smartphone long: " + dat.SOURCE_TCP.Position[1]
|
|
||||||
document.getElementById("TCPlat").innerHTML = "Smartphone lat: " + dat.SOURCE_TCP.Position[0]
|
|
||||||
}
|
|
||||||
}catch{}
|
|
||||||
|
|
||||||
try{
|
try{
|
||||||
if(!(dat.SOURCE_SERIAL.Position[1] === 0) && !(dat.SOURCE_SERIAL.Position[0] === 0)){
|
if(!(dat.SOURCE_TCP.Position[1] === 0) && !(dat.SOURCE_SERIAL.Position[1] === 0)){
|
||||||
document.getElementById("SERIALlong").innerHTML = "Ublox long: " + dat.SOURCE_SERIAL.Position[1]
|
document.getElementById("diffLong").innerHTML = "Differenz long: " + Math.abs(dat.SOURCE_TCP.Position[1] - dat.SOURCE_SERIAL.Position[1])
|
||||||
document.getElementById("SERIALlat").innerHTML = "Ublox lat: " + dat.SOURCE_SERIAL.Position[0]
|
}
|
||||||
updateMapSERIAL(dat.SOURCE_SERIAL.Position[1], dat.SOURCE_SERIAL.Position[0])
|
if(!(dat.SOURCE_TCP.Position[0] === 0) && !(dat.SOURCE_SERIAL.Position[0] === 0)){
|
||||||
map.panTo([dat.SOURCE_SERIAL.Position[1], dat.SOURCE_SERIAL.Position[0]])
|
document.getElementById("diffLat").innerHTML = "Differenz lat: " + Math.abs(dat.SOURCE_TCP.Position[0] - dat.SOURCE_SERIAL.Position[0])
|
||||||
}
|
|
||||||
}catch{}
|
|
||||||
|
|
||||||
try{
|
|
||||||
if(!(dat.SOURCE_TCP.Position[1] === 0) && !(dat.SOURCE_SERIAL.Position[1] === 0)){
|
|
||||||
document.getElementById("diffLong").innerHTML = "Differenz long: " + Math.abs(dat.SOURCE_TCP.Position[1] - dat.SOURCE_SERIAL.Position[1])
|
|
||||||
}
|
|
||||||
if(!(dat.SOURCE_TCP.Position[0] === 0) && !(dat.SOURCE_SERIAL.Position[0] === 0)){
|
|
||||||
document.getElementById("diffLat").innerHTML = "Differenz lat: " + Math.abs(dat.SOURCE_TCP.Position[0] - dat.SOURCE_SERIAL.Position[0])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch{}
|
|
||||||
}
|
}
|
||||||
|
catch{
|
||||||
|
console.log("no data to compare")
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
console.log(dat)
|
console.log(dat)
|
||||||
orientation[0] += dat[0] * multiplier
|
orientation[0] += dat[0] * multiplier
|
||||||
@ -164,6 +154,17 @@ window.addEventListener("load", function(evt) {
|
|||||||
fetch('http://localhost:3011/trackings/', { method: 'PATCH', body: 'some data'})
|
fetch('http://localhost:3011/trackings/', { method: 'PATCH', body: 'some data'})
|
||||||
.then(results => results.json())
|
.then(results => results.json())
|
||||||
.then(console.log);
|
.then(console.log);
|
||||||
|
document.getElementById("tracking state").innerHTML = "Tracking state: RECORD"
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
document.getElementById("messung beenden").onclick = function(evt) {
|
||||||
|
if (ws) {
|
||||||
|
fetch('http://localhost:3011/trackings/', { method: 'PUT', body: 'some data'})
|
||||||
|
.then(results => results.json())
|
||||||
|
.then(console.log);
|
||||||
|
document.getElementById("tracking state").innerHTML = "Tracking state: LIVE"
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -139,10 +139,9 @@
|
|||||||
|
|
||||||
<button id="messung starten">Messung starten</button>
|
<button id="messung starten">Messung starten</button>
|
||||||
<button id="messung beenden">Messung beenden</button>
|
<button id="messung beenden">Messung beenden</button>
|
||||||
<button id="messung speichern">Messung speichern</button>
|
|
||||||
<button id="messung verwerfen">Messung verwerfen</button>
|
|
||||||
<button id="messung laden">Messung laden</button>
|
<button id="messung laden">Messung laden</button>
|
||||||
<button id="alles beenden">Alles Beenden</button><br>
|
<button id="alles beenden">Alles Beenden</button><br>
|
||||||
|
<label id="tracking state" style= "font: 12px/20px 'Helvetica Neue', Arial, Helvetica, sans-serif">Tracking state: </label><br>
|
||||||
<label id="TCPlong" style= "font: 12px/20px 'Helvetica Neue', Arial, Helvetica, sans-serif">Smartphone long: </label>
|
<label id="TCPlong" style= "font: 12px/20px 'Helvetica Neue', Arial, Helvetica, sans-serif">Smartphone long: </label>
|
||||||
<label id="TCPlat" style= "font: 12px/20px 'Helvetica Neue', Arial, Helvetica, sans-serif">Smartphone lat: </label>
|
<label id="TCPlat" style= "font: 12px/20px 'Helvetica Neue', Arial, Helvetica, sans-serif">Smartphone lat: </label>
|
||||||
<label id="SERIALlong" style= "font: 12px/20px 'Helvetica Neue', Arial, Helvetica, sans-serif">Ublox long: </label>
|
<label id="SERIALlong" style= "font: 12px/20px 'Helvetica Neue', Arial, Helvetica, sans-serif">Ublox long: </label>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user