From 93f6d1f6cd4e76d5c0556ae87b15c2306dc6c813 Mon Sep 17 00:00:00 2001 From: Collin Kidder Date: Mon, 3 May 2021 22:01:47 -0400 Subject: [PATCH] Add DBC signals to frame data analysis window. --- re/frameinfowindow.cpp | 50 ++++++++++++++++++++++++++++++++++++++++-- re/frameinfowindow.h | 2 ++ 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/re/frameinfowindow.cpp b/re/frameinfowindow.cpp index d97b2d9..a62686e 100644 --- a/re/frameinfowindow.cpp +++ b/re/frameinfowindow.cpp @@ -6,8 +6,8 @@ #include #include "filterutility.h" -const QColor FrameInfoWindow::byteGraphColors[8] = {Qt::blue, Qt::green, Qt::black, Qt::red, //0 1 2 3 - Qt::gray, Qt::yellow, Qt::cyan, Qt::darkMagenta}; //4 5 6 7 +const QColor FrameInfoWindow::byteGraphColors[8] = {Qt::blue, Qt::green, Qt::black, Qt::red, //0 1 2 3 + Qt::gray, Qt::yellow, Qt::cyan, Qt::darkMagenta}; //4 5 6 7 QPen FrameInfoWindow::bytePens[8]; const int numIntervalHistBars = 20; @@ -111,6 +111,8 @@ FrameInfoWindow::FrameInfoWindow(const QVector *frames, QWidget *paren bytePens[i].setColor(byteGraphColors[i]); bytePens[i].setWidth(1); } + + dbcHandler = DBCHandler::getReference(); } void FrameInfoWindow::showEvent(QShowEvent* event) @@ -267,6 +269,7 @@ void FrameInfoWindow::updateDetailsWindow(QString newID) QVector histGraphX, histGraphY; QVector byteGraphX, byteGraphY[8]; QVector timeGraphX, timeGraphY; + QHash> signalInstances; double maxY = -1000.0; uint8_t changedBits[8]; uint8_t referenceBits[8]; @@ -378,6 +381,7 @@ void FrameInfoWindow::updateDetailsWindow(QString newID) for (int k = 0; k < 256; k++) dataHistogram[k][i] = 0; } for (int j = 0; j < 64; j++) bitfieldHistogram[j] = 0; + signalInstances.clear(); data = reinterpret_cast(frameCache.at(0).payload().constData()); dataLen = frameCache.at(0).payload().length(); @@ -392,6 +396,8 @@ void FrameInfoWindow::updateDetailsWindow(QString newID) std::vector sortedIntervals; int64_t intervalSum = 0; + DBC_MESSAGE *msg = dbcHandler->findMessageForFilter(targettedID, nullptr); + //then find all data points for (int j = 0; j < frameCache.count(); j++) { @@ -438,6 +444,28 @@ void FrameInfoWindow::updateDetailsWindow(QString newID) } changedBits[c] |= referenceBits[c] ^ dat; } + + //Search every signal in the selected message and give output of the range the signal took and + //how many messages contained each discrete value. + if (msg) + { + int numSignals = msg->sigHandler->getCount(); + for (int i = 0; i < numSignals; i++) + { + DBC_SIGNAL *sig = msg->sigHandler->findSignalByIdx(i); + if (sig) + { + if (sig->isSignalInMessage(frameCache.at(j))) + { + QString sigVal; + if (sig->processAsText(frameCache.at(j), sigVal, false)) + { + signalInstances[sig->name][sigVal] = signalInstances[sig->name][sigVal] + 1; + } + } + } + } + } } std::sort(sortedIntervals.begin(), sortedIntervals.end()); @@ -512,6 +540,8 @@ void FrameInfoWindow::updateDetailsWindow(QString newID) tempItem = new QTreeWidgetItem(); tempItem->setText(0, tr("Minimum range to fit 90% of inter-frame intervals: ") + QString::number((intervalPctl95 - intervalPctl5) / 1000.0) + "ms"); baseNode->addChild(tempItem); + + //display accumulated data for all the bytes in the message for (int c = 0; c < maxLen; c++) { dataBase = new QTreeWidgetItem(); @@ -558,6 +588,22 @@ void FrameInfoWindow::updateDetailsWindow(QString newID) } baseNode->addChild(dataBase); + QHash>::const_iterator it = signalInstances.constBegin(); + while (it != signalInstances.constEnd()) { + dataBase = new QTreeWidgetItem(); + dataBase->setText(0, it.key()); + QHash::const_iterator itVal = signalInstances[it.key()].constBegin(); + while (itVal != signalInstances[it.key()].constEnd()) + { + tempItem = new QTreeWidgetItem(); + tempItem->setText(0, itVal.key() + ": " + QString::number(itVal.value())); + dataBase->addChild(tempItem); + ++itVal; + } + baseNode->addChild(dataBase); + ++it; + } + ui->treeDetails->insertTopLevelItem(0, baseNode); ui->graphHistogram->clearGraphs(); diff --git a/re/frameinfowindow.h b/re/frameinfowindow.h index abf53a8..8600020 100644 --- a/re/frameinfowindow.h +++ b/re/frameinfowindow.h @@ -7,6 +7,7 @@ #include #include "can_structs.h" #include "bus_protocols/j1939_handler.h" +#include "dbc/dbchandler.h" namespace Ui { class FrameInfoWindow; @@ -35,6 +36,7 @@ private: bool useOpenGL; static const QColor byteGraphColors[8]; static QPen bytePens[8]; + DBCHandler *dbcHandler; void refreshIDList(); void closeEvent(QCloseEvent *event);