Major mondification to how DBC files are handled in-program. Now it is
much more object oriented and encapsulated. The biggest addition is that it is now possible to support multiple DBC files being loaded at once with each file associated to one or both buses. Note that currently the program still does not support multiple DBC files but the groundwork is there.
This commit is contained in:
+68
-21
@@ -6,42 +6,89 @@
|
||||
#include "can_structs.h"
|
||||
|
||||
/*
|
||||
* For ease of quick testing and development this is all run together.
|
||||
* It should be decoupled once the functionality is confirmed.
|
||||
* TODO:
|
||||
* Finish coding up the decoupled design
|
||||
*
|
||||
*/
|
||||
|
||||
class DBCHandler : public QObject
|
||||
|
||||
class DBCSignalHandler: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DBCHandler(QObject *parent = 0);
|
||||
void loadDBCFile(QString);
|
||||
void saveDBCFile(QString);
|
||||
void listDebugging();
|
||||
QString processSignal(const CANFrame &frame, const DBC_SIGNAL &sig);
|
||||
bool processSignalInt(const CANFrame &frame, const DBC_SIGNAL &sig, int32_t &outValue);
|
||||
bool processSignalDouble(const CANFrame &frame, const DBC_SIGNAL &sig, double &outValue);
|
||||
DBC_NODE *findNodeByName(QString name);
|
||||
DBC_NODE *findNodeByIdx(int idx);
|
||||
DBC_SIGNAL *findSignalByName(QString name);
|
||||
DBC_SIGNAL *findSignalByIdx(int idx);
|
||||
bool addSignal(DBC_SIGNAL &sig);
|
||||
bool removeSignal(DBC_SIGNAL *sig);
|
||||
bool removeSignal(int idx);
|
||||
bool removeSignal(QString name);
|
||||
void removeAllSignals();
|
||||
int getCount();
|
||||
private:
|
||||
QList<DBC_SIGNAL> sigs; //signals is a reserved word or I'd have used that
|
||||
};
|
||||
|
||||
class DBCMessageHandler: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DBC_MESSAGE *findMsgByID(int id);
|
||||
DBC_MESSAGE *findMsgByIdx(int idx);
|
||||
DBC_MESSAGE *findMsgByName(QString name);
|
||||
bool addMessage(DBC_MESSAGE &msg);
|
||||
bool removeMessage(DBC_MESSAGE *msg);
|
||||
bool removeMessageByIndex(int idx);
|
||||
bool removeMessage(int ID);
|
||||
bool removeMessage(QString name);
|
||||
void removeAllMessages();
|
||||
int getCount();
|
||||
private:
|
||||
QList<DBC_MESSAGE> messages;
|
||||
};
|
||||
|
||||
DBC_SIGNAL *findSignalByName(DBC_MESSAGE *msg, QString name);
|
||||
DBC_SIGNAL *findSignalByIdx(DBC_MESSAGE *msg, int idx);
|
||||
//technically there should be a node handler too but I'm sort of treating nodes as second class
|
||||
//citizens since they aren't really all that important (to me anyway)
|
||||
class DBCFile: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DBCFile();
|
||||
DBCFile(const DBCFile& cpy);
|
||||
DBCFile& operator=(const DBCFile& cpy);
|
||||
DBC_NODE *findNodeByName(QString name);
|
||||
DBC_NODE *findNodeByIdx(int idx);
|
||||
void saveFile(QString);
|
||||
void loadFile(QString);
|
||||
QString getFullFilename();
|
||||
QString getFilename();
|
||||
QString getPath();
|
||||
int getAssocBus();
|
||||
void setAssocBus(int bus);
|
||||
|
||||
DBCMessageHandler *messageHandler;
|
||||
QList<DBC_NODE> dbc_nodes;
|
||||
QList<DBC_MESSAGE> dbc_messages;
|
||||
private:
|
||||
QString fileName;
|
||||
QString filePath;
|
||||
int assocBuses; //-1 = all buses, 0 = first bus, 1 = second bus
|
||||
};
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
class DBCHandler: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
void loadDBCFile(int);
|
||||
void saveDBCFile(int);
|
||||
void removeDBCFile(int);
|
||||
void removeAllFiles();
|
||||
void swapFiles(int pos1, int pos2);
|
||||
DBC_MESSAGE* findMessage(const CANFrame &frame);
|
||||
int getFileCount();
|
||||
DBCFile* getFileByIdx(int idx);
|
||||
DBCFile* getFileByName(QString name);
|
||||
|
||||
private:
|
||||
|
||||
unsigned char reverseBits(unsigned char);
|
||||
unsigned char processByte(unsigned char, int, int);
|
||||
QList<DBCFile> loadedFiles;
|
||||
};
|
||||
|
||||
#endif // DBCHANDLER_H
|
||||
|
||||
Reference in New Issue
Block a user