diff --git a/static/scripts/websocket.js b/static/scripts/websocket.js
index 6ebadb3..683d32f 100644
--- a/static/scripts/websocket.js
+++ b/static/scripts/websocket.js
@@ -53,6 +53,9 @@ window.addEventListener("load", function(evt) {
.then(results => results.json())
.then(console.log);
}
+
+ document.getElementById("tracking state").innerHTML = "Tracking state: LIVE"
+
checkBoxSmartphone.disabled = true;
checkBoxUblox.disabled = true;
@@ -66,23 +69,22 @@ window.addEventListener("load", function(evt) {
//console.log(evt.data)
console.log("JSON geparsed onmessage", dat)
-
- if(checkBoxSmartphone.checked && !checkBoxUblox.checked){
- try{
- 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]
- document.getElementById("TCPlat").innerHTML = "Smartphone lat: " + 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]])
- }
+ try{
+ 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]
+ document.getElementById("TCPlat").innerHTML = "Smartphone lat: " + 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)){
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])
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{
- if(!(dat.SOURCE_SERIAL.Position[1] === 0) && !(dat.SOURCE_SERIAL.Position[0] === 0)){
- document.getElementById("SERIALlong").innerHTML = "Ublox long: " + 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])
- map.panTo([dat.SOURCE_SERIAL.Position[1], 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])
- }
+ 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)
orientation[0] += dat[0] * multiplier
@@ -164,6 +154,17 @@ window.addEventListener("load", function(evt) {
fetch('http://localhost:3011/trackings/', { method: 'PATCH', body: 'some data'})
.then(results => results.json())
.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;
};
diff --git a/templates/index.html b/templates/index.html
index 5945da9..7748486 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -139,10 +139,9 @@
-
-
+