addDistanceFix

This commit is contained in:
Timo Volkmann 2021-01-15 18:08:33 +01:00
parent 9199977b89
commit 196bbfd05b

View File

@ -115,7 +115,7 @@ window.addEventListener("load", function(evt) {
});
function prepareForDistanceCalc(data) {
if('SOURCE_TCP' in data && data.SOURCE_TCP.length > 0 && 'SOURCE_SERIAL' in data) {
if('SOURCE_TCP' in data && data.SOURCE_TCP.length > 0 && 'SOURCE_SERIAL' in data && data.SOURCE_SERIAL.length > 0) {
let sensorPoints = [];
data.SOURCE_TCP.forEach(element => {
if (element.Position[0] !== 0 && element.Position[1] !== 0) {
@ -123,7 +123,6 @@ function prepareForDistanceCalc(data) {
differenceMs: Number.MAX_VALUE,
tcp: element,
ser: null,
speed: null
})
}
})
@ -151,7 +150,18 @@ function prepareForDistanceCalc(data) {
differenceMs: Number.MAX_VALUE,
tcp: null,
ser: element,
speed: null
})
}
})
return sensorPoints
} else if ('SOURCE_TCP' in data && data.SOURCE_TCP.length > 0) {
let sensorPoints = [];
data.SOURCE_TCP.forEach(element => {
if (element.Position[0] !== 0 && element.Position[1] !== 0) {
sensorPoints.push({
differenceMs: Number.MAX_VALUE,
tcp: element,
ser: null,
})
}
})