diff --git a/static/scripts/refull.js b/static/scripts/refull.js index a89d701..f6da95b 100644 --- a/static/scripts/refull.js +++ b/static/scripts/refull.js @@ -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, }) } })