From 079c242bfec565882423898bc21f4cc04bba95c7 Mon Sep 17 00:00:00 2001 From: Sebastian Kuzminsky Date: Thu, 16 May 2024 15:19:50 -0600 Subject: [PATCH 1/4] fix endianness in DBC_SIGNAL::processAsDouble() --- dbc/dbc_classes.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dbc/dbc_classes.cpp b/dbc/dbc_classes.cpp index da44f804..cd795b0d 100644 --- a/dbc/dbc_classes.cpp +++ b/dbc/dbc_classes.cpp @@ -300,7 +300,7 @@ bool DBC_SIGNAL::processAsDouble(const CANFrame &frame, double &outValue) //that the bytes that make up the integer are instead treated as having made up //a 32 bit single precision float. That's evil incarnate but it is very fast and small //in terms of new code. - result = Utility::processIntegerSignal(frame.payload(), startBit, 32, false, false); + result = Utility::processIntegerSignal(frame.payload(), startBit, 32, intelByteOrder, false); endResult = (*((float *)(&result)) * factor) + bias; } else //double precision float @@ -312,7 +312,7 @@ bool DBC_SIGNAL::processAsDouble(const CANFrame &frame, double &outValue) } //like the above, this is rotten and evil and wrong in so many ways. Force //calculation of a 64 bit integer and then cast it into a double. - result = Utility::processIntegerSignal(frame.payload(), startBit, 64, false, false); + result = Utility::processIntegerSignal(frame.payload(), startBit, 64, intelByteOrder, false); endResult = (*((double *)(&result)) * factor) + bias; } cachedValue = endResult; From 557f5619e071e364d4a136a3acb339ad520f91ad Mon Sep 17 00:00:00 2001 From: Sebastian Kuzminsky Date: Thu, 16 May 2024 15:19:51 -0600 Subject: [PATCH 2/4] GraphingWindow: fix graphing of floats --- re/graphingwindow.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/re/graphingwindow.cpp b/re/graphingwindow.cpp index 80b32d5a..b7436da8 100644 --- a/re/graphingwindow.cpp +++ b/re/graphingwindow.cpp @@ -1241,9 +1241,18 @@ void GraphingWindow::appendToGraph(GraphParams ¶ms, CANFrame &frame, QVector if (params.strideSoFar >= params.stride) { params.strideSoFar = 0; - int64_t tempVal; //64 bit temp value. - tempVal = Utility::processIntegerSignal(frame.payload(), params.startBit, params.numBits, params.intelFormat, params.isSigned); //& params.mask; + DBC_SIGNAL * sig = params.associatedSignal; double xVal, yVal; + + if (sig == NULL) { + return; + } + if (!sig->processAsDouble(frame, yVal)) { + return; + } + params.y.append(yVal); + y.append(yVal); + if (Utility::timeStyle == TS_SECONDS) { xVal = ((double)(frame.timeStamp().microSeconds()) / 1000000.0 - params.xbias); @@ -1257,18 +1266,15 @@ void GraphingWindow::appendToGraph(GraphParams ¶ms, CANFrame &frame, QVector { xVal = (frame.timeStamp().microSeconds() - params.xbias); } - yVal = (tempVal * params.scale) + params.bias; params.x.append(xVal); - params.y.append(yVal); x.append(xVal); - y.append(yVal); //now see if we've got to do anything with the brackets and labels for value table stuff QString tempStr; if (params.associatedSignal) { - bool isValid = params.associatedSignal->getValueString(tempVal, tempStr); + bool isValid = params.associatedSignal->getValueString(yVal, tempStr); if (isValid) { //we have a graph with associated signal and we could interpret it. So, see what we need to do @@ -1287,7 +1293,7 @@ void GraphingWindow::appendToGraph(GraphParams ¶ms, CANFrame &frame, QVector } else //wasn't the same so complete the previous span and start a new one. { - params.prevValTable = tempVal; + params.prevValTable = yVal; params.prevValLocation = QPointF(xVal, yVal); params.prevValStr = tempStr; From 89fa0f08770a5265c9f4e22b68e3cdcf27cbf2fd Mon Sep 17 00:00:00 2001 From: Sebastian Kuzminsky Date: Thu, 16 May 2024 15:19:52 -0600 Subject: [PATCH 3/4] GraphingWindow: load floats from frame cache --- re/graphingwindow.cpp | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/re/graphingwindow.cpp b/re/graphingwindow.cpp index b7436da8..bc94648f 100644 --- a/re/graphingwindow.cpp +++ b/re/graphingwindow.cpp @@ -1321,7 +1321,6 @@ void GraphingWindow::appendToGraph(GraphParams ¶ms, CANFrame &frame, QVector void GraphingWindow::createGraph(GraphParams ¶ms, bool createGraphParam) { - int64_t tempVal; //64 bit temp value. double yminval=10000000.0, ymaxval = -1000000.0; double xminval=10000000000.0, xmaxval = -10000000000.0; GraphParams *refParam = ¶ms; @@ -1374,20 +1373,19 @@ void GraphingWindow::createGraph(GraphParams ¶ms, bool createGraphParam) for (int j = 0; j < numEntries; j++) { int k = j * params.stride; - if (params.associatedSignal) + if (!params.associatedSignal) { + continue; + } + //skip all the rest of the stuff in this loop and don't add this to the graph if this signal isn't in this frame + if (!params.associatedSignal->isSignalInMessage(frameCache[k])) { - //skip all the rest of the stuff in this loop and don't add this to the graph if this signal isn't in this frame - if (!params.associatedSignal->isSignalInMessage(frameCache[k])) - { - qDebug() << "Signal was not in this frame"; - continue; - } - else qDebug() << "Signal in the frame!"; + qDebug() << "Signal was not in this frame"; + continue; + } + if (!params.associatedSignal->processAsDouble(frameCache[k], y)) { + continue; } - tempVal = Utility::processIntegerSignal(frameCache[k].payload(), sBit, bits, intelFormat, isSigned); //& params.mask; - //qDebug() << tempVal; - y = (tempVal * params.scale) + params.bias; - params.y.append( y ); + params.y.append(y); if (Utility::timeStyle == TS_SECONDS) { @@ -1405,10 +1403,10 @@ void GraphingWindow::createGraph(GraphParams ¶ms, bool createGraphParam) params.x.append( x ); - if (params.associatedSignal && numEntries > 1) + if (numEntries > 1) { - bool isValid = params.associatedSignal->getValueString(tempVal, tempStr); + bool isValid = params.associatedSignal->getValueString(y, tempStr); if (isValid) { if (params.prevValLocation == QPointF(0,0)) { @@ -1416,7 +1414,7 @@ void GraphingWindow::createGraph(GraphParams ¶ms, bool createGraphParam) params.prevValStr = tempStr; params.prevValTable = 0; } - if (tempVal != params.prevValTable) + if (y != params.prevValTable) { qDebug() << "New Value: " << tempStr; @@ -1444,7 +1442,7 @@ void GraphingWindow::createGraph(GraphParams ¶ms, bool createGraphParam) params.prevValStr = tempStr; params.lastBracket = bracket; } - params.prevValTable = tempVal; + params.prevValTable = y; } } @@ -1470,7 +1468,7 @@ void GraphingWindow::createGraph(GraphParams ¶ms, bool createGraphParam) valueText->setFont(QFont(font().family(), 10)); params.prevValLocation = QPointF(x, y); params.prevValStr = tempStr; - params.prevValTable = tempVal; + params.prevValTable = y; params.lastBracket = bracket; } From 0dfc6b6cff1ad76e339213900873a14f9a6f0d6c Mon Sep 17 00:00:00 2001 From: Sebastian Kuzminsky Date: Thu, 16 May 2024 15:31:38 -0600 Subject: [PATCH 4/4] GraphingWindow: show millisecond resolution time when graphing --- re/graphingwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/re/graphingwindow.cpp b/re/graphingwindow.cpp index bc94648f..c3c9d33a 100644 --- a/re/graphingwindow.cpp +++ b/re/graphingwindow.cpp @@ -1260,7 +1260,7 @@ void GraphingWindow::appendToGraph(GraphParams ¶ms, CANFrame &frame, QVector else if (Utility::timeStyle == TS_CLOCK) { QDateTime dt = QDateTime::fromMSecsSinceEpoch((frame.timeStamp().microSeconds() / 1000) - params.xbias); - xVal = (dt.time().second() + dt.time().minute() * 60 + dt.time().hour() * 3600); + xVal = (dt.time().msec()/1000.0 + dt.time().second() + dt.time().minute() * 60 + dt.time().hour() * 3600); } else {