More implementation of DBC loader, added fields to status bar on main screen.
This commit is contained in:
@@ -31,6 +31,7 @@ enum DBC_ATTRIBUTE_VAL_TYPE
|
|||||||
|
|
||||||
class DBC_ATTRIBUTE
|
class DBC_ATTRIBUTE
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
QString name;
|
QString name;
|
||||||
DBC_ATTRIBUTE_VAL_TYPE type;
|
DBC_ATTRIBUTE_VAL_TYPE type;
|
||||||
double startVal;
|
double startVal;
|
||||||
@@ -40,6 +41,7 @@ class DBC_ATTRIBUTE
|
|||||||
|
|
||||||
class DBC_VAL
|
class DBC_VAL
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
int value;
|
int value;
|
||||||
QString descript;
|
QString descript;
|
||||||
};
|
};
|
||||||
@@ -54,6 +56,7 @@ public:
|
|||||||
|
|
||||||
class DBC_SIGNAL
|
class DBC_SIGNAL
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
QString name;
|
QString name;
|
||||||
int startBit;
|
int startBit;
|
||||||
int signalSize;
|
int signalSize;
|
||||||
@@ -72,6 +75,7 @@ class DBC_SIGNAL
|
|||||||
|
|
||||||
class DBC_MESSAGE
|
class DBC_MESSAGE
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
int ID;
|
int ID;
|
||||||
QString name;
|
QString name;
|
||||||
QString comment;
|
QString comment;
|
||||||
|
|||||||
+87
-1
@@ -15,6 +15,7 @@ void DBCHandler::loadDBCFile(QString filename)
|
|||||||
QString line;
|
QString line;
|
||||||
QRegularExpression regex;
|
QRegularExpression regex;
|
||||||
QRegularExpressionMatch match;
|
QRegularExpressionMatch match;
|
||||||
|
DBC_MESSAGE *currentMessage;
|
||||||
|
|
||||||
qDebug() << "DBC File: " << filename;
|
qDebug() << "DBC File: " << filename;
|
||||||
|
|
||||||
@@ -36,6 +37,13 @@ void DBCHandler::loadDBCFile(QString filename)
|
|||||||
//captured 4 = the NODE responsible for this message
|
//captured 4 = the NODE responsible for this message
|
||||||
if (match.hasMatch())
|
if (match.hasMatch())
|
||||||
{
|
{
|
||||||
|
DBC_MESSAGE msg;
|
||||||
|
msg.ID = match.captured(1).toInt(); //the ID is always stored in decimal format
|
||||||
|
msg.name = match.captured(2);
|
||||||
|
msg.len = match.captured(3).toInt();
|
||||||
|
msg.sender = findNodeByName(match.captured(4));
|
||||||
|
dbc_messages.append(msg);
|
||||||
|
currentMessage = &dbc_messages.last();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (line.startsWith("SG_ "))
|
if (line.startsWith("SG_ "))
|
||||||
@@ -57,6 +65,41 @@ void DBCHandler::loadDBCFile(QString filename)
|
|||||||
|
|
||||||
if (match.hasMatch())
|
if (match.hasMatch())
|
||||||
{
|
{
|
||||||
|
DBC_SIGNAL sig;
|
||||||
|
sig.name = match.captured(1);
|
||||||
|
sig.startBit = match.captured(2).toInt();
|
||||||
|
sig.signalSize = match.captured(3).toInt();
|
||||||
|
int val = match.captured(4).toInt();
|
||||||
|
if (val < 2)
|
||||||
|
{
|
||||||
|
if (match.captured(5) == "+") sig.valType = UNSIGNED_INT;
|
||||||
|
else sig.valType = SIGNED_INT;
|
||||||
|
}
|
||||||
|
switch (val)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
sig.intelByteOrder = true;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
sig.intelByteOrder = false;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
sig.valType = SP_FLOAT;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
sig.valType = DP_FLOAT;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
sig.valType = STRING;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
sig.factor = match.captured(6).toDouble();
|
||||||
|
sig.bias = match.captured(7).toDouble();
|
||||||
|
sig.min = match.captured(8).toDouble();
|
||||||
|
sig.max = match.captured(9).toDouble();
|
||||||
|
sig.unitName = match.captured(10);
|
||||||
|
sig.receiver = findNodeByName(match.captured(11));
|
||||||
|
currentMessage->msgSignals.append(sig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (line.startsWith("BU_:"))
|
if (line.startsWith("BU_:"))
|
||||||
@@ -71,7 +114,13 @@ void DBCHandler::loadDBCFile(QString filename)
|
|||||||
qDebug() << "Found " << nodeStrings.count() << " node names";
|
qDebug() << "Found " << nodeStrings.count() << " node names";
|
||||||
for (int i = 0; i < nodeStrings.count(); i++)
|
for (int i = 0; i < nodeStrings.count(); i++)
|
||||||
{
|
{
|
||||||
qDebug() << nodeStrings[i];
|
//qDebug() << nodeStrings[i];
|
||||||
|
if (nodeStrings[i].length() > 1)
|
||||||
|
{
|
||||||
|
DBC_NODE node;
|
||||||
|
node.name = nodeStrings[i];
|
||||||
|
dbc_nodes.append(node);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -155,3 +204,40 @@ void DBCHandler::loadDBCFile(QString filename)
|
|||||||
}
|
}
|
||||||
inFile->close();
|
inFile->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DBC_NODE *DBCHandler::findNodeByName(QString name)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < dbc_nodes.length(); i++)
|
||||||
|
{
|
||||||
|
if (dbc_nodes[i].name == name)
|
||||||
|
{
|
||||||
|
return &dbc_nodes[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
DBC_MESSAGE *DBCHandler::findMsgByID(int id)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < dbc_messages.length(); i++)
|
||||||
|
{
|
||||||
|
if (dbc_messages[i].ID == id)
|
||||||
|
{
|
||||||
|
return &dbc_messages[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
DBC_SIGNAL *DBCHandler::findSignalByName(DBC_MESSAGE *msg, QString name)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < msg->msgSignals.length(); i++)
|
||||||
|
{
|
||||||
|
if (msg->msgSignals[i].name == name)
|
||||||
|
{
|
||||||
|
return &msg->msgSignals[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,10 @@ public slots:
|
|||||||
private:
|
private:
|
||||||
QList<DBC_NODE> dbc_nodes;
|
QList<DBC_NODE> dbc_nodes;
|
||||||
QList<DBC_MESSAGE> dbc_messages;
|
QList<DBC_MESSAGE> dbc_messages;
|
||||||
|
|
||||||
|
DBC_NODE *findNodeByName(QString name);
|
||||||
|
DBC_MESSAGE *findMsgByID(int id);
|
||||||
|
DBC_SIGNAL *findSignalByName(DBC_MESSAGE *msg, QString name);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DBCHANDLER_H
|
#endif // DBCHANDLER_H
|
||||||
|
|||||||
@@ -91,6 +91,12 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
connect(ui->actionEdit_Messages_Signals, SIGNAL(triggered(bool)), this, SLOT(showEditSignalsWindow()));
|
connect(ui->actionEdit_Messages_Signals, SIGNAL(triggered(bool)), this, SLOT(showEditSignalsWindow()));
|
||||||
connect(ui->actionSave_DBC_File, SIGNAL(triggered(bool)), this, SLOT(handleSaveDBC()));
|
connect(ui->actionSave_DBC_File, SIGNAL(triggered(bool)), this, SLOT(handleSaveDBC()));
|
||||||
|
|
||||||
|
lbStatusConnected.setText(tr("Not connected"));
|
||||||
|
lbStatusBauds.setText(tr("Baud 1: 0 Baud 2: 0"));
|
||||||
|
lbStatusDatabase.setText(tr("No database loaded"));
|
||||||
|
ui->statusBar->addWidget(&lbStatusConnected);
|
||||||
|
ui->statusBar->addWidget(&lbStatusBauds);
|
||||||
|
ui->statusBar->addWidget(&lbStatusDatabase);
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
@@ -178,6 +184,8 @@ void MainWindow::changeBaudRates()
|
|||||||
}
|
}
|
||||||
|
|
||||||
emit updateBaudRates(Speed1, Speed2);
|
emit updateBaudRates(Speed1, Speed2);
|
||||||
|
|
||||||
|
lbStatusBauds.setText(tr("Baud 1: ") + QString::number(Speed1) + tr(" Baud 2:") + QString::number(Speed2));
|
||||||
}
|
}
|
||||||
|
|
||||||
//CRTD format from Mark Webb-Johnson / OVMS project
|
//CRTD format from Mark Webb-Johnson / OVMS project
|
||||||
@@ -654,6 +662,7 @@ void MainWindow::connButtonPress()
|
|||||||
if (ports.at(x).portName() == ui->cbSerialPorts->currentText())
|
if (ports.at(x).portName() == ui->cbSerialPorts->currentText())
|
||||||
{
|
{
|
||||||
emit sendSerialPort(&ports[x]);
|
emit sendSerialPort(&ports[x]);
|
||||||
|
lbStatusConnected.setText(tr("Connected to port ") + ports[x].portName());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,6 +60,9 @@ private:
|
|||||||
FlowViewWindow *flowViewWindow;
|
FlowViewWindow *flowViewWindow;
|
||||||
FrameSenderWindow *frameSenderWindow;
|
FrameSenderWindow *frameSenderWindow;
|
||||||
DBCHandler *dbcHandler;
|
DBCHandler *dbcHandler;
|
||||||
|
QLabel lbStatusConnected;
|
||||||
|
QLabel lbStatusBauds;
|
||||||
|
QLabel lbStatusDatabase;
|
||||||
void loadCRTDFile(QString);
|
void loadCRTDFile(QString);
|
||||||
void loadNativeCSVFile(QString);
|
void loadNativeCSVFile(QString);
|
||||||
void loadGenericCSVFile(QString);
|
void loadGenericCSVFile(QString);
|
||||||
|
|||||||
Reference in New Issue
Block a user