Skip to content

Commit

Permalink
Hook up SignalSelector UI to DNS results
Browse files Browse the repository at this point in the history
Signed-off-by: Magnus Groß <[email protected]>
  • Loading branch information
vimpostor committed Jul 24, 2024
1 parent 1c38792 commit 6e5c98a
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 176 deletions.
16 changes: 16 additions & 0 deletions src/service/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <fstream>
#include <thread>

#include "FAIR/DeviceNameHelper.hpp"
#include "dashboard/dashboardWorker.hpp"
#include "gnuradio/GnuRadioWorker.hpp"
#include "rest/fileserverRestBackend.hpp"
Expand Down Expand Up @@ -172,6 +173,21 @@ int main(int argc, char **argv) {

std::vector<SignalEntry> registeredSignals;
grAcqWorker.setUpdateSignalEntriesCallback([&registeredSignals, &dns_client, &restUrl](std::vector<SignalEntry> signals) {
if (::getenv("OPENDIGITIZER_LOAD_TEST_SIGNALS")) {
size_t x = 0;
for (auto& i : fair::testDeviceNames) {
if (x >= 12) {
break;
}
const auto info = fair::getDeviceInfo(i);
SignalEntry entry;
entry.name = info.name;
entry.sample_rate = 1.f;
signals.push_back(entry);
x++;
}
}

std::ranges::sort(signals);
std::vector<SignalEntry> toUnregister;
std::ranges::set_difference(registeredSignals, signals, std::back_inserter(toUnregister));
Expand Down
7 changes: 6 additions & 1 deletion src/ui/RemoteSignalSources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,12 @@ void SignalList::update() {
});
try {
std::unique_lock l{signalsMutex};
dnsClient.querySignalsAsync([this](const std::vector<opencmw::service::dns::Entry>& entries) { signals = entries; }, queryEntry);
dnsClient.querySignalsAsync([this](const std::vector<opencmw::service::dns::Entry>& entries) {
signals = entries;
if (updateSignalsCallback) {
updateSignalsCallback(signals);
}
});
} catch (const std::exception& e) {
std::cerr << "Error loading signals: " << e.what() << std::endl;
}
Expand Down
1 change: 1 addition & 0 deletions src/ui/RemoteSignalSources.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class SignalList {

public:
std::function<void(opencmw::service::dns::Entry)> addRemoteSignalCallback;
std::function<void(const std::vector<opencmw::service::dns::Entry>&)> updateSignalsCallback;

explicit SignalList(QueryFilterElementList& filters);
~SignalList();
Expand Down
Loading

0 comments on commit 6e5c98a

Please sign in to comment.