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:
+39
-30
@@ -2,6 +2,7 @@
|
||||
#include "ui_signalviewerwindow.h"
|
||||
#include "helpwindow.h"
|
||||
#include "mainwindow.h"
|
||||
#include "utility.h"
|
||||
#include <QDebug>
|
||||
|
||||
#define MSG_COL 1
|
||||
@@ -40,6 +41,7 @@ SignalViewerWindow::SignalViewerWindow(const QVector<CANFrame> *frames, QWidget
|
||||
verticalHeader->setFont(QFont());
|
||||
|
||||
dbcHandler = DBCHandler::getReference();
|
||||
currentlySelectedMsg = nullptr;
|
||||
|
||||
connect(ui->cbNodes, SIGNAL(currentIndexChanged(int)), this, SLOT(loadMessages(int)));
|
||||
connect(ui->cbMessages, SIGNAL(currentIndexChanged(int)), this, SLOT(loadSignals(int)));
|
||||
@@ -118,18 +120,6 @@ void SignalViewerWindow::removeSelectedSignal()
|
||||
ui->tableViewer->removeRow(selRow);
|
||||
}
|
||||
|
||||
void SetComboBoxItemEnabled(QComboBox * comboBox, int index, bool enabled)
|
||||
{
|
||||
auto * model = qobject_cast<QStandardItemModel*>(comboBox->model());
|
||||
assert(model);
|
||||
if(!model) return;
|
||||
|
||||
auto * item = model->item(index);
|
||||
assert(item);
|
||||
if(!item) return;
|
||||
item->setEnabled(enabled);
|
||||
}
|
||||
|
||||
void SignalViewerWindow::loadNodes()
|
||||
{
|
||||
int numFiles;
|
||||
@@ -139,22 +129,34 @@ void SignalViewerWindow::loadNodes()
|
||||
qDebug() << numFiles;
|
||||
for (int f = 0; f < numFiles; f++)
|
||||
{
|
||||
qDebug() << dbcHandler->getFileByIdx(f)->messageHandler->getCount();
|
||||
DBCFile* thisFile = dbcHandler->getFileByIdx(f);
|
||||
qDebug() << thisFile->messageHandler->getCount();
|
||||
|
||||
QList<QString> names;
|
||||
|
||||
for (int x = 0; x < dbcHandler->getFileByIdx(f)->dbc_nodes.count(); x++)
|
||||
for (int x = 0; x < thisFile->dbc_nodes.count(); x++)
|
||||
{
|
||||
QString name = dbcHandler->getFileByIdx(f)->dbc_nodes[x].name;
|
||||
if(name != "Vector__XXX")
|
||||
names.append(name);
|
||||
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("----" + dbcHandler->getFileByIdx(f)->getFilename());
|
||||
SetComboBoxItemEnabled(ui->cbNodes, ui->cbNodes->count() -1, false);
|
||||
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]);
|
||||
}
|
||||
@@ -163,13 +165,13 @@ void SignalViewerWindow::loadNodes()
|
||||
|
||||
void SignalViewerWindow::loadMessages(int idx)
|
||||
{
|
||||
int numFiles;
|
||||
int numFiles = 0;
|
||||
ui->cbMessages->clear();
|
||||
if (dbcHandler == nullptr) return;
|
||||
if ((numFiles = dbcHandler->getFileCount()) == 0) return;
|
||||
qDebug() << numFiles;
|
||||
|
||||
QString nodeName = ui->cbNodes->itemText(idx);
|
||||
QString displayedNodeName = ui->cbNodes->itemText(idx);
|
||||
|
||||
for (int f = 0; f < numFiles; f++)
|
||||
{
|
||||
@@ -177,7 +179,8 @@ void SignalViewerWindow::loadMessages(int idx)
|
||||
|
||||
for (int x = 0; x < dbcHandler->getFileByIdx(f)->messageHandler->getCount(); x++)
|
||||
{
|
||||
if(dbcHandler->getFileByIdx(f)->messageHandler->findMsgByIdx(x)->sender->name == nodeName)
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -186,14 +189,14 @@ void SignalViewerWindow::loadMessages(int idx)
|
||||
void SignalViewerWindow::loadSignals(int idx)
|
||||
{
|
||||
Q_UNUSED(idx);
|
||||
//messages were placed into the list in the same order as they exist
|
||||
//in the data structure so it should have been possible to just
|
||||
//look it up based on index but by name is probably safer and this operation
|
||||
//is not time critical at all.
|
||||
DBC_MESSAGE *msg = dbcHandler->findMessage(ui->cbMessages->currentText());
|
||||
|
||||
if (msg == nullptr) return;
|
||||
ui->cbSignals->clear();
|
||||
|
||||
QString fullyQualifiedNodeName = ui->cbNodes->itemText(ui->cbNodes->currentIndex());
|
||||
QString msgName = ui->cbMessages->itemText(ui->cbMessages->currentIndex());
|
||||
|
||||
DBC_MESSAGE *msg = dbcHandler->findMessage(msgName, fullyQualifiedNodeName);
|
||||
if (msg == nullptr) return;
|
||||
for (int x = 0; x < msg->sigHandler->getCount(); x++)
|
||||
{
|
||||
ui->cbSignals->addItem(msg->sigHandler->findSignalByIdx(x)->name);
|
||||
@@ -202,7 +205,13 @@ void SignalViewerWindow::loadSignals(int idx)
|
||||
|
||||
void SignalViewerWindow::addSignal()
|
||||
{
|
||||
DBC_MESSAGE *msg = dbcHandler->findMessage(ui->cbMessages->currentText());
|
||||
DBC_MESSAGE *msg = nullptr;
|
||||
|
||||
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());
|
||||
if (!sig) return;
|
||||
@@ -366,7 +375,7 @@ void SignalViewerWindow::loadDefinitions(bool append)
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "Couldn't find the message by name! " << msgName << " " << sigName;
|
||||
qDebug() << "Couldn't find the message by ID or name! " << msgName << " " << sigName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user