fix error for some records in acc chart
This commit is contained in:
parent
ec11f2541d
commit
6f6da95780
@ -1,5 +1,6 @@
|
|||||||
let allAccSerial = []
|
let allAccSerial = []
|
||||||
let allSerialCoords = []
|
let allSerialCoords = []
|
||||||
|
let allTcpCoords = []
|
||||||
|
|
||||||
var ctx = document.getElementById('accChart').getContext('2d');
|
var ctx = document.getElementById('accChart').getContext('2d');
|
||||||
var accChart = new Chart(ctx, {
|
var accChart = new Chart(ctx, {
|
||||||
@ -48,10 +49,6 @@ var accChart = new Chart(ctx, {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function addSerialHAccData(){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function addDistances(tcpDataList, serialDataList){
|
function addDistances(tcpDataList, serialDataList){
|
||||||
let tcpCoords = []
|
let tcpCoords = []
|
||||||
let serialCoords = []
|
let serialCoords = []
|
||||||
@ -66,12 +63,13 @@ function addDistances(tcpDataList, serialDataList){
|
|||||||
})
|
})
|
||||||
|
|
||||||
tcpDataList.forEach(sensordata => {
|
tcpDataList.forEach(sensordata => {
|
||||||
if (!(sensordata.Position[0] === 0) && !(sensordata.Position[1] === 0)) {
|
if(!(sensordata.Speed === 0) && !(sensordata.HAcc === 0)){
|
||||||
let tcpCoord = [sensordata.Position[1], sensordata.Position[0]]
|
if (!(sensordata.Position[0] === 0) && !(sensordata.Position[1] === 0)) {
|
||||||
tcpCoords.push(tcpCoord)
|
let tcpCoord = [sensordata.Position[1], sensordata.Position[0]]
|
||||||
|
tcpCoords.push(tcpCoord)
|
||||||
let time = sensordata.Servertime
|
let time = sensordata.Timestamp
|
||||||
tcpTimes.push(time)
|
tcpTimes.push(time)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -56,6 +56,7 @@ function addSerialSpeedData() {
|
|||||||
})
|
})
|
||||||
speedChart.data.datasets[0].data = speeds;
|
speedChart.data.datasets[0].data = speeds;
|
||||||
speedChart.update();
|
speedChart.update();
|
||||||
|
console.log("speeds serial " + speeds.length)
|
||||||
}
|
}
|
||||||
|
|
||||||
function addTCPSpeedData(sensordataList) {
|
function addTCPSpeedData(sensordataList) {
|
||||||
@ -72,6 +73,8 @@ function addTCPSpeedData(sensordataList) {
|
|||||||
times.push(time)
|
times.push(time)
|
||||||
|
|
||||||
})
|
})
|
||||||
|
console.log("speeds tcp " + speedsTCP.length)
|
||||||
|
|
||||||
speedChart.data.labels = times;
|
speedChart.data.labels = times;
|
||||||
speedChart.data.datasets[1].data = speedsTCP;
|
speedChart.data.datasets[1].data = speedsTCP;
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
var trackingdata = null;
|
var trackingdata = null;
|
||||||
let indexes
|
let indexes
|
||||||
|
|
||||||
function composeServertime(servertime){
|
function composeTimestamp(servertime){
|
||||||
var composed;
|
var composed;
|
||||||
composed = servertime.slice(11,25).split(':').join("").split('.').join("");
|
composed = servertime.slice(11,25).split(':').join("").split('.').join("");
|
||||||
return composed;
|
return composed;
|
||||||
@ -37,18 +37,19 @@ function findSerialDataIndex(tcpdataList, serialdataList) {
|
|||||||
|
|
||||||
serialdataList.forEach(sensordata => {
|
serialdataList.forEach(sensordata => {
|
||||||
if (!(sensordata.Speed === 0) && !(sensordata.HAcc === 0)) {
|
if (!(sensordata.Speed === 0) && !(sensordata.HAcc === 0)) {
|
||||||
let serialTimestamp;
|
|
||||||
allSpeedsSerial.push(sensordata.Speed)
|
allSpeedsSerial.push(sensordata.Speed)
|
||||||
allAccSerial.push(sensordata.HAcc)
|
allAccSerial.push(sensordata.HAcc)
|
||||||
allSerialCoords.push([sensordata.Position[1], sensordata.Position[0]])
|
if(!(sensordata.Position[1] === 0) && !(sensordata.Position[0] === 0)){
|
||||||
serialTimestamp = composeServertime(sensordata.Servertime)
|
allSerialCoords.push([sensordata.Position[1], sensordata.Position[0]])
|
||||||
|
}
|
||||||
|
let serialTimestamp = composeTimestamp(sensordata.Timestamp)
|
||||||
allSerialTimes.push(serialTimestamp)
|
allSerialTimes.push(serialTimestamp)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
tcpdataList.forEach(sensordata => {
|
tcpdataList.forEach(sensordata => {
|
||||||
if (!(sensordata.Speed === 0)) {
|
if (!(sensordata.Speed === 0) && !(sensordata.HAcc === 0)) {
|
||||||
let tcpTimestamp = composeServertime(sensordata.Servertime)
|
let tcpTimestamp = composeTimestamp(sensordata.Timestamp)
|
||||||
let index = findBestTimeMatch(tcpTimestamp, allSerialTimes)[1]
|
let index = findBestTimeMatch(tcpTimestamp, allSerialTimes)[1]
|
||||||
|
|
||||||
indexes.push(index)
|
indexes.push(index)
|
||||||
@ -107,7 +108,6 @@ window.addEventListener("load", function(evt) {
|
|||||||
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()
|
||||||
addSerialHAccData()
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user