Addition of two new forms for DBC editing. Not done yet. The main editor window works for viewing though. Still toying with ideas for the signal editor. Very much a work in progress.
This commit is contained in:
+9
-3
@@ -25,7 +25,9 @@ SOURCES += main.cpp\
|
||||
candatagrid.cpp \
|
||||
flowviewwindow.cpp \
|
||||
framesenderwindow.cpp \
|
||||
dbchandler.cpp
|
||||
dbchandler.cpp \
|
||||
dbcmaineditor.cpp \
|
||||
dbcsignaleditor.cpp
|
||||
|
||||
HEADERS += mainwindow.h \
|
||||
can_structs.h \
|
||||
@@ -42,7 +44,9 @@ HEADERS += mainwindow.h \
|
||||
framesenderwindow.h \
|
||||
can_trigger_structs.h \
|
||||
dbc_classes.h \
|
||||
dbchandler.h
|
||||
dbchandler.h \
|
||||
dbcmaineditor.h \
|
||||
dbcsignaleditor.h
|
||||
|
||||
FORMS += mainwindow.ui \
|
||||
graphingwindow.ui \
|
||||
@@ -51,7 +55,9 @@ FORMS += mainwindow.ui \
|
||||
frameplaybackwindow.ui \
|
||||
candatagrid.ui \
|
||||
flowviewwindow.ui \
|
||||
framesenderwindow.ui
|
||||
framesenderwindow.ui \
|
||||
dbcmaineditor.ui \
|
||||
dbcsignaleditor.ui
|
||||
|
||||
DISTFILES +=
|
||||
|
||||
|
||||
+3
-2
@@ -22,13 +22,14 @@ public:
|
||||
DBC_MESSAGE *findMsgByID(int id);
|
||||
DBC_SIGNAL *findSignalByName(DBC_MESSAGE *msg, QString name);
|
||||
|
||||
QList<DBC_NODE> dbc_nodes;
|
||||
QList<DBC_MESSAGE> dbc_messages;
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
private:
|
||||
QList<DBC_NODE> dbc_nodes;
|
||||
QList<DBC_MESSAGE> dbc_messages;
|
||||
|
||||
unsigned char reverseBits(unsigned char);
|
||||
unsigned char processByte(unsigned char, int, int);
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
#include "dbcmaineditor.h"
|
||||
#include "ui_dbcmaineditor.h"
|
||||
|
||||
DBCMainEditor::DBCMainEditor(DBCHandler *handler, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::DBCMainEditor)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
dbcHandler = handler;
|
||||
|
||||
QStringList headers;
|
||||
headers << "Node Name" << "Comment";
|
||||
ui->NodesTable->setColumnCount(2);
|
||||
ui->NodesTable->setColumnWidth(0, 240);
|
||||
ui->NodesTable->setColumnWidth(1, 700);
|
||||
ui->NodesTable->setHorizontalHeaderLabels(headers);
|
||||
ui->NodesTable->horizontalHeader()->setStretchLastSection(true);
|
||||
|
||||
QStringList headers2;
|
||||
headers2 << "Msg ID" << "Msg Name" << "Data Len" << "Signals" << "Comment";
|
||||
ui->MessagesTable->setColumnCount(5);
|
||||
ui->MessagesTable->setColumnWidth(0, 80);
|
||||
ui->MessagesTable->setColumnWidth(1, 240);
|
||||
ui->MessagesTable->setColumnWidth(2, 80);
|
||||
ui->MessagesTable->setColumnWidth(3, 80);
|
||||
ui->MessagesTable->setColumnWidth(4, 340);
|
||||
ui->MessagesTable->setHorizontalHeaderLabels(headers2);
|
||||
ui->MessagesTable->horizontalHeader()->setStretchLastSection(true);
|
||||
|
||||
|
||||
refreshNodesTable();
|
||||
refreshMessagesTable(&dbcHandler->dbc_nodes.at(0));
|
||||
currRow = 0;
|
||||
|
||||
connect(ui->NodesTable, SIGNAL(cellChanged(int,int)), this, SLOT(onCellChangedNode(int,int)));
|
||||
connect(ui->NodesTable, SIGNAL(cellClicked(int,int)), this, SLOT(onCellClickedNode(int,int)));
|
||||
|
||||
connect(ui->MessagesTable, SIGNAL(cellChanged(int,int)), this, SLOT(onCellChangedMessage(int,int)));
|
||||
connect(ui->MessagesTable, SIGNAL(cellClicked(int,int)), this, SLOT(onCellClickedMessage(int,int)));
|
||||
|
||||
sigEditor = new DBCSignalEditor(handler);
|
||||
}
|
||||
|
||||
DBCMainEditor::~DBCMainEditor()
|
||||
{
|
||||
delete ui;
|
||||
delete sigEditor;
|
||||
}
|
||||
|
||||
void DBCMainEditor::onCellChangedNode(int row,int col)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DBCMainEditor::onCellChangedMessage(int row,int col)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DBCMainEditor::onCellClickedNode(int row, int col)
|
||||
{
|
||||
//reload messages list if the currently selected row has changed.
|
||||
//qDebug() << "Entered at row " << row << " col " << col;
|
||||
if (row != currRow)
|
||||
{
|
||||
currRow = row;
|
||||
QString nodeName = ui->NodesTable->item(currRow, 0)->text();
|
||||
qDebug() << "Trying to find node with name " << nodeName;
|
||||
DBC_NODE *node = dbcHandler->findNodeByName(nodeName);
|
||||
//qDebug() << "Address of node: " << (int)node;
|
||||
refreshMessagesTable(node);
|
||||
}
|
||||
}
|
||||
|
||||
void DBCMainEditor::onCellClickedMessage(int row, int col)
|
||||
{
|
||||
if (col == 3) //3 is the signals field. If clicked we go to the signals dialog
|
||||
{
|
||||
QString idString = ui->MessagesTable->item(row, 0)->text();
|
||||
DBC_MESSAGE *message = dbcHandler->findMsgByID(idString.toInt(NULL, 16));
|
||||
sigEditor->setMessageRef(message);
|
||||
sigEditor->exec(); //blocks this window from being active until we're done
|
||||
}
|
||||
}
|
||||
|
||||
void DBCMainEditor::refreshNodesTable()
|
||||
{
|
||||
ui->NodesTable->clearContents(); //first step, clear out any previous crap
|
||||
ui->NodesTable->setRowCount(0);
|
||||
|
||||
int rowIdx;
|
||||
|
||||
for (int x = 0; x < dbcHandler->dbc_nodes.count(); x++)
|
||||
{
|
||||
DBC_NODE node = dbcHandler->dbc_nodes.at(x);
|
||||
QTableWidgetItem *nodeName = new QTableWidgetItem(node.name);
|
||||
QTableWidgetItem *nodeComment = new QTableWidgetItem(node.comment);
|
||||
rowIdx = ui->NodesTable->rowCount();
|
||||
ui->NodesTable->insertRow(rowIdx);
|
||||
ui->NodesTable->setItem(rowIdx, 0, nodeName);
|
||||
ui->NodesTable->setItem(rowIdx, 1, nodeComment);
|
||||
}
|
||||
|
||||
ui->NodesTable->insertRow(ui->NodesTable->rowCount());
|
||||
}
|
||||
|
||||
void DBCMainEditor::refreshMessagesTable(const DBC_NODE *node)
|
||||
{
|
||||
ui->MessagesTable->clearContents();
|
||||
ui->MessagesTable->setRowCount(0);
|
||||
|
||||
int rowIdx;
|
||||
|
||||
if (node != NULL)
|
||||
{
|
||||
for (int x = 0; x < dbcHandler->dbc_messages.count(); x++)
|
||||
{
|
||||
DBC_MESSAGE msg = dbcHandler->dbc_messages.at(x);
|
||||
if (msg.sender == node)
|
||||
{
|
||||
//many of these are simplistic first versions just to test functionality.
|
||||
QTableWidgetItem *msgID = new QTableWidgetItem(QString::number(msg.ID, 16));
|
||||
QTableWidgetItem *msgName = new QTableWidgetItem(msg.name);
|
||||
QTableWidgetItem *msgLen = new QTableWidgetItem(QString::number(msg.len));
|
||||
QTableWidgetItem *msgSignals = new QTableWidgetItem(QString::number(msg.msgSignals.count()));
|
||||
QTableWidgetItem *msgComment = new QTableWidgetItem(msg.comment);
|
||||
|
||||
rowIdx = ui->MessagesTable->rowCount();
|
||||
ui->MessagesTable->insertRow(rowIdx);
|
||||
ui->MessagesTable->setItem(rowIdx, 0, msgID);
|
||||
ui->MessagesTable->setItem(rowIdx, 1, msgName);
|
||||
ui->MessagesTable->setItem(rowIdx, 2, msgLen);
|
||||
ui->MessagesTable->setItem(rowIdx, 3, msgSignals);
|
||||
ui->MessagesTable->setItem(rowIdx, 4, msgComment);
|
||||
//note that there is a sending node field in the structure but we're
|
||||
//not displaying it. It has to be the node we selected from the node list
|
||||
//so no need to show that here.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ui->MessagesTable->insertRow(ui->MessagesTable->rowCount());
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
#ifndef DBCMAINEDITOR_H
|
||||
#define DBCMAINEDITOR_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QDebug>
|
||||
#include "dbchandler.h"
|
||||
#include "dbcsignaleditor.h"
|
||||
|
||||
namespace Ui {
|
||||
class DBCMainEditor;
|
||||
}
|
||||
|
||||
class DBCMainEditor : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DBCMainEditor(DBCHandler *handler, QWidget *parent = 0);
|
||||
~DBCMainEditor();
|
||||
|
||||
private slots:
|
||||
void onCellChangedNode(int,int);
|
||||
void onCellClickedNode(int, int);
|
||||
void onCellClickedMessage(int, int);
|
||||
void onCellChangedMessage(int,int);
|
||||
|
||||
private:
|
||||
Ui::DBCMainEditor *ui;
|
||||
DBCHandler *dbcHandler;
|
||||
DBCSignalEditor *sigEditor;
|
||||
int currRow;
|
||||
|
||||
void refreshNodesTable();
|
||||
void refreshMessagesTable(const DBC_NODE *node);
|
||||
};
|
||||
|
||||
#endif // DBCMAINEDITOR_H
|
||||
@@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DBCMainEditor</class>
|
||||
<widget class="QDialog" name="DBCMainEditor">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1103</width>
|
||||
<height>571</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>DBC Editing Window</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3" stretch="1,3">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Nodes</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTableWidget" name="NodesTable"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Messages</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTableWidget" name="MessagesTable"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,65 @@
|
||||
#include "dbcsignaleditor.h"
|
||||
#include "ui_dbcsignaleditor.h"
|
||||
|
||||
DBCSignalEditor::DBCSignalEditor(DBCHandler *handler, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::DBCSignalEditor)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
dbcHandler = handler;
|
||||
dbcMessage = NULL;
|
||||
/*
|
||||
QStringList headers;
|
||||
headers << "Node Name" << "Comment";
|
||||
ui->signalsTable->setColumnCount(2);
|
||||
ui->signalsTable->setColumnWidth(0, 240);
|
||||
ui->signalsTable->setColumnWidth(1, 700);
|
||||
ui->signalsTable->setHorizontalHeaderLabels(headers);
|
||||
ui->signalsTable->horizontalHeader()->setStretchLastSection(true);
|
||||
name,
|
||||
a start bit,
|
||||
a length,
|
||||
byte order (intel or motorola),
|
||||
a type (signed, unsigned, float, string),
|
||||
a scaling factor,
|
||||
a bias,
|
||||
a minimum and
|
||||
maximum,
|
||||
a receiving node,
|
||||
a unit name,
|
||||
an optional comment,
|
||||
and an optional value list
|
||||
|
||||
|
||||
|
||||
|
||||
QStringList headers2;
|
||||
headers2 << "Msg ID" << "Msg Name" << "Data Len" << "Signals" << "Comment";
|
||||
ui->MessagesTable->setColumnCount(5);
|
||||
ui->MessagesTable->setColumnWidth(0, 80);
|
||||
ui->MessagesTable->setColumnWidth(1, 240);
|
||||
ui->MessagesTable->setColumnWidth(2, 80);
|
||||
ui->MessagesTable->setColumnWidth(3, 80);
|
||||
ui->MessagesTable->setColumnWidth(4, 340);
|
||||
ui->MessagesTable->setHorizontalHeaderLabels(headers2);
|
||||
ui->MessagesTable->horizontalHeader()->setStretchLastSection(true);
|
||||
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
DBCSignalEditor::~DBCSignalEditor()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void DBCSignalEditor::setMessageRef(DBC_MESSAGE *msg)
|
||||
{
|
||||
dbcMessage = msg;
|
||||
}
|
||||
|
||||
void DBCSignalEditor::showEvent(QShowEvent* event)
|
||||
{
|
||||
QDialog::showEvent(event);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#ifndef DBCSIGNALEDITOR_H
|
||||
#define DBCSIGNALEDITOR_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "dbchandler.h"
|
||||
|
||||
namespace Ui {
|
||||
class DBCSignalEditor;
|
||||
}
|
||||
|
||||
class DBCSignalEditor : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DBCSignalEditor(DBCHandler *handler, QWidget *parent = 0);
|
||||
void setMessageRef(DBC_MESSAGE *msg);
|
||||
void showEvent(QShowEvent*);
|
||||
~DBCSignalEditor();
|
||||
|
||||
private:
|
||||
Ui::DBCSignalEditor *ui;
|
||||
DBCHandler *dbcHandler;
|
||||
DBC_MESSAGE *dbcMessage;
|
||||
};
|
||||
|
||||
#endif // DBCSIGNALEDITOR_H
|
||||
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DBCSignalEditor</class>
|
||||
<widget class="QDialog" name="DBCSignalEditor">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>884</width>
|
||||
<height>530</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Signal Editor</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="1,10,1,5">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Signals</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTableWidget" name="signalsTable"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Value Table For Selected Signal:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTableWidget" name="valuesTable"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+13
-1
@@ -91,6 +91,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
playbackWindow = NULL;
|
||||
flowViewWindow = NULL;
|
||||
frameSenderWindow = NULL;
|
||||
dbcMainEditor = NULL;
|
||||
dbcHandler = new DBCHandler;
|
||||
|
||||
model->setDBCHandler(dbcHandler);
|
||||
@@ -111,6 +112,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
connect(ui->canFramesView, SIGNAL(clicked(QModelIndex)), this, SLOT(gridClicked(QModelIndex)));
|
||||
connect(ui->cbInterpret, SIGNAL(toggled(bool)), this, SLOT(interpretToggled(bool)));
|
||||
connect(ui->cbOverwrite, SIGNAL(toggled(bool)), this, SLOT(overwriteToggled(bool)));
|
||||
connect(ui->actionEdit_Messages_Signals, SIGNAL(triggered(bool)), this, SLOT(showDBCEditor()));
|
||||
|
||||
lbStatusConnected.setText(tr("Not connected"));
|
||||
updateBaudLabel(0,0);
|
||||
@@ -132,7 +134,6 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
normalRowHeight = ui->canFramesView->rowHeight(0);
|
||||
qDebug() << "normal row height = " << normalRowHeight;
|
||||
model->clearFrames();
|
||||
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
@@ -145,9 +146,12 @@ MainWindow::~MainWindow()
|
||||
if (playbackWindow) delete playbackWindow;
|
||||
if (flowViewWindow) delete flowViewWindow;
|
||||
if (frameSenderWindow) delete frameSenderWindow;
|
||||
if (dbcMainEditor) delete dbcMainEditor;
|
||||
|
||||
delete ui;
|
||||
delete dbcHandler;
|
||||
model->clearFrames();
|
||||
delete model;
|
||||
}
|
||||
|
||||
void MainWindow::gridClicked(QModelIndex idx)
|
||||
@@ -807,5 +811,13 @@ void MainWindow::showFlowViewWindow()
|
||||
flowViewWindow = new FlowViewWindow(model->getListReference());
|
||||
}
|
||||
flowViewWindow->show();
|
||||
}
|
||||
|
||||
void MainWindow::showDBCEditor()
|
||||
{
|
||||
if (!dbcMainEditor)
|
||||
{
|
||||
dbcMainEditor = new DBCMainEditor(dbcHandler);
|
||||
}
|
||||
dbcMainEditor->show();
|
||||
}
|
||||
|
||||
+12
-1
@@ -12,6 +12,7 @@
|
||||
#include "flowviewwindow.h"
|
||||
#include "framesenderwindow.h"
|
||||
#include "dbchandler.h"
|
||||
#include "dbcmaineditor.h"
|
||||
|
||||
#define VERSION 105
|
||||
|
||||
@@ -47,6 +48,7 @@ private slots:
|
||||
void gridClicked(QModelIndex);
|
||||
void interpretToggled(bool);
|
||||
void overwriteToggled(bool);
|
||||
void showDBCEditor();
|
||||
|
||||
public slots:
|
||||
void gotFrames(int, int);
|
||||
@@ -60,21 +62,30 @@ signals:
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
|
||||
//canbus related data
|
||||
CANFrameModel *model;
|
||||
DBCHandler *dbcHandler;
|
||||
QList<QSerialPortInfo> ports;
|
||||
QThread serialWorkerThread;
|
||||
QByteArray inputBuffer;
|
||||
|
||||
//References to other windows we can display
|
||||
GraphingWindow *graphingWindow;
|
||||
FrameInfoWindow *frameInfoWindow;
|
||||
FramePlaybackWindow *playbackWindow;
|
||||
FlowViewWindow *flowViewWindow;
|
||||
FrameSenderWindow *frameSenderWindow;
|
||||
DBCHandler *dbcHandler;
|
||||
DBCMainEditor *dbcMainEditor;
|
||||
|
||||
//various private storage
|
||||
QLabel lbStatusConnected;
|
||||
QLabel lbStatusBauds;
|
||||
QLabel lbStatusDatabase;
|
||||
int normalRowHeight;
|
||||
bool isConnected;
|
||||
|
||||
//private methods
|
||||
void loadCRTDFile(QString);
|
||||
void loadNativeCSVFile(QString);
|
||||
void loadGenericCSVFile(QString);
|
||||
|
||||
Reference in New Issue
Block a user