Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Čukić <[email protected]>
  • Loading branch information
ivan-cukic committed Nov 8, 2024
1 parent d20675a commit 35b1fd3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
10 changes: 7 additions & 3 deletions src/service/gnuradio/GnuRadioAcquisitionWorker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,14 @@ class GnuRadioAcquisitionWorker : public Worker<serviceName, TimeDomainContext,

void setUpdateSignalEntriesCallback(std::function<void(std::vector<SignalEntry>)> callback) { _updateSignalEntriesCallback = std::move(callback); }

template<typename Fn>
auto withGraph(Fn fn) {
template<typename Fn, typename Ret = std::invoke_result_t<Fn, gr::Graph&>>
std::optional<Ret> withGraph(Fn fn) {
std::lock_guard lg{_graphChangeMutex};
return fn(_scheduler->graph());
if (!_scheduler) {
return {};
} else {
return {fn(_scheduler->graph())};
}
}

private:
Expand Down
7 changes: 5 additions & 2 deletions src/service/gnuradio/GnuRadioFlowgraphWorker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,11 @@ class GnuRadioFlowGraphWorker : public Worker<serviceName, flowgraph::FilterCont

void handleGetRequest(flowgraph::Flowgraph& out) {
std::lock_guard lockGuard(_flowgraphLock);
out = _flowgraph;
out.serialisedFlowgraph = _acquisitionWorker.withGraph([](const auto& graph) { return gr::saveGrc(graph); });
out = _flowgraph;

auto serialisedFlowgraph = _acquisitionWorker.withGraph([](const auto& graph) { return gr::saveGrc(graph); });

out.serialisedFlowgraph = serialisedFlowgraph.value_or("");
}

void replaceGraphGRC(const flowgraph::Flowgraph& in, flowgraph::Flowgraph& out) {
Expand Down
11 changes: 8 additions & 3 deletions src/service/gnuradio/test/qa_GnuRadioWorker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,15 @@ struct TestSetup {
message.endpoint = "ReplaceGraphGRC";
opendigitizer::flowgraph::storeFlowgraphToMessage(fg, message);

const auto serialised = serialiseMessage(message);
IoBuffer buffer(serialised.data(), serialised.size());
const auto serialisedMessage = serialiseMessage(message);

fmt::print("Sending ReplaceGraphGRC message to the service\n");
opendigitizer::flowgraph::SerialisedFlowgraphMessage serialised;
serialised.data = serialisedMessage;

IoBuffer buffer;
opencmw::serialise<opencmw::Json>(buffer, serialised);

fmt::print("Sending ReplaceGraphGRC message to the service {}\n", buffer);
client.set(URI("mdp://127.0.0.1:12346/GnuRadio/FlowGraph"), std::move(callback), std::move(buffer));
}

Expand Down

0 comments on commit 35b1fd3

Please sign in to comment.