cabana: fix issue where graphData relTime did not correspond to message entry relTime
parent
8a80b613e6
commit
db1885fcdb
|
@ -6,13 +6,13 @@ import Signal from '../../models/can/signal';
|
|||
import DBC from '../../models/can/dbc';
|
||||
import DbcUtils from '../../utils/dbc';
|
||||
|
||||
function appendMockGraphData(existingGraphData) {
|
||||
function appendMockGraphData(existingGraphData, entryCount = 1) {
|
||||
const dbc = new DBC();
|
||||
const signal = new Signal({name: 'NEW_SIGNAL_1'});
|
||||
dbc.setSignals(0, {[signal.name]: signal});
|
||||
const message = DbcUtils.createMessageSpec(dbc, 0, '0', 0);
|
||||
// time, relTime, data, byteStateChangeTimes) {
|
||||
message.entries = [DbcUtils.createMessageEntry(dbc, 0, 0, 0, Buffer.alloc(8), [])];
|
||||
message.entries = Array(entryCount).fill(DbcUtils.createMessageEntry(dbc, 0, 0, 0, Buffer.alloc(8), []));
|
||||
const messages = {[message.id]: message};
|
||||
|
||||
const plottedSignals = [[{signalName: 'NEW_SIGNAL_1', messageId: '0'}]];
|
||||
|
|
|
@ -13,11 +13,13 @@ function _calcGraphData(msg, signalName, firstCanTime) {
|
|||
for(let i = 0; i < msg.entries.length; i += skip) {
|
||||
samples.push(msg.entries[i]);
|
||||
}
|
||||
// Always include last message entry, which faciliates graphData comparison
|
||||
samples.push(msg.entries[msg.entries.length - 1]);
|
||||
}
|
||||
return samples.filter((e) => e.signals[signalName] !== undefined)
|
||||
.map((entry) => {
|
||||
return {x: entry.time,
|
||||
relTime: entry.time - firstCanTime,
|
||||
relTime: entry.relTime,
|
||||
y: entry.signals[signalName],
|
||||
unit: msg.frame.signals[signalName].unit,
|
||||
color: `rgba(${msg.frame.signals[signalName].colors().join(",")}, 0.5)`,
|
||||
|
@ -42,6 +44,7 @@ function appendNewGraphData(plottedSignals, graphData, messages, firstCanTime) {
|
|||
if(graphData[index].length > 0) {
|
||||
maxGraphTime = graphData[index][graphData[index].length - 1].relTime;
|
||||
}
|
||||
|
||||
return plottedMessageIds.some((messageId) =>
|
||||
(messages[messageId].entries.length > 0 && graphData[index].length === 0)
|
||||
||
|
||||
|
|
Loading…
Reference in New Issue