Add preliminaries for signal viewer, update version number, switch dbc handler to singleton pattern, changes to DBC attributes

This commit is contained in:
Collin Kidder
2017-01-15 16:30:08 -05:00
parent d94c823216
commit 74f6d7f947
21 changed files with 236 additions and 55 deletions
+6 -3
View File
@@ -59,7 +59,8 @@ SOURCES += main.cpp\
connections/connectionwindow.cpp \
re/graphingwindow.cpp \
re/newgraphdialog.cpp \
bisectwindow.cpp
bisectwindow.cpp \
signalviewerwindow.cpp
HEADERS += mainwindow.h \
can_structs.h \
@@ -107,7 +108,8 @@ HEADERS += mainwindow.h \
connections/connectionwindow.h \
re/graphingwindow.h \
re/newgraphdialog.h \
bisectwindow.h
bisectwindow.h \
signalviewerwindow.h
FORMS += ui/candatagrid.ui \
ui/connectionwindow.ui \
@@ -132,7 +134,8 @@ FORMS += ui/candatagrid.ui \
ui/scriptingwindow.ui \
ui/snifferwindow.ui \
ui/udsscanwindow.ui \
ui/bisectwindow.ui
ui/bisectwindow.ui \
ui/signalviewerwindow.ui
DISTFILES +=
+1 -6
View File
@@ -58,7 +58,7 @@ CANFrameModel::CANFrameModel(QObject *parent)
frames.reserve(preallocSize);
filteredFrames.reserve(preallocSize); //the goal is to prevent a reallocation from ever happening
dbcHandler = NULL;
dbcHandler = DBCHandler::getReference();
interpretFrames = false;
overwriteDups = false;
useHexMode = true;
@@ -89,11 +89,6 @@ void CANFrameModel::setSecondsMode(bool mode)
}
}
void CANFrameModel::setDBCHandler(DBCHandler *handler)
{
dbcHandler = handler;
}
void CANFrameModel::setInterpetMode(bool mode)
{
//if the state of interpretFrames changes then we need to reset the model
-1
View File
@@ -29,7 +29,6 @@ public:
void sendRefresh(int);
int sendBulkRefresh();
void clearFrames();
void setDBCHandler(DBCHandler *);
void setInterpetMode(bool);
void setOverwriteMode(bool);
void setHexMode(bool);
+1 -1
View File
@@ -1,7 +1,7 @@
#ifndef CONFIG
#define CONFIG
#define VERSION 163
#define VERSION 164
//try to keep this in sync.
//SavvyCAN will complain if you connect a GVRET board with a revision
+28 -10
View File
@@ -1,15 +1,17 @@
#ifndef DBC_CLASSES_H
#define DBC_CLASSES_H
#include <QColor>
#include <QString>
#include <QStringList>
#include <QVariant>
#include "can_structs.h"
/*classes to encapsulate data from a DBC file. Really, the stuff of interest
are the nodes, messages, signals, attributes, and comments.
These things sort of form a hierarchy. Nodes send and receive messages.
Messages are comprised of signals. Signals and messages have attributes.
Messages are comprised of signals. Nodes, signals, and messages potentially have attribute values.
All of them can have comments.
*/
@@ -30,17 +32,31 @@ enum DBC_ATTRIBUTE_VAL_TYPE
ENUM
};
enum DBC_ATTRIBUTE_TYPE
{
GENERAL,
NODE,
MESSAGE,
SIG
};
class DBC_ATTRIBUTE
{
public:
QString name;
DBC_ATTRIBUTE_VAL_TYPE type;
double startVal;
double endVal;
QStringList enumVals; //also used for STRING type but then you're assured to have only one
DBC_ATTRIBUTE_VAL_TYPE valType;
DBC_ATTRIBUTE_TYPE attrType;
double upper, lower;
QVariant defaultValue;
};
class DBC_VAL
class DBC_ATTRIBUTE_VALUE
{
QString attrName;
QVariant value;
};
class DBC_VAL_ENUM_ENTRY
{
public:
int value;
@@ -52,7 +68,7 @@ class DBC_NODE
public:
QString name;
QString comment;
QList<DBC_ATTRIBUTE> attributes;
QList<DBC_ATTRIBUTE_VALUE> attributes;
};
class DBC_MESSAGE; //forward reference so that DBC_SIGNAL can compile before we get to real definition of DBC_MESSAGE
@@ -76,8 +92,8 @@ public: //TODO: this is sloppy. It shouldn't all be public!
DBC_MESSAGE *parentMessage;
QString unitName;
QString comment;
QList<DBC_ATTRIBUTE> attributes;
QList<DBC_VAL> valList;
QList<DBC_ATTRIBUTE_VALUE> attributes;
QList<DBC_VAL_ENUM_ENTRY> valList;
bool processAsText(const CANFrame &frame, QString &outString);
bool processAsInt(const CANFrame &frame, int32_t &outValue);
@@ -96,7 +112,9 @@ public:
QString comment;
unsigned int len;
DBC_NODE *sender;
QList<DBC_ATTRIBUTE> attributes;
QColor bgColor;
QColor fgColor;
QList<DBC_ATTRIBUTE_VALUE> attributes;
DBCSignalHandler *sigHandler;
DBC_SIGNAL* multiplexorSignal;
};
+32 -11
View File
@@ -7,6 +7,8 @@
#include <QFileDialog>
#include "utility.h"
DBCHandler* DBCHandler::instance = NULL;
DBC_SIGNAL* DBCSignalHandler::findSignalByIdx(int idx)
{
if (sigs.count() == 0) return NULL;
@@ -499,7 +501,7 @@ void DBCFile::loadFile(QString fileName)
if (sig != NULL)
{
QString tokenString = match.captured(3);
DBC_VAL val;
DBC_VAL_ENUM_ENTRY val;
while (tokenString.length() > 2)
{
regex.setPattern("(\\d+) \\\"(.*?)\\\"(.*)");
@@ -522,28 +524,36 @@ void DBCFile::loadFile(QString fileName)
}
}
/*
if (line.startsWith("BA_DEF_ SG_ "))
{
qDebug() << "Found a SG attribute line";
regex.setPattern("^BA\\_DEF\\_ SG\\_ +\\\"([A-Za-z0-9\-_]+)\\\" +(.+);");
match = regex.match(line);
//captured 1 is the Node name
//captured 2 is the comment itself
//captured 1 is the name of the attribute to set up
//captured 2 is the type of signal attribute to create.
if (match.hasMatch())
{
qDebug() << "Comment was: " << match.captured(2);
}
}
if (line.startsWith("BA_DEF_ BO_ "))
if (line.startsWith("BA_DEF_ BO_ ")) //definition of a message attribute
{
}
if (line.startsWith("BA_DEF_ BU_ "))
if (line.startsWith("BA_DEF_ BU_ ")) //definition of a node attribute
{
}
if (line.startsWith("BA_DEF_DEF_ ")) //definition of default value for an attribute
{
}
if (line.startsWith("BA_ ")) //set value of attribute
{
}
*/
}
if (numSigFaults > 0 || numMsgFaults > 0)
{
@@ -551,7 +561,8 @@ void DBCFile::loadFile(QString fileName)
QString msg = "DBC file loaded with errors!\n";
msg += "Number of faulty message entries: " + QString::number(numMsgFaults) + "\n";
msg += "Number of faulty signal entries: " + QString::number(numSigFaults) + "\n\n";
msg += "Faulty entries have not been loaded.";
msg += "Faulty entries have not been loaded.\n\n";
msg += "All other entries are, however, loaded.";
msgBox.setText(msg);
msgBox.exec();
}
@@ -561,7 +572,6 @@ void DBCFile::loadFile(QString fileName)
this->fileName = fileList[fileList.length() - 1]; //whoops... same name as parameter in this function.
filePath = fileName.left(fileName.length() - this->fileName.length());
assocBuses = -1;
}
void DBCFile::saveFile(QString fileName)
@@ -684,7 +694,7 @@ void DBCFile::saveFile(QString fileName)
valuesOutput.append("VAL_ " + QString::number(msg->ID) + " " + sig->name);
for (int v = 0; v < sig->valList.count(); v++)
{
DBC_VAL val = sig->valList[v];
DBC_VAL_ENUM_ENTRY val = sig->valList[v];
valuesOutput.append(" " + QString::number(val.value) + " \"" + val.descript +"\"");
}
valuesOutput.append(";\n");
@@ -842,3 +852,14 @@ DBCFile* DBCHandler::getFileByName(QString name)
}
return NULL;
}
DBCHandler::DBCHandler()
{
}
DBCHandler* DBCHandler::getReference()
{
if (!instance) instance = new DBCHandler();
return instance;
}
+6 -3
View File
@@ -10,8 +10,6 @@
* Finish coding up the decoupled design
*
*/
class DBCSignalHandler: public QObject
{
Q_OBJECT
@@ -67,10 +65,11 @@ public:
DBCMessageHandler *messageHandler;
QList<DBC_NODE> dbc_nodes;
QList<DBC_ATTRIBUTE> dbc_attributes;
private:
QString fileName;
QString filePath;
int assocBuses; //-1 = all buses, 0 = first bus, 1 = second bus
int assocBuses; //-1 = all buses, 0 = first bus, 1 = second bus, etc.
};
class DBCHandler: public QObject
@@ -87,9 +86,13 @@ public:
DBCFile* getFileByIdx(int idx);
DBCFile* getFileByName(QString name);
int createBlankFile();
static DBCHandler *getReference();
private:
QList<DBCFile> loadedFiles;
DBCHandler();
static DBCHandler *instance;
};
#endif // DBCHANDLER_H
+3 -3
View File
@@ -1,12 +1,12 @@
#include "dbcloadsavewindow.h"
#include "ui_dbcloadsavewindow.h"
DBCLoadSaveWindow::DBCLoadSaveWindow(DBCHandler *handler, const QVector<CANFrame> *frames, QWidget *parent) :
DBCLoadSaveWindow::DBCLoadSaveWindow(const QVector<CANFrame> *frames, QWidget *parent) :
QDialog(parent),
ui(new Ui::DBCLoadSaveWindow)
{
dbcHandler = handler;
dbcHandler = DBCHandler::getReference();
referenceFrames = frames;
ui->setupUi(this);
@@ -28,7 +28,7 @@ DBCLoadSaveWindow::DBCLoadSaveWindow(DBCHandler *handler, const QVector<CANFrame
connect(ui->tableFiles, &QTableWidget::cellChanged, this, &DBCLoadSaveWindow::cellChanged);
connect(ui->tableFiles, &QTableWidget::cellDoubleClicked, this, &DBCLoadSaveWindow::cellDoubleClicked);
editorWindow = new DBCMainEditor(handler, frames);
editorWindow = new DBCMainEditor(frames);
}
DBCLoadSaveWindow::~DBCLoadSaveWindow()
+1 -1
View File
@@ -15,7 +15,7 @@ class DBCLoadSaveWindow : public QDialog
Q_OBJECT
public:
explicit DBCLoadSaveWindow(DBCHandler *handler, const QVector<CANFrame> *frames, QWidget *parent = 0);
explicit DBCLoadSaveWindow(const QVector<CANFrame> *frames, QWidget *parent = 0);
~DBCLoadSaveWindow();
private slots:
+3 -3
View File
@@ -7,7 +7,7 @@
#define MT_COLUMN_COUNT 5
DBCMainEditor::DBCMainEditor(DBCHandler *handler, const QVector<CANFrame> *frames, QWidget *parent) :
DBCMainEditor::DBCMainEditor( const QVector<CANFrame> *frames, QWidget *parent) :
QDialog(parent),
ui(new Ui::DBCMainEditor)
{
@@ -15,7 +15,7 @@ DBCMainEditor::DBCMainEditor(DBCHandler *handler, const QVector<CANFrame> *frame
readSettings();
dbcHandler = handler;
dbcHandler = DBCHandler::getReference();
referenceFrames = frames;
QStringList headers;
@@ -47,7 +47,7 @@ DBCMainEditor::DBCMainEditor(DBCHandler *handler, const QVector<CANFrame> *frame
connect(ui->MessagesTable, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onCustomMenuMessage(QPoint)));
ui->MessagesTable->setContextMenuPolicy(Qt::CustomContextMenu);
sigEditor = new DBCSignalEditor(handler);
sigEditor = new DBCSignalEditor();
}
void DBCMainEditor::showEvent(QShowEvent* event)
+1 -1
View File
@@ -16,7 +16,7 @@ class DBCMainEditor : public QDialog
Q_OBJECT
public:
explicit DBCMainEditor(DBCHandler *handler, const QVector<CANFrame> *frames, QWidget *parent = 0);
explicit DBCMainEditor(const QVector<CANFrame> *frames, QWidget *parent = 0);
~DBCMainEditor();
void setFileIdx(int idx);
+3 -3
View File
@@ -5,7 +5,7 @@
#include <QMenu>
#include <QSettings>
DBCSignalEditor::DBCSignalEditor(DBCHandler *handler, QWidget *parent) :
DBCSignalEditor::DBCSignalEditor(QWidget *parent) :
QDialog(parent),
ui(new Ui::DBCSignalEditor)
{
@@ -15,7 +15,7 @@ DBCSignalEditor::DBCSignalEditor(DBCHandler *handler, QWidget *parent) :
qsrand(QDateTime::currentMSecsSinceEpoch());
dbcHandler = handler;
dbcHandler = DBCHandler::getReference();
dbcMessage = NULL;
currentSignal = NULL;
@@ -270,7 +270,7 @@ void DBCSignalEditor::onValuesCellChanged(int row,int col)
if (row == ui->valuesTable->rowCount() - 1)
{
DBC_VAL newVal;
DBC_VAL_ENUM_ENTRY newVal;
newVal.value = 0;
newVal.descript = "No Description";
currentSignal->valList.append(newVal);
+1 -1
View File
@@ -14,7 +14,7 @@ class DBCSignalEditor : public QDialog
Q_OBJECT
public:
explicit DBCSignalEditor(DBCHandler *handler, QWidget *parent = 0);
explicit DBCSignalEditor(QWidget *parent = 0);
void setMessageRef(DBC_MESSAGE *msg);
void showEvent(QShowEvent*);
void setFileIdx(int idx);
+15 -5
View File
@@ -82,14 +82,13 @@ MainWindow::MainWindow(QWidget *parent) :
isoWindow = NULL;
snifferWindow = NULL;
bisectWindow = NULL;
dbcHandler = new DBCHandler;
signalViewerWindow = NULL;
dbcHandler = DBCHandler::getReference();
bDirty = false;
inhibitFilterUpdate = false;
rxFrames = 0;
framesPerSec = 0;
model->setDBCHandler(dbcHandler);
connect(ui->actionSetup, SIGNAL(triggered(bool)), SLOT(showConnectionSettingsWindow()));
connect(ui->actionOpen_Log_File, &QAction::triggered, this, &MainWindow::handleLoadFile);
connect(ui->actionGraph_Dta, &QAction::triggered, this, &MainWindow::showGraphingWindow);
@@ -128,6 +127,7 @@ MainWindow::MainWindow(QWidget *parent) :
connect(ui->actionSniffer, &QAction::triggered, this, &MainWindow::showSnifferWindow);
connect(ui->actionMotorControlConfig, &QAction::triggered, this, &MainWindow::showMCConfigWindow);
connect(ui->actionCapture_Bisector, &QAction::triggered, this, &MainWindow::showBisectWindow);
connect(ui->actionSignal_Viewer, &QAction::triggered, this, &MainWindow::showSignalViewer);
connect(CANConManager::getInstance(), &CANConManager::framesReceived, model, &CANFrameModel::addFrames);
@@ -205,6 +205,7 @@ void MainWindow::killEmAll()
killWindow(bisectWindow);
killWindow(firmwareUploaderWindow);
killWindow(motorctrlConfigWindow);
killWindow(signalViewerWindow);
}
//forcefully close the window, kill it, and salt the earth
@@ -687,7 +688,7 @@ void MainWindow::showSettingsDialog()
void MainWindow::showGraphingWindow()
{
if (!graphingWindow) {
graphingWindow = new GraphingWindow(dbcHandler, model->getListReference());
graphingWindow = new GraphingWindow(model->getListReference());
connect(graphingWindow, SIGNAL(sendCenterTimeID(int32_t,double)), this, SLOT(gotCenterTimeID(int32_t,double)));
connect(this, SIGNAL(sendCenterTimeID(int32_t,double)), graphingWindow, SLOT(gotCenterTimeID(int32_t,double)));
}
@@ -869,11 +870,20 @@ void MainWindow::showDBCFileWindow()
{
if (!dbcFileWindow)
{
dbcFileWindow = new DBCLoadSaveWindow(dbcHandler, model->getListReference());
dbcFileWindow = new DBCLoadSaveWindow(model->getListReference());
}
dbcFileWindow->show();
}
void MainWindow::showSignalViewer()
{
if (!signalViewerWindow)
{
signalViewerWindow = new SignalViewerWindow();
}
signalViewerWindow->show();
}
void MainWindow::showConnectionSettingsWindow()
{
if (!connectionWindow)
+3
View File
@@ -29,6 +29,7 @@
#include "re/sniffer/snifferwindow.h"
#include "re/isotp_interpreterwindow.h"
#include "motorcontrollerconfigwindow.h"
#include "signalviewerwindow.h"
class ConnectionWindow;
@@ -73,6 +74,7 @@ private slots:
void showISOInterpreterWindow();
void showSnifferWindow();
void showBisectWindow();
void showSignalViewer();
void exitApp();
void handleSaveDecoded();
void connectionStatusUpdated(int conns);
@@ -144,6 +146,7 @@ private:
SnifferWindow* snifferWindow;
MotorControllerConfigWindow *motorctrlConfigWindow;
BisectWindow* bisectWindow;
SignalViewerWindow *signalViewerWindow;
//various private storage
QLabel lbStatusConnected;
+2 -2
View File
@@ -4,7 +4,7 @@
#include "mainwindow.h"
#include <QDebug>
GraphingWindow::GraphingWindow(DBCHandler *handler, const QVector<CANFrame> *frames, QWidget *parent) :
GraphingWindow::GraphingWindow(const QVector<CANFrame> *frames, QWidget *parent) :
QDialog(parent),
ui(new Ui::GraphingWindow)
{
@@ -13,7 +13,7 @@ GraphingWindow::GraphingWindow(DBCHandler *handler, const QVector<CANFrame> *fra
readSettings();
modelFrames = frames;
dbcHandler = handler;
dbcHandler = DBCHandler::getReference();
ui->graphingView->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectAxes |
QCP::iSelectLegend | QCP::iSelectPlottables);
+1 -1
View File
@@ -35,7 +35,7 @@ class GraphingWindow : public QDialog
Q_OBJECT
public:
explicit GraphingWindow(DBCHandler *handler, const QVector<CANFrame> *, QWidget *parent = 0);
explicit GraphingWindow(const QVector<CANFrame> *, QWidget *parent = 0);
~GraphingWindow();
void showEvent(QShowEvent*);
+18
View File
@@ -0,0 +1,18 @@
#include "signalviewerwindow.h"
#include "ui_signalviewerwindow.h"
SignalViewerWindow::SignalViewerWindow(QWidget *parent) :
QDialog(parent),
ui(new Ui::SignalViewerWindow)
{
ui->setupUi(this);
QStringList headers;
headers << "Signal" << "Value";
ui->tableViewer->setHorizontalHeaderLabels(headers);
}
SignalViewerWindow::~SignalViewerWindow()
{
delete ui;
}
+22
View File
@@ -0,0 +1,22 @@
#ifndef SIGNALVIEWERWINDOW_H
#define SIGNALVIEWERWINDOW_H
#include <QDialog>
namespace Ui {
class SignalViewerWindow;
}
class SignalViewerWindow : public QDialog
{
Q_OBJECT
public:
explicit SignalViewerWindow(QWidget *parent = 0);
~SignalViewerWindow();
private:
Ui::SignalViewerWindow *ui;
};
#endif // SIGNALVIEWERWINDOW_H
+6
View File
@@ -216,6 +216,7 @@
<addaction name="actionISO_TP_Decoder"/>
<addaction name="actionSniffer"/>
<addaction name="actionCapture_Bisector"/>
<addaction name="actionSignal_Viewer"/>
</widget>
<widget class="QMenu" name="menuSend_Frames">
<property name="title">
@@ -419,6 +420,11 @@
<string>Capture Bisector</string>
</property>
</action>
<action name="actionSignal_Viewer">
<property name="text">
<string>Signal Viewer</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
+83
View File
@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SignalViewerWindow</class>
<widget class="QDialog" name="SignalViewerWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>975</width>
<height>424</height>
</rect>
</property>
<property name="windowTitle">
<string>Signal Viewer</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="3,1">
<item>
<widget class="QTableWidget" name="tableViewer">
<property name="columnCount">
<number>2</number>
</property>
<attribute name="horizontalHeaderDefaultSectionSize">
<number>300</number>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderStretchLastSection">
<bool>false</bool>
</attribute>
<column/>
<column/>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Message</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cbMessages"/>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Signal</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cbSignals"/>
</item>
<item>
<widget class="QPushButton" name="btnAdd">
<property name="text">
<string>Add To Viewer</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>