You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
1.9 KiB
68 lines
1.9 KiB
3 years ago
|
#pragma once
|
||
|
|
||
3 years ago
|
#include <map>
|
||
2 years ago
|
#include <QList>
|
||
2 years ago
|
#include <QMetaType>
|
||
|
#include <QObject>
|
||
3 years ago
|
#include <QString>
|
||
2 years ago
|
#include <QSet>
|
||
|
#include <QDebug>
|
||
3 years ago
|
|
||
2 years ago
|
#include "tools/cabana/dbc/dbc.h"
|
||
|
#include "tools/cabana/dbc/dbcfile.h"
|
||
2 years ago
|
|
||
|
typedef QSet<uint8_t> SourceSet;
|
||
|
const SourceSet SOURCE_ALL = {};
|
||
3 years ago
|
|
||
3 years ago
|
class DBCManager : public QObject {
|
||
|
Q_OBJECT
|
||
|
|
||
|
public:
|
||
2 years ago
|
DBCManager(QObject *parent) {}
|
||
|
~DBCManager() {}
|
||
2 years ago
|
bool open(SourceSet s, const QString &dbc_file_name, QString *error = nullptr);
|
||
|
bool open(SourceSet s, const QString &name, const QString &content, QString *error = nullptr);
|
||
|
void closeAll();
|
||
|
|
||
2 years ago
|
void addSignal(const MessageId &id, const cabana::Signal &sig);
|
||
|
void updateSignal(const MessageId &id, const QString &sig_name, const cabana::Signal &sig);
|
||
2 years ago
|
void removeSignal(const MessageId &id, const QString &sig_name);
|
||
3 years ago
|
|
||
2 years ago
|
void updateMsg(const MessageId &id, const QString &name, uint32_t size);
|
||
|
void removeMsg(const MessageId &id);
|
||
2 years ago
|
|
||
|
std::map<MessageId, cabana::Msg> getMessages(uint8_t source);
|
||
|
const cabana::Msg *msg(const MessageId &id) const;
|
||
|
const cabana::Msg* msg(uint8_t source, const QString &name);
|
||
|
|
||
|
QStringList signalNames() const;
|
||
|
int msgCount() const;
|
||
|
int dbcCount() const;
|
||
|
|
||
|
std::optional<std::pair<SourceSet, DBCFile*>> findDBCFile(const uint8_t source) const;
|
||
|
std::optional<std::pair<SourceSet, DBCFile*>> findDBCFile(const MessageId &id) const;
|
||
|
|
||
|
QList<std::pair<SourceSet, DBCFile*>> dbc_files;
|
||
|
|
||
|
private:
|
||
|
SourceSet sources;
|
||
3 years ago
|
|
||
2 years ago
|
public slots:
|
||
2 years ago
|
void updateSources(const SourceSet &s);
|
||
2 years ago
|
|
||
3 years ago
|
signals:
|
||
2 years ago
|
void signalAdded(MessageId id, const cabana::Signal *sig);
|
||
2 years ago
|
void signalRemoved(const cabana::Signal *sig);
|
||
|
void signalUpdated(const cabana::Signal *sig);
|
||
2 years ago
|
void msgUpdated(MessageId id);
|
||
|
void msgRemoved(MessageId id);
|
||
3 years ago
|
void DBCFileChanged();
|
||
|
};
|
||
|
|
||
|
DBCManager *dbc();
|
||
2 years ago
|
|
||
2 years ago
|
inline QString msgName(const MessageId &id) {
|
||
3 years ago
|
auto msg = dbc()->msg(id);
|
||
2 years ago
|
return msg ? msg->name : UNTITLED;
|
||
3 years ago
|
}
|