forked from IQ.Lvbs/IQ.Pilot
IQ.Pilot Release Commit @ 0b96bd5
This commit is contained in:
@@ -17,7 +17,7 @@ bool DBCManager::open(const SourceSet &sources, const std::string &dbc_file_name
|
||||
return false;
|
||||
}
|
||||
|
||||
if (callbacks_.file_changed) callbacks_.file_changed();
|
||||
fileChanged();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ bool DBCManager::open(const SourceSet &sources, const std::string &name, const s
|
||||
return false;
|
||||
}
|
||||
|
||||
if (callbacks_.file_changed) callbacks_.file_changed();
|
||||
fileChanged();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -40,26 +40,26 @@ void DBCManager::close(const SourceSet &sources) {
|
||||
for (auto s : sources) {
|
||||
dbc_files[s] = nullptr;
|
||||
}
|
||||
if (callbacks_.file_changed) callbacks_.file_changed();
|
||||
fileChanged();
|
||||
}
|
||||
|
||||
void DBCManager::close(DBCFile *dbc_file) {
|
||||
for (auto &[_, f] : dbc_files) {
|
||||
if (f.get() == dbc_file) f = nullptr;
|
||||
}
|
||||
if (callbacks_.file_changed) callbacks_.file_changed();
|
||||
fileChanged();
|
||||
}
|
||||
|
||||
void DBCManager::closeAll() {
|
||||
dbc_files.clear();
|
||||
if (callbacks_.file_changed) callbacks_.file_changed();
|
||||
fileChanged();
|
||||
}
|
||||
|
||||
void DBCManager::addSignal(const MessageId &id, const cabana::Signal &sig) {
|
||||
if (auto m = msg(id)) {
|
||||
if (auto s = m->addSignal(sig)) {
|
||||
if (callbacks_.signal_added) callbacks_.signal_added(id, s);
|
||||
if (callbacks_.mask_updated) callbacks_.mask_updated();
|
||||
signalAdded(id, s);
|
||||
maskUpdated();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -67,8 +67,8 @@ void DBCManager::addSignal(const MessageId &id, const cabana::Signal &sig) {
|
||||
void DBCManager::updateSignal(const MessageId &id, const std::string &sig_name, const cabana::Signal &sig) {
|
||||
if (auto m = msg(id)) {
|
||||
if (auto s = m->updateSignal(sig_name, sig)) {
|
||||
if (callbacks_.signal_updated) callbacks_.signal_updated(s);
|
||||
if (callbacks_.mask_updated) callbacks_.mask_updated();
|
||||
signalUpdated(s);
|
||||
maskUpdated();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -76,26 +76,26 @@ void DBCManager::updateSignal(const MessageId &id, const std::string &sig_name,
|
||||
void DBCManager::removeSignal(const MessageId &id, const std::string &sig_name) {
|
||||
if (auto m = msg(id)) {
|
||||
if (auto s = m->sig(sig_name)) {
|
||||
if (callbacks_.signal_removed) callbacks_.signal_removed(s);
|
||||
signalRemoved(s);
|
||||
m->removeSignal(sig_name);
|
||||
if (callbacks_.mask_updated) callbacks_.mask_updated();
|
||||
maskUpdated();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DBCManager::updateMsg(const MessageId &id, const std::string &name, uint32_t size, const std::string &node, const std::string &comment) {
|
||||
auto dbc_file = findDBCFile(id);
|
||||
assert(dbc_file); // This should be impossible
|
||||
assert(dbc_file);
|
||||
dbc_file->updateMsg(id, name, size, node, comment);
|
||||
if (callbacks_.msg_updated) callbacks_.msg_updated(id);
|
||||
msgUpdated(id);
|
||||
}
|
||||
|
||||
void DBCManager::removeMsg(const MessageId &id) {
|
||||
auto dbc_file = findDBCFile(id);
|
||||
assert(dbc_file); // This should be impossible
|
||||
assert(dbc_file);
|
||||
dbc_file->removeMsg(id);
|
||||
if (callbacks_.msg_removed) callbacks_.msg_removed(id);
|
||||
if (callbacks_.mask_updated) callbacks_.mask_updated();
|
||||
msgRemoved(id);
|
||||
maskUpdated();
|
||||
}
|
||||
|
||||
std::string DBCManager::newMsgName(const MessageId &id) {
|
||||
@@ -126,7 +126,7 @@ cabana::Msg *DBCManager::msg(uint8_t source, const std::string &name) {
|
||||
}
|
||||
|
||||
std::vector<std::string> DBCManager::signalNames() {
|
||||
// Used for autocompletion
|
||||
|
||||
std::set<std::string> names;
|
||||
for (auto &f : allDBCFiles()) {
|
||||
for (auto &[_, m] : f->getMessages()) {
|
||||
@@ -141,12 +141,19 @@ std::vector<std::string> DBCManager::signalNames() {
|
||||
}
|
||||
|
||||
int DBCManager::nonEmptyDBCCount() {
|
||||
auto files = allDBCFiles();
|
||||
return std::count_if(files.cbegin(), files.cend(), [](auto &f) { return !f->isEmpty(); });
|
||||
return nonEmptyDBCFiles().size();
|
||||
}
|
||||
|
||||
std::vector<DBCFile *> DBCManager::nonEmptyDBCFiles() {
|
||||
std::vector<DBCFile *> files;
|
||||
for (auto f : allDBCFiles()) {
|
||||
if (!f->isEmpty()) files.push_back(f);
|
||||
}
|
||||
return files;
|
||||
}
|
||||
|
||||
DBCFile *DBCManager::findDBCFile(const uint8_t source) {
|
||||
// Find DBC file that matches id.source, fall back to SOURCE_ALL if no specific DBC is found
|
||||
|
||||
auto it = dbc_files.count(source) ? dbc_files.find(source) : dbc_files.find(-1);
|
||||
return it != dbc_files.end() ? it->second.get() : nullptr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user