mirror of
https://github.com/MoreTore/openpilot.git
synced 2026-08-24 01:23:45 +08:00
c5543bf21d
* support muxed signals
* write multiplexor in generateDBC
* edit multiplex_switch_value in signalView
* no overlapping warning for mux signals
* group signals by multiplexer indicator
* display freq for each multiplexed signals
* remove all multiplexed signals after switch deleted
* disable switch value
* cleanup
* historyView: use getValue
* sort by switch value
* check address
* rename variables
* rename signale type
* parse multiplexed signals in dbcmanater
* cache signal color in member variable
* cleanup num_decimals
* remove sources from dbcmanager and cleanup code
* fix sort
* check mltiplex in operator==
* fix sizehint
* convert multipledxed to normal after changing multiplxor to normal
* throw error on multiple 'M' signals
* add comment
* parse multipled signals in test case
* cleanup
* change order
* cleanup open
* display multiplexed/overlapping signals in binaryview
* sort overlapped signals by size
* refactor dbcmanager
* trimmed
* parse multiplexed signals in test case
* cleanup
* merge master
* space
* use pointer for sigs
* alldbcFiles
* cleanup
* cleanup sparkline
* use std::vector
* skip draw sparkline if isnull
* bigger capacity
old-commit-hash: e08569b0f3
79 lines
2.4 KiB
C++
79 lines
2.4 KiB
C++
#pragma once
|
|
|
|
#include <memory>
|
|
#include <map>
|
|
#include <set>
|
|
|
|
#include "tools/cabana/dbc/dbcfile.h"
|
|
|
|
typedef std::set<int> SourceSet;
|
|
const SourceSet SOURCE_ALL = {-1};
|
|
const int INVALID_SOURCE = 0xff;
|
|
inline bool operator<(const std::shared_ptr<DBCFile> &l, const std::shared_ptr<DBCFile> &r) { return l.get() < r.get(); }
|
|
|
|
class DBCManager : public QObject {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
DBCManager(QObject *parent) : QObject(parent) {}
|
|
~DBCManager() {}
|
|
bool open(const SourceSet &sources, const QString &dbc_file_name, QString *error = nullptr);
|
|
bool open(const SourceSet &sources, const QString &name, const QString &content, QString *error = nullptr);
|
|
void close(const SourceSet &sources);
|
|
void close(DBCFile *dbc_file);
|
|
void closeAll();
|
|
|
|
void addSignal(const MessageId &id, const cabana::Signal &sig);
|
|
void updateSignal(const MessageId &id, const QString &sig_name, const cabana::Signal &sig);
|
|
void removeSignal(const MessageId &id, const QString &sig_name);
|
|
|
|
void updateMsg(const MessageId &id, const QString &name, uint32_t size, const QString &comment);
|
|
void removeMsg(const MessageId &id);
|
|
|
|
QString newMsgName(const MessageId &id);
|
|
QString newSignalName(const MessageId &id);
|
|
const QList<uint8_t>& mask(const MessageId &id);
|
|
|
|
const std::map<uint32_t, cabana::Msg> &getMessages(uint8_t source);
|
|
cabana::Msg *msg(const MessageId &id);
|
|
cabana::Msg* msg(uint8_t source, const QString &name);
|
|
|
|
QStringList signalNames();
|
|
int signalCount(const MessageId &id);
|
|
int signalCount();
|
|
int msgCount();
|
|
int dbcCount();
|
|
int nonEmptyDBCCount();
|
|
|
|
const SourceSet sources(const DBCFile *dbc_file) const;
|
|
DBCFile *findDBCFile(const uint8_t source);
|
|
inline DBCFile *findDBCFile(const MessageId &id) { return findDBCFile(id.source); }
|
|
std::set<DBCFile *> allDBCFiles();
|
|
|
|
signals:
|
|
void signalAdded(MessageId id, const cabana::Signal *sig);
|
|
void signalRemoved(const cabana::Signal *sig);
|
|
void signalUpdated(const cabana::Signal *sig);
|
|
void msgUpdated(MessageId id);
|
|
void msgRemoved(MessageId id);
|
|
void DBCFileChanged();
|
|
|
|
private:
|
|
std::map<int, std::shared_ptr<DBCFile>> dbc_files;
|
|
};
|
|
|
|
DBCManager *dbc();
|
|
|
|
inline QString msgName(const MessageId &id) {
|
|
auto msg = dbc()->msg(id);
|
|
return msg ? msg->name : UNTITLED;
|
|
}
|
|
|
|
inline QString toString(const SourceSet &ss) {
|
|
QStringList ret;
|
|
for (auto s : ss) {
|
|
ret << (s == -1 ? QString("all") : QString::number(s));
|
|
}
|
|
return ret.join(", ");
|
|
}
|