From 1844695a783642e967c4014cc528a97b1f0dd7b6 Mon Sep 17 00:00:00 2001 From: Collin Kidder Date: Sat, 1 May 2021 09:39:02 -0400 Subject: [PATCH] Added DBC signal value table strings to graphs of signals with value tables, incremented version number. --- config.h | 2 +- dbc/dbc_classes.cpp | 16 ++++++++++++++++ dbc/dbc_classes.h | 1 + re/graphingwindow.cpp | 32 +++++++++++++++++++++++++++++++- 4 files changed, 49 insertions(+), 2 deletions(-) diff --git a/config.h b/config.h index 9822598..5018e48 100644 --- a/config.h +++ b/config.h @@ -1,7 +1,7 @@ #ifndef CONFIG #define CONFIG -#define VERSION 203 +#define VERSION 204 //try to keep this in sync. //SavvyCAN will complain if you connect a GVRET board with a revision diff --git a/dbc/dbc_classes.cpp b/dbc/dbc_classes.cpp index b7840a2..96c21f6 100644 --- a/dbc/dbc_classes.cpp +++ b/dbc/dbc_classes.cpp @@ -180,6 +180,22 @@ bool DBC_SIGNAL::processAsText(const CANFrame &frame, QString &outString, bool o return true; } +bool DBC_SIGNAL::getValueString(int64_t intVal, QString &outString) +{ + if (valList.count() > 0) //if this is a value list type then look it up and display the proper string + { + for (int x = 0; x < valList.count(); x++) + { + if (valList.at(x).value == intVal) + { + outString = valList.at(x).descript; + return true; + } + } + } + return false; +} + QString DBC_SIGNAL::makePrettyOutput(double floatVal, int64_t intVal, bool outputName, bool isInteger) { QString outputString; diff --git a/dbc/dbc_classes.h b/dbc/dbc_classes.h index acb1f95..3e090cf 100644 --- a/dbc/dbc_classes.h +++ b/dbc/dbc_classes.h @@ -115,6 +115,7 @@ public: //TODO: this is sloppy. It shouldn't all be public! bool processAsText(const CANFrame &frame, QString &outString, bool outputName = true); bool processAsInt(const CANFrame &frame, int32_t &outValue); bool processAsDouble(const CANFrame &frame, double &outValue); + bool getValueString(int64_t intVal, QString &outString); QString makePrettyOutput(double floatVal, int64_t intVal, bool outputName = true, bool isInteger = false); QString processSignalTree(const CANFrame &frame); DBC_ATTRIBUTE_VALUE *findAttrValByName(QString name); diff --git a/re/graphingwindow.cpp b/re/graphingwindow.cpp index 8cd1a84..000fa56 100644 --- a/re/graphingwindow.cpp +++ b/re/graphingwindow.cpp @@ -1167,6 +1167,7 @@ void GraphingWindow::createGraph(GraphParams ¶ms, bool createGraphParam) GraphParams *refParam = ¶ms; int sBit, bits; bool intelFormat, isSigned; + int64_t prevValu = 9999999999; qDebug() << "New Graph ID: " << params.ID; qDebug() << "Start bit: " << params.startBit; @@ -1213,6 +1214,8 @@ void GraphingWindow::createGraph(GraphParams ¶ms, bool createGraphParam) int k = j * params.stride; tempVal = Utility::processIntegerSignal(frameCache[k].payload(), sBit, bits, intelFormat, isSigned); //& params.mask; //qDebug() << tempVal; + params.y[j] = (tempVal * params.scale) + params.bias; + if (secondsMode) { params.x[j] = (frameCache[k].timeStamp().microSeconds()) / 1000000.0; @@ -1221,7 +1224,34 @@ void GraphingWindow::createGraph(GraphParams ¶ms, bool createGraphParam) { params.x[j] = frameCache[k].timeStamp().microSeconds(); } - params.y[j] = (tempVal * params.scale) + params.bias; + + if (params.associatedSignal) + { + QString tempStr; + bool isValid = params.associatedSignal->getValueString(tempVal, tempStr); + if (isValid) + { + if (tempVal != prevValu) + { + qDebug() << "New Value: " << tempStr; + // add the bracket at the top: + //QCPItemBracket *bracket = new QCPItemBracket(ui->graphingView); + //bracket->left->setCoords(-8, 1.1); + //bracket->right->setCoords(8, 1.1); + //bracket->setLength(13); + + // add the text label at the top: + QCPItemText *wavePacketText = new QCPItemText(ui->graphingView); + //wavePacketText->position->setParentAnchor(bracket->center); + wavePacketText->position->setCoords(params.x[j], params.y[j]); // move 10 pixels to the top from bracket center anchor + wavePacketText->setPositionAlignment(Qt::AlignBottom|Qt::AlignHCenter); + wavePacketText->setText(tempStr); + wavePacketText->setFont(QFont(font().family(), 10)); + } + prevValu = tempVal; + } + } + if (params.y[j] < yminval) yminval = params.y[j]; if (params.y[j] > ymaxval) ymaxval = params.y[j]; if (params.x[j] < xminval) xminval = params.x[j];