Added signal comparison to the file comparison window. Very poor, slow
proof of concept inplementation - will be improved soon.
This commit is contained in:
@@ -1930,6 +1930,18 @@ DBC_MESSAGE* DBCHandler::findMessage(const CANFrame &frame)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DBC_MESSAGE* DBCHandler::findMessage(uint32_t id)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < loadedFiles.count(); i++)
|
||||||
|
{
|
||||||
|
DBC_MESSAGE* msg = loadedFiles[i].messageHandler->findMsgByID(id);
|
||||||
|
if (msg != nullptr)
|
||||||
|
{
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
// This function won't care which bus the DBC file is associated, but will return any message as long as ID matches and the file
|
// This function won't care which bus the DBC file is associated, but will return any message as long as ID matches and the file
|
||||||
// has filter labeling enabled.
|
// has filter labeling enabled.
|
||||||
|
|||||||
@@ -118,6 +118,7 @@ public:
|
|||||||
void swapFiles(int pos1, int pos2);
|
void swapFiles(int pos1, int pos2);
|
||||||
DBC_MESSAGE* findMessage(const CANFrame &frame);
|
DBC_MESSAGE* findMessage(const CANFrame &frame);
|
||||||
DBC_MESSAGE* findMessage(const QString msgName);
|
DBC_MESSAGE* findMessage(const QString msgName);
|
||||||
|
DBC_MESSAGE* findMessage(uint32_t id);
|
||||||
DBC_MESSAGE* findMessageForFilter(uint32_t id, MatchingCriteria_t * matchingCriteria);
|
DBC_MESSAGE* findMessageForFilter(uint32_t id, MatchingCriteria_t * matchingCriteria);
|
||||||
int getFileCount();
|
int getFileCount();
|
||||||
DBCFile* getFileByIdx(int idx);
|
DBCFile* getFileByIdx(int idx);
|
||||||
|
|||||||
+156
-4
@@ -20,6 +20,8 @@ FileComparatorWindow::FileComparatorWindow(QWidget *parent) :
|
|||||||
ui->lblFirstFile->setText("");
|
ui->lblFirstFile->setText("");
|
||||||
ui->lblRefFrames->setText("Loaded frames: 0");
|
ui->lblRefFrames->setText("Loaded frames: 0");
|
||||||
|
|
||||||
|
dbcHandler = DBCHandler::getReference();
|
||||||
|
|
||||||
installEventFilter(this);
|
installEventFilter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,6 +156,7 @@ void FileComparatorWindow::calculateDetails()
|
|||||||
for (int x = 0; x < interestedFrames.count(); x++)
|
for (int x = 0; x < interestedFrames.count(); x++)
|
||||||
{
|
{
|
||||||
CANFrame frame = interestedFrames.at(x);
|
CANFrame frame = interestedFrames.at(x);
|
||||||
|
DBC_MESSAGE *msg = dbcHandler->findMessage(frame.frameId());
|
||||||
data = reinterpret_cast<const unsigned char *>(frame.payload().constData());
|
data = reinterpret_cast<const unsigned char *>(frame.payload().constData());
|
||||||
dataLen = frame.payload().count();
|
dataLen = frame.payload().count();
|
||||||
|
|
||||||
@@ -167,6 +170,28 @@ void FileComparatorWindow::calculateDetails()
|
|||||||
interestedIDs[frame.frameId()].bitmap |= tmp;
|
interestedIDs[frame.frameId()].bitmap |= tmp;
|
||||||
//qDebug() << "bitmap: " << QString::number(interestedIDs[frame.frameId()].bitmap, 16);
|
//qDebug() << "bitmap: " << QString::number(interestedIDs[frame.frameId()].bitmap, 16);
|
||||||
}
|
}
|
||||||
|
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(frame))
|
||||||
|
{
|
||||||
|
QString sigVal;
|
||||||
|
if (sig->processAsText(frame, sigVal, false))
|
||||||
|
{
|
||||||
|
QList<QString> tempList = interestedIDs[frame.frameId()].signalInstances[sig->name];
|
||||||
|
if (!tempList.contains(sigVal)) tempList.append(sigVal);
|
||||||
|
interestedIDs[frame.frameId()].signalInstances[sig->name] = tempList;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
qApp->processEvents();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else //never seen this ID before so add one
|
else //never seen this ID before so add one
|
||||||
{
|
{
|
||||||
@@ -192,6 +217,28 @@ void FileComparatorWindow::calculateDetails()
|
|||||||
newData->bitmap |= tmp;
|
newData->bitmap |= tmp;
|
||||||
//qDebug() << "bitmap: " << QString::number(newData->bitmap, 16);
|
//qDebug() << "bitmap: " << QString::number(newData->bitmap, 16);
|
||||||
}
|
}
|
||||||
|
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(frame))
|
||||||
|
{
|
||||||
|
QString sigVal;
|
||||||
|
if (sig->processAsText(frame, sigVal, false))
|
||||||
|
{
|
||||||
|
QList<QString> tempList;
|
||||||
|
tempList.append(sigVal);
|
||||||
|
newData->signalInstances[sig->name] = tempList;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
interestedIDs.insert(frame.frameId(), *newData);
|
interestedIDs.insert(frame.frameId(), *newData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -201,6 +248,7 @@ void FileComparatorWindow::calculateDetails()
|
|||||||
for (int x = 0; x < referenceFrames.count(); x++)
|
for (int x = 0; x < referenceFrames.count(); x++)
|
||||||
{
|
{
|
||||||
CANFrame frame = referenceFrames.at(x);
|
CANFrame frame = referenceFrames.at(x);
|
||||||
|
DBC_MESSAGE *msg = dbcHandler->findMessage(frame.frameId());
|
||||||
data = reinterpret_cast<const unsigned char *>(frame.payload().constData());
|
data = reinterpret_cast<const unsigned char *>(frame.payload().constData());
|
||||||
dataLen = frame.payload().count();
|
dataLen = frame.payload().count();
|
||||||
|
|
||||||
@@ -214,6 +262,27 @@ void FileComparatorWindow::calculateDetails()
|
|||||||
referenceIDs[frame.frameId()].bitmap |= tmp;
|
referenceIDs[frame.frameId()].bitmap |= tmp;
|
||||||
//qDebug() << "bitmap: " << QString::number(referenceIDs[frame.frameId()].bitmap, 16);
|
//qDebug() << "bitmap: " << QString::number(referenceIDs[frame.frameId()].bitmap, 16);
|
||||||
}
|
}
|
||||||
|
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(frame))
|
||||||
|
{
|
||||||
|
QString sigVal;
|
||||||
|
if (sig->processAsText(frame, sigVal, false))
|
||||||
|
{
|
||||||
|
QList<QString> tempList = referenceIDs[frame.frameId()].signalInstances[sig->name];
|
||||||
|
if (!tempList.contains(sigVal)) tempList.append(sigVal);
|
||||||
|
referenceIDs[frame.frameId()].signalInstances[sig->name] = tempList;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else //never seen this ID before so add one
|
else //never seen this ID before so add one
|
||||||
{
|
{
|
||||||
@@ -237,6 +306,27 @@ void FileComparatorWindow::calculateDetails()
|
|||||||
newData->bitmap |= tmp;
|
newData->bitmap |= tmp;
|
||||||
//qDebug() << "bitmap: " << QString::number(newData->bitmap, 16);
|
//qDebug() << "bitmap: " << QString::number(newData->bitmap, 16);
|
||||||
}
|
}
|
||||||
|
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(frame))
|
||||||
|
{
|
||||||
|
QString sigVal;
|
||||||
|
if (sig->processAsText(frame, sigVal, false))
|
||||||
|
{
|
||||||
|
QList<QString> tempList;
|
||||||
|
tempList.append(sigVal);
|
||||||
|
newData->signalInstances[sig->name] = tempList;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
referenceIDs.insert(frame.frameId(), *newData);
|
referenceIDs.insert(frame.frameId(), *newData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -251,7 +341,7 @@ void FileComparatorWindow::calculateDetails()
|
|||||||
for (i = interestedIDs.begin(); i != interestedIDs.end(); ++i)
|
for (i = interestedIDs.begin(); i != interestedIDs.end(); ++i)
|
||||||
{
|
{
|
||||||
framesCounter++;
|
framesCounter++;
|
||||||
if (framesCounter > 10000)
|
if (framesCounter > 50)
|
||||||
{
|
{
|
||||||
framesCounter = 0;
|
framesCounter = 0;
|
||||||
qApp->processEvents();
|
qApp->processEvents();
|
||||||
@@ -261,14 +351,24 @@ void FileComparatorWindow::calculateDetails()
|
|||||||
if (!referenceIDs.contains(keyone))
|
if (!referenceIDs.contains(keyone))
|
||||||
{
|
{
|
||||||
valuesBase = new QTreeWidgetItem();
|
valuesBase = new QTreeWidgetItem();
|
||||||
valuesBase->setText(0, Utility::formatHexNum(keyone));
|
DBC_MESSAGE *msg = dbcHandler->findMessage(keyone);
|
||||||
|
if (msg)
|
||||||
|
{
|
||||||
|
valuesBase->setText(0, Utility::formatHexNum(keyone) + " (" + msg->name + ")");
|
||||||
|
}
|
||||||
|
else valuesBase->setText(0, Utility::formatHexNum(keyone));
|
||||||
interestedOnlyBase->addChild(valuesBase);
|
interestedOnlyBase->addChild(valuesBase);
|
||||||
}
|
}
|
||||||
else //ID was in both files
|
else //ID was in both files
|
||||||
{
|
{
|
||||||
interestedHadUnique = false;
|
interestedHadUnique = false;
|
||||||
sharedItem = new QTreeWidgetItem();
|
sharedItem = new QTreeWidgetItem();
|
||||||
sharedItem->setText(0, Utility::formatHexNum(keyone));
|
DBC_MESSAGE *msg = dbcHandler->findMessage(keyone);
|
||||||
|
if (msg)
|
||||||
|
{
|
||||||
|
sharedItem->setText(0, Utility::formatHexNum(keyone) + " (" + msg->name + ")");
|
||||||
|
}
|
||||||
|
else sharedItem->setText(0, Utility::formatHexNum(keyone));
|
||||||
//if the ID was in both files then we can use the data accumulated above in bitmap
|
//if the ID was in both files then we can use the data accumulated above in bitmap
|
||||||
//and values to figure out what has changed between the two files
|
//and values to figure out what has changed between the two files
|
||||||
|
|
||||||
@@ -336,6 +436,53 @@ void FileComparatorWindow::calculateDetails()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//presumably both include the same signals so for this first attempt just
|
||||||
|
//take all signals from the reference and then find that same signal in
|
||||||
|
//the interested frames and then see what unique values there were in either one
|
||||||
|
|
||||||
|
QHash<QString, QList<QString>>::const_iterator it = reference.signalInstances.constBegin();
|
||||||
|
while (it != reference.signalInstances.constEnd())
|
||||||
|
{
|
||||||
|
valuesBase = new QTreeWidgetItem();
|
||||||
|
valuesBase->setText(0, "Signal " + it.key());
|
||||||
|
sharedItem->addChild(valuesBase);
|
||||||
|
valuesInterested = new QTreeWidgetItem();
|
||||||
|
valuesInterested->setText(0, "Values found only in " + interestedFilename);
|
||||||
|
if (!uniqueInterested)
|
||||||
|
{
|
||||||
|
valuesReference = new QTreeWidgetItem();
|
||||||
|
valuesReference->setText(0, "Values found only in Side 2 - Reference frames");
|
||||||
|
}
|
||||||
|
valuesBase->addChild(valuesInterested);
|
||||||
|
if (!uniqueInterested) valuesBase->addChild(valuesReference);
|
||||||
|
|
||||||
|
QList<QString> refVals = it.value();
|
||||||
|
QList<QString> interestedVals = interested.signalInstances[it.key()];
|
||||||
|
foreach (QString str, refVals)
|
||||||
|
{
|
||||||
|
if (!interestedVals.contains(str))
|
||||||
|
{
|
||||||
|
qDebug() << "Interested frames didn't contain value: " << str << " in signal " << it.key();
|
||||||
|
detail = new QTreeWidgetItem();
|
||||||
|
detail->setText(0, str);
|
||||||
|
valuesReference->addChild(detail);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
qApp->processEvents();
|
||||||
|
foreach (QString str, interestedVals)
|
||||||
|
{
|
||||||
|
if (!refVals.contains(str))
|
||||||
|
{
|
||||||
|
qDebug() << "Reference frames didn't contain value: " << str << " in signal " << it.key();
|
||||||
|
detail = new QTreeWidgetItem();
|
||||||
|
detail->setText(0, str);
|
||||||
|
valuesInterested->addChild(detail);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
|
||||||
if (interestedHadUnique || !uniqueInterested) sharedBase->addChild(sharedItem);
|
if (interestedHadUnique || !uniqueInterested) sharedBase->addChild(sharedItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -351,7 +498,12 @@ void FileComparatorWindow::calculateDetails()
|
|||||||
if (!interestedIDs.contains(keytwo))
|
if (!interestedIDs.contains(keytwo))
|
||||||
{
|
{
|
||||||
valuesBase = new QTreeWidgetItem();
|
valuesBase = new QTreeWidgetItem();
|
||||||
valuesBase->setText(0, Utility::formatHexNum(keytwo));
|
DBC_MESSAGE *msg = dbcHandler->findMessage(keytwo);
|
||||||
|
if (msg)
|
||||||
|
{
|
||||||
|
valuesBase->setText(0, Utility::formatHexNum(keytwo) + " (" + msg->name + ")" );
|
||||||
|
}
|
||||||
|
else valuesBase->setText(0, Utility::formatHexNum(keytwo));
|
||||||
referenceOnlyBase->addChild(valuesBase);
|
referenceOnlyBase->addChild(valuesBase);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "framefileio.h"
|
#include "framefileio.h"
|
||||||
#include "can_structs.h"
|
#include "can_structs.h"
|
||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
|
#include "dbc/dbchandler.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class FileComparatorWindow;
|
class FileComparatorWindow;
|
||||||
@@ -18,6 +19,7 @@ struct FrameData
|
|||||||
int dataLen;
|
int dataLen;
|
||||||
uint64_t bitmap;
|
uint64_t bitmap;
|
||||||
int values[8][256]; //first index is the data byte, second is # of times we saw that value
|
int values[8][256]; //first index is the data byte, second is # of times we saw that value
|
||||||
|
QHash<QString, QList<QString>> signalInstances;
|
||||||
};
|
};
|
||||||
|
|
||||||
class FileComparatorWindow : public QDialog
|
class FileComparatorWindow : public QDialog
|
||||||
@@ -39,6 +41,7 @@ private:
|
|||||||
QVector<CANFrame> interestedFrames;
|
QVector<CANFrame> interestedFrames;
|
||||||
QVector<CANFrame> referenceFrames;
|
QVector<CANFrame> referenceFrames;
|
||||||
QString interestedFilename;
|
QString interestedFilename;
|
||||||
|
DBCHandler *dbcHandler;
|
||||||
|
|
||||||
void calculateDetails();
|
void calculateDetails();
|
||||||
void showEvent(QShowEvent *);
|
void showEvent(QShowEvent *);
|
||||||
|
|||||||
@@ -1007,7 +1007,7 @@ void GraphingWindow::loadDefinitions()
|
|||||||
}
|
}
|
||||||
if (tokens.length() > 21)
|
if (tokens.length() > 21)
|
||||||
{
|
{
|
||||||
DBC_MESSAGE *msg = dbcHandler->findMessage(tokens[20]);
|
DBC_MESSAGE *msg = dbcHandler->findMessage(QString(tokens[20]));
|
||||||
if (msg)
|
if (msg)
|
||||||
{
|
{
|
||||||
gp.associatedSignal = msg->sigHandler->findSignalByName(tokens[21]);
|
gp.associatedSignal = msg->sigHandler->findSignalByName(tokens[21]);
|
||||||
|
|||||||
Reference in New Issue
Block a user