From b140737ab7d776a861e376e625d6a2e5a732377b Mon Sep 17 00:00:00 2001 From: Collin Kidder Date: Tue, 9 Jun 2015 21:29:03 -0400 Subject: [PATCH] Additional implementation of DBC editor --- dbchandler.cpp | 12 +++++++++--- dbchandler.h | 1 + dbcmaineditor.cpp | 12 +++++++++++- dbcsignaleditor.cpp | 8 +++++--- 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/dbchandler.cpp b/dbchandler.cpp index 31d58fb..d2b851c 100644 --- a/dbchandler.cpp +++ b/dbchandler.cpp @@ -253,12 +253,18 @@ void DBCHandler::loadDBCFile(QString filename) inFile->close(); } +void DBCHandler::saveDBCFile(QString filename) +{ + +} + + DBC_NODE *DBCHandler::findNodeByName(QString name) { if (dbc_nodes.length() == 0) return NULL; for (int i = 0; i < dbc_nodes.length(); i++) { - if (dbc_nodes[i].name == name) + if (dbc_nodes[i].name.compare(name, Qt::CaseInsensitive) == 0) { return &dbc_nodes[i]; } @@ -299,7 +305,7 @@ DBC_MESSAGE *DBCHandler::findMsgByName(QString name) if (dbc_messages.length() == 0) return NULL; for (int i = 0; i < dbc_messages.length(); i++) { - if (dbc_messages[i].name.compare(name, Qt::CaseInsensitive)) + if (dbc_messages[i].name.compare(name, Qt::CaseInsensitive) == 0) { return &dbc_messages[i]; } @@ -313,7 +319,7 @@ DBC_SIGNAL *DBCHandler::findSignalByName(DBC_MESSAGE *msg, QString name) if (msg->msgSignals.length() == 0) return NULL; for (int i = 0; i < msg->msgSignals.length(); i++) { - if (msg->msgSignals[i].name == name) + if (msg->msgSignals[i].name.compare(name, Qt::CaseInsensitive) == 0) { return &msg->msgSignals[i]; } diff --git a/dbchandler.h b/dbchandler.h index 796f193..b49645c 100644 --- a/dbchandler.h +++ b/dbchandler.h @@ -16,6 +16,7 @@ class DBCHandler : public QObject public: explicit DBCHandler(QObject *parent = 0); void loadDBCFile(QString); + void saveDBCFile(QString); void listDebugging(); QString processSignal(const CANFrame &frame, const DBC_SIGNAL &sig); DBC_NODE *findNodeByName(QString name); diff --git a/dbcmaineditor.cpp b/dbcmaineditor.cpp index 302d4fe..7231d76 100644 --- a/dbcmaineditor.cpp +++ b/dbcmaineditor.cpp @@ -114,7 +114,7 @@ void DBCMainEditor::onCellChangedNode(int row,int col) qDebug() << "New comment: " << thisNode->comment; } } - + ui->NodesTable->setCurrentCell(row, col); } void DBCMainEditor::onCellChangedMessage(int row,int col) @@ -243,6 +243,8 @@ void DBCMainEditor::onCellChangedMessage(int row,int col) { ui->MessagesTable->insertRow(ui->MessagesTable->rowCount()); } + + ui->MessagesTable->setCurrentCell(row, col); } void DBCMainEditor::onCellClickedNode(int row, int col) @@ -284,6 +286,14 @@ void DBCMainEditor::refreshNodesTable() int rowIdx; + if (dbcHandler->findNodeByName("Vector_XXX") == NULL) + { + DBC_NODE newNode; + newNode.name = "Vector_XXX"; + newNode.comment = "Default node if no other node is specified"; + dbcHandler->dbc_nodes.append(newNode); + } + for (int x = 0; x < dbcHandler->dbc_nodes.count(); x++) { DBC_NODE node = dbcHandler->dbc_nodes.at(x); diff --git a/dbcsignaleditor.cpp b/dbcsignaleditor.cpp index 20bf064..d6e1b59 100644 --- a/dbcsignaleditor.cpp +++ b/dbcsignaleditor.cpp @@ -90,12 +90,14 @@ void DBCSignalEditor::fillSignalForm(DBC_SIGNAL *sig) endBit = startBit + sig->signalSize - 1; - for (int y = startBit; y <= endBit; y++) + bitpattern[startBit / 8] |= 1 << (startBit % 8); + ui->bitfield->setReference(bitpattern, false); + + for (int y = startBit + 1; y <= endBit; y++) { int byt = y / 8; bitpattern[byt] |= 1 << (y % 8); - } - ui->bitfield->setReference(bitpattern, false); + } ui->bitfield->updateData(bitpattern, true); ui->cbIntelFormat->setChecked(sig->intelByteOrder);