Added fully qualified dbc, node, and msg searching
...to graphing window and signal viewer so complex systems with message name duplication (eg "Status") works well. DBCHandler class has a new function to find a msg by fully qualified node name...Utility class defines the qualified name seperator, right now it is :: and is used thusly filenameNoExtension::nodeName for display in the node dropdown (because nodes can be common between dbc files). To get the message from the system you use the findMessage function in dbchandler and pass the msgName and the fully qualified node name. This is about as unique as we can get, second only to message ID. Added node comboBox to graph signal editor for easier data filtering (took the same implementation that was in signal viewer, and tuned up both of them)
This commit is contained in:
+145
-38
@@ -43,6 +43,7 @@ NewGraphDialog::NewGraphDialog(DBCHandler *handler, QWidget *parent) :
|
||||
ui->coPointStyle->addItem("Plus Inside Circle");
|
||||
ui->coPointStyle->addItem("Peace Sign");
|
||||
|
||||
connect(ui->cbNodes, SIGNAL(currentIndexChanged(int)), this, SLOT(loadMessages(int)));
|
||||
connect(ui->cbMessages, SIGNAL(currentIndexChanged(int)), this, SLOT(loadSignals(int)));
|
||||
connect(ui->gridData, SIGNAL(gridClicked(int)), this, SLOT(bitfieldClicked(int)));
|
||||
connect(ui->txtDataLen, SIGNAL(textChanged(QString)), this, SLOT(handleDataLenUpdate()));
|
||||
@@ -54,7 +55,7 @@ NewGraphDialog::NewGraphDialog(DBCHandler *handler, QWidget *parent) :
|
||||
dataLen = 1;
|
||||
assocSignal = nullptr;
|
||||
|
||||
loadMessages();
|
||||
loadNodes();
|
||||
|
||||
installEventFilter(this);
|
||||
}
|
||||
@@ -68,7 +69,8 @@ NewGraphDialog::~NewGraphDialog()
|
||||
void NewGraphDialog::showEvent(QShowEvent* event)
|
||||
{
|
||||
QDialog::showEvent(event);
|
||||
loadMessages();
|
||||
if(shownFromPlotEdit == false)
|
||||
loadNodes();
|
||||
drawBitfield();
|
||||
qDebug() << "S" << ui->gridData->geometry();
|
||||
}
|
||||
@@ -124,9 +126,11 @@ void NewGraphDialog::checkSignalAgreement()
|
||||
DBC_MESSAGE *msg = nullptr;
|
||||
|
||||
if (dbcHandler == nullptr) return;
|
||||
if (dbcHandler->getFileCount() == 0) return;
|
||||
if (dbcHandler->getFileCount() == 0) return;
|
||||
|
||||
msg = dbcHandler->findMessage(ui->cbMessages->currentText());
|
||||
QString fullyQualifiedNodeName = ui->cbNodes->itemText(ui->cbNodes->currentIndex());
|
||||
QString msgName = ui->cbMessages->currentText();
|
||||
msg = dbcHandler->findMessage(msgName, fullyQualifiedNodeName);
|
||||
if (msg)
|
||||
{
|
||||
sig = msg->sigHandler->findSignalByName(ui->cbSignals->currentText());
|
||||
@@ -149,13 +153,20 @@ void NewGraphDialog::checkSignalAgreement()
|
||||
testingParams.startBit = startBit;
|
||||
testingParams.numBits = dataLen;
|
||||
|
||||
if (testingParams.ID != msg->ID) bAgree = false;
|
||||
if (fabs(testingParams.bias - sig->bias) > 0.01) bAgree = false;
|
||||
if (testingParams.isSigned != sigSigned) bAgree = false;
|
||||
if (testingParams.intelFormat != sig->intelByteOrder) bAgree = false;
|
||||
if (fabs(testingParams.scale - sig->factor) > 0.01) bAgree = false;
|
||||
if (testingParams.startBit != sig->startBit) bAgree = false;
|
||||
if (testingParams.numBits != sig->signalSize) bAgree = false;
|
||||
if (testingParams.ID != msg->ID)
|
||||
bAgree = false;
|
||||
if (fabs(testingParams.bias - sig->bias) > 0.01)
|
||||
bAgree = false;
|
||||
if (testingParams.isSigned != sigSigned)
|
||||
bAgree = false;
|
||||
if (testingParams.intelFormat != sig->intelByteOrder)
|
||||
bAgree = false;
|
||||
if (fabs(testingParams.scale - sig->factor) > 0.01)
|
||||
bAgree = false;
|
||||
if (testingParams.startBit != sig->startBit)
|
||||
bAgree = false;
|
||||
if (testingParams.numBits != sig->signalSize)
|
||||
bAgree = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -187,6 +198,8 @@ void NewGraphDialog::clearParams()
|
||||
|
||||
void NewGraphDialog::setParams(GraphParams ¶ms)
|
||||
{
|
||||
shownFromPlotEdit = true;
|
||||
|
||||
ui->txtBias->setText(QString::number(params.bias));
|
||||
ui->txtMask->setText(Utility::formatNumber(params.mask));
|
||||
ui->txtScale->setText(QString::number(params.scale));
|
||||
@@ -212,8 +225,59 @@ void NewGraphDialog::setParams(GraphParams ¶ms)
|
||||
|
||||
assocSignal = params.associatedSignal;
|
||||
|
||||
loadMessages();
|
||||
loadSignals(0);
|
||||
loadNodes();
|
||||
|
||||
auto msg = assocSignal->parentMessage;
|
||||
auto node = msg->sender;
|
||||
|
||||
bool nodeFound = false;
|
||||
for(int i=0; i<ui->cbNodes->count(); i++)
|
||||
{
|
||||
if(ui->cbNodes->itemText(i) == node->sourceFileName + Utility::fullyQualifiedNameSeperator + node->name)
|
||||
{
|
||||
ui->cbNodes->setCurrentIndex(i);
|
||||
nodeFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
qDebug() << "Matching plot params to Node: " << nodeFound;
|
||||
|
||||
if(nodeFound)
|
||||
{
|
||||
bool msgFound = false;
|
||||
for(int i=0; i<ui->cbMessages->count(); i++)
|
||||
{
|
||||
if(ui->cbMessages->itemText(i) == msg->name)
|
||||
{
|
||||
ui->cbMessages->setCurrentIndex(i);
|
||||
msgFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
qDebug() << "Matching plot params to Msg: " << msgFound;
|
||||
|
||||
if(msgFound)
|
||||
{
|
||||
bool sigFound = false;
|
||||
for(int i=0; i<ui->cbSignals->count(); i++)
|
||||
{
|
||||
if(ui->cbSignals->itemText(i) == assocSignal->name)
|
||||
{
|
||||
ui->cbSignals->setCurrentIndex(i);
|
||||
sigFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
qDebug() << "Matching plot params to Signal: " << sigFound;
|
||||
}
|
||||
}
|
||||
//ui->cbNodes->model()->
|
||||
|
||||
|
||||
//loadSignals(0);
|
||||
drawBitfield();
|
||||
checkSignalAgreement();
|
||||
}
|
||||
@@ -248,41 +312,85 @@ void NewGraphDialog::getParams(GraphParams ¶ms)
|
||||
if (params.stride < 1) params.stride = 1;
|
||||
}
|
||||
|
||||
void NewGraphDialog::loadMessages()
|
||||
void NewGraphDialog::loadNodes()
|
||||
{
|
||||
int numFiles;
|
||||
ui->cbNodes->clear();
|
||||
if (dbcHandler == nullptr) return;
|
||||
if ((numFiles = dbcHandler->getFileCount()) == 0) return;
|
||||
qDebug() << numFiles;
|
||||
for (int f = 0; f < numFiles; f++)
|
||||
{
|
||||
DBCFile* thisFile = dbcHandler->getFileByIdx(f);
|
||||
qDebug() << thisFile->messageHandler->getCount();
|
||||
|
||||
QList<QString> names;
|
||||
|
||||
for (int x = 0; x < thisFile->dbc_nodes.count(); x++)
|
||||
{
|
||||
bool messagesInNode = false;
|
||||
for (int m = 0; m < thisFile->messageHandler->getCount(); m++)
|
||||
{
|
||||
if(thisFile->messageHandler->findMsgByIdx(m)->sender->name == thisFile->dbc_nodes[x].name)
|
||||
{
|
||||
messagesInNode = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(messagesInNode)
|
||||
{
|
||||
QString fullyQualifiedNodeName = thisFile->getFilenameNoExt() + Utility::fullyQualifiedNameSeperator + thisFile->dbc_nodes[x].name;
|
||||
names.append(fullyQualifiedNodeName);
|
||||
}
|
||||
}
|
||||
|
||||
if(names.count() > 0)
|
||||
{
|
||||
names.sort();
|
||||
ui->cbNodes->addItem("----" + thisFile->getFilename());
|
||||
Utility::SetComboBoxItemEnabled(ui->cbNodes, ui->cbNodes->count() -1, false);
|
||||
for(int i=0; i<names.count(); i++)
|
||||
ui->cbNodes->addItem(names[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NewGraphDialog::loadMessages(int idx)
|
||||
{
|
||||
int numFiles = 0;
|
||||
DBC_MESSAGE *msg;
|
||||
ui->cbMessages->clear();
|
||||
if (dbcHandler == nullptr) return;
|
||||
if (dbcHandler->getFileCount() == 0) return;
|
||||
for (int y = 0; y < dbcHandler->getFileCount(); y++)
|
||||
if ((numFiles = dbcHandler->getFileCount()) == 0) return;
|
||||
qDebug() << numFiles;
|
||||
|
||||
QString displayedNodeName = ui->cbNodes->itemText(idx);
|
||||
|
||||
for (int f = 0; f < numFiles; f++)
|
||||
{
|
||||
for (int x = 0; x < dbcHandler->getFileByIdx(y)->messageHandler->getCount(); x++)
|
||||
qDebug() << dbcHandler->getFileByIdx(f)->messageHandler->getCount();
|
||||
|
||||
for (int x = 0; x < dbcHandler->getFileByIdx(f)->messageHandler->getCount(); x++)
|
||||
{
|
||||
msg = dbcHandler->getFileByIdx(y)->messageHandler->findMsgByIdx(x);
|
||||
if (msg)
|
||||
{
|
||||
ui->cbMessages->addItem(msg->name);
|
||||
if (assocSignal && msg->name == assocSignal->parentMessage->name)
|
||||
{
|
||||
ui->cbMessages->setCurrentIndex(ui->cbMessages->count() -1);
|
||||
//qDebug() << "Found my parent";
|
||||
}
|
||||
}
|
||||
QString fullyQualifiedNodeName = dbcHandler->getFileByIdx(f)->getFilenameNoExt() + Utility::fullyQualifiedNameSeperator + dbcHandler->getFileByIdx(f)->messageHandler->findMsgByIdx(x)->sender->name;
|
||||
if(fullyQualifiedNodeName == displayedNodeName)
|
||||
ui->cbMessages->addItem(dbcHandler->getFileByIdx(f)->messageHandler->findMsgByIdx(x)->name);
|
||||
}
|
||||
}
|
||||
ui->cbMessages->model()->sort(0);
|
||||
}
|
||||
|
||||
void NewGraphDialog::loadSignals(int idx)
|
||||
{
|
||||
Q_UNUSED(idx);
|
||||
//search through all DBC files in order to try to find a message with the given name
|
||||
DBC_MESSAGE *msg = dbcHandler->findMessage(ui->cbMessages->currentText());
|
||||
DBC_SIGNAL *sig;
|
||||
|
||||
if (msg == nullptr) return;
|
||||
|
||||
ui->cbSignals->clear();
|
||||
|
||||
//search through all DBC files in order to try to find a message with the given name
|
||||
QString fullyQualifiedNodeName = ui->cbNodes->itemText(ui->cbNodes->currentIndex());
|
||||
DBC_MESSAGE *msg = dbcHandler->findMessage(ui->cbMessages->currentText(), fullyQualifiedNodeName);
|
||||
if (msg == nullptr) return;
|
||||
|
||||
DBC_SIGNAL *sig;
|
||||
for (int x = 0; x < msg->sigHandler->getCount(); x++)
|
||||
{
|
||||
sig = msg->sigHandler->findSignalByIdx(x);
|
||||
@@ -366,11 +474,10 @@ void NewGraphDialog::copySignalToParamsUI()
|
||||
assocSignal = nullptr;
|
||||
DBC_MESSAGE *msg = nullptr;
|
||||
|
||||
for(int i = 0; i < dbcHandler->getFileCount(); i++)
|
||||
{
|
||||
msg = dbcHandler->getFileByIdx(i)->messageHandler->findMsgByName(ui->cbMessages->currentText());
|
||||
if (msg) break;
|
||||
}
|
||||
QString fullyQualifiedNodeName = ui->cbNodes->itemText(ui->cbNodes->currentIndex());
|
||||
QString msgName = ui->cbMessages->itemText(ui->cbMessages->currentIndex());
|
||||
|
||||
msg = dbcHandler->findMessage(msgName, fullyQualifiedNodeName);
|
||||
|
||||
if (!msg) return;
|
||||
DBC_SIGNAL *sig = msg->sigHandler->findSignalByName(ui->cbSignals->currentText());
|
||||
|
||||
Reference in New Issue
Block a user