fix no serial data error on tracking analysis page
This commit is contained in:
parent
32bb0e7785
commit
b303568a0f
@ -97,16 +97,18 @@ window.addEventListener("load", function(evt) {
|
|||||||
}).then(r => {
|
}).then(r => {
|
||||||
// console.log(r.data.Data)
|
// console.log(r.data.Data)
|
||||||
// console.log(r.data)
|
// console.log(r.data)
|
||||||
|
if(r.data.Data.SOURCE_SERIAL > 0 && r.data.Data.SOURCE_TCP > 0) {
|
||||||
findSerialDataIndex(r.data.Data.SOURCE_TCP, r.data.Data.SOURCE_SERIAL)
|
findSerialDataIndex(r.data.Data.SOURCE_TCP, r.data.Data.SOURCE_SERIAL)
|
||||||
|
}
|
||||||
if ('SOURCE_TCP' in r.data.Data && r.data.Data.SOURCE_TCP.length > 0) {
|
if ('SOURCE_TCP' in r.data.Data && r.data.Data.SOURCE_TCP.length > 0) {
|
||||||
updateMapTCPbulk(r.data.Data.SOURCE_TCP)
|
updateMapTCPbulk(r.data.Data.SOURCE_TCP)
|
||||||
addTCPSpeedData(r.data.Data.SOURCE_TCP)
|
addTCPSpeedData(r.data.Data.SOURCE_TCP)
|
||||||
}
|
}
|
||||||
if ('SOURCE_SERIAL' in r.data.Data && r.data.Data.SOURCE_SERIAL.length > 0) {
|
if ('SOURCE_SERIAL' in r.data.Data && r.data.Data.SOURCE_SERIAL.length > 0) {
|
||||||
updateMapSERIALbulk(r.data.Data.SOURCE_SERIAL)
|
updateMapSERIALbulk(r.data.Data.SOURCE_SERIAL)
|
||||||
addSerialSpeedData()
|
addSerialSpeedData(r.data.Data.SOURCE_SERIAL)
|
||||||
}
|
}
|
||||||
|
|
||||||
addDistances(prepareForDistanceCalc(r.data.Data))
|
addDistances(prepareForDistanceCalc(r.data.Data))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -63,14 +63,31 @@ let speedChart = new Chart(ctx, {
|
|||||||
* As there is less smartphone data collected, we only want the Ublox speeds that come in at the moment with the
|
* As there is less smartphone data collected, we only want the Ublox speeds that come in at the moment with the
|
||||||
* smallest time difference between the TCP message and the Serial message.
|
* smallest time difference between the TCP message and the Serial message.
|
||||||
*/
|
*/
|
||||||
function addSerialSpeedData() {
|
function addSerialSpeedData(sensordataList) {
|
||||||
let speeds = []
|
let speedsSerial = []
|
||||||
|
let times = []
|
||||||
|
|
||||||
|
if(indexes.length > 0){
|
||||||
indexes.forEach(index => {
|
indexes.forEach(index => {
|
||||||
speeds.push((allSpeedsSerial[index] * 3.6).toFixed(2))
|
speedsSerial.push((allSpeedsSerial[index] * 3.6).toFixed(2))
|
||||||
})
|
})
|
||||||
speedChart.data.datasets[0].data = speeds;
|
speedChart.data.datasets[0].data = speedsSerial;
|
||||||
speedChart.update();
|
speedChart.update();
|
||||||
|
} else {
|
||||||
|
sensordataList.forEach(sensordata => {
|
||||||
|
if (sensordata.Speed === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let speed = sensordata.Speed
|
||||||
|
speedsSerial.push((speed * 3.6).toFixed(2));
|
||||||
|
let time = sensordata.Timestamp
|
||||||
|
times.push(time)
|
||||||
|
|
||||||
|
})
|
||||||
|
speedChart.data.labels = times;
|
||||||
|
speedChart.data.datasets[0].data = speedsSerial;
|
||||||
|
speedChart.update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -88,7 +105,7 @@ function addTCPSpeedData(sensordataList) {
|
|||||||
}
|
}
|
||||||
let speed = sensordata.Speed
|
let speed = sensordata.Speed
|
||||||
speedsTCP.push((speed * 3.6).toFixed(2));
|
speedsTCP.push((speed * 3.6).toFixed(2));
|
||||||
let time = sensordata.Servertime
|
let time = sensordata.Timestamp
|
||||||
times.push(time)
|
times.push(time)
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user