From 52f8d7941ea71fb26ec2ca79ee7fcba7aceae22f Mon Sep 17 00:00:00 2001 From: Collin Kidder Date: Thu, 8 May 2025 21:48:07 -0400 Subject: [PATCH] Reimplementation and rework of pull request from SebKuzminsky that adds ability to graph floating point values from DBC signals. Credit for this suggestion and initial code goes to him --- config.h | 2 +- re/graphingwindow.cpp | 25 +++++++++++++++++++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/config.h b/config.h index 2b97312..e02ffa6 100644 --- a/config.h +++ b/config.h @@ -1,7 +1,7 @@ #ifndef CONFIG #define CONFIG -#define VERSION 220 +#define VERSION 221 //try to keep this in sync. //SavvyCAN will complain if you connect a GVRET board with a revision diff --git a/re/graphingwindow.cpp b/re/graphingwindow.cpp index 80b32d5..74dcf41 100644 --- a/re/graphingwindow.cpp +++ b/re/graphingwindow.cpp @@ -1251,13 +1251,23 @@ 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 { xVal = (frame.timeStamp().microSeconds() - params.xbias); } - yVal = (tempVal * params.scale) + params.bias; + + //there really is no way to set a graphable item as being stored as a float unless it was an actual DBC signal + //So, if we have a DBC signal associated then use that, otherwise try to turn the above integer calculation into + //a final output by using the scale and bias. + if (params.associatedSignal) + { + //if for some reason the processAsDouble fails we'll fall back on manual approach + if (!params.associatedSignal->processAsDouble(frame, yVal)) yVal = (tempVal * params.scale) + params.bias; + } + else yVal = (tempVal * params.scale) + params.bias; + params.x.append(xVal); params.y.append(yVal); x.append(xVal); @@ -1267,7 +1277,6 @@ void GraphingWindow::appendToGraph(GraphParams ¶ms, CANFrame &frame, QVector QString tempStr; if (params.associatedSignal) { - bool isValid = params.associatedSignal->getValueString(tempVal, tempStr); if (isValid) { @@ -1380,7 +1389,15 @@ void GraphingWindow::createGraph(GraphParams ¶ms, bool createGraphParam) } tempVal = Utility::processIntegerSignal(frameCache[k].payload(), sBit, bits, intelFormat, isSigned); //& params.mask; //qDebug() << tempVal; - y = (tempVal * params.scale) + params.bias; + + if (params.associatedSignal) + { + //if for some reason the processAsDouble fails we'll fall back on manual approach + if (!params.associatedSignal->processAsDouble(frameCache[k], y)) + y = (tempVal * params.scale) + params.bias; + } + else y = (tempVal * params.scale) + params.bias; + params.y.append( y ); if (Utility::timeStyle == TS_SECONDS)