Skip to content

Commit

Permalink
added Dashboard-ImPlotSink UI unit-test
Browse files Browse the repository at this point in the history
Signed-off-by: rstein <[email protected]>
  • Loading branch information
RalphSteinhagen committed Dec 19, 2024
1 parent ecf6954 commit 1dd0ad4
Show file tree
Hide file tree
Showing 11 changed files with 267 additions and 226 deletions.
4 changes: 2 additions & 2 deletions cmake/DependenciesSHAs.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
set(GIT_SHA_GNURADIO4 db0a2bcc4a14759c992ca89661f687b87d93e923 CACHE STRING "" FORCE) # main as of 2024-12-09
set(GIT_SHA_GNURADIO4 0da51c551ed2317c7afafa066971d2eac8617ae1 CACHE STRING "" FORCE) # main as of 2024-12-19

set(GIT_SHA_OPENCMW_CPP bb8996babab2000a4ae3612ea146a551a96e59c4 CACHE STRING "" FORCE) # main as of 2024-10-18

set(GIT_SHA_UT v2.0.1 CACHE STRING "" FORCE) # latest version as of 2023-12-19

set(GIT_SHA_GR_DIGITIZERS 749394c12285887eb8840ac4cd0c46f1d21b46b4 CACHE STRING "" FORCE) # dev-prototype as of 2024-11-06
set(GIT_SHA_GR_DIGITIZERS fbbcf42cdf51513bad3415fb35363b58fd4ebb16 CACHE STRING "" FORCE) # main as of 2024-12-18
2 changes: 1 addition & 1 deletion src/service/gnuradio/examples/function_generator.grc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
blocks:
- name: !!str ClockSource
id: !!str gr::basic::ClockSource
template_args: !!str "float"
template_args: !!str "unsigned char"
parameters:
do_zero_order_hold: !!bool true
n_samples_max: !!uint32 0
Expand Down
2 changes: 1 addition & 1 deletion src/service/gnuradio/examples/signal_generator.grc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
blocks:
- name: !!str ClockSource
id: !!str gr::basic::ClockSource
template_args: !!str "float"
template_args: !!str "unsigned char"
parameters:
do_zero_order_hold: !!bool true
n_samples_max: !!uint32 0
Expand Down
2 changes: 1 addition & 1 deletion src/service/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void registerTestBlocks(Registry& registry) {
gr::registerBlock<fair::picoscope::Picoscope4000a, fair::picoscope::AcquisitionMode::Streaming, float, std::int16_t>(registry); // ommitting gr::UncertainValue<float> for now, which would also be supported by picoscope block
gr::registerBlock<gr::basic::FunctionGenerator, float>(registry);
gr::registerBlock<gr::basic::SignalGenerator, float>(registry);
gr::registerBlock<gr::basic::DefaultClockSource, float>(registry);
gr::registerBlock<gr::basic::DefaultClockSource, std::uint8_t>(registry);
gr::registerBlock<MultiAdder, float>(registry);
fmt::print("providedBlocks:\n");
for (auto& blockName : registry.providedBlocks()) {
Expand Down
26 changes: 18 additions & 8 deletions src/ui/Dashboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ uint32_t randomColor() {

std::shared_ptr<DashboardSource> unsavedSource() {
static auto source = std::make_shared<DashboardSource>(DashboardSource{
.path = "Unsaved",
.path = "Unsaved",
.isValid = false,
});
return source;
Expand Down Expand Up @@ -234,7 +234,8 @@ Dashboard::Dashboard(PrivateTag, FlowGraphItem* fgItem, const std::shared_ptr<Da
};
}

Dashboard::~Dashboard() {}
Dashboard::~Dashboard() {
}

std::shared_ptr<Dashboard> Dashboard::create(FlowGraphItem* fgItem, const std::shared_ptr<DashboardDescription>& desc) { return std::make_shared<Dashboard>(PrivateTag{}, fgItem, desc); }

Expand Down Expand Up @@ -271,7 +272,16 @@ void Dashboard::load(const std::string& grcData, const std::string& dashboardDat
localFlowGraph.parse(grcData);
// Load is called after parsing the flowgraph so that we already have the list of sources
doLoad(dashboardData);
} catch (const gr::exception& e) {
#ifndef NDEBUG
fmt::println(stderr, "Dashboard::load(const std::string& grcData,const std::string& dashboardData): error: {}", e);
#endif
components::Notification::error(fmt::format("Error: {}", e.what()));
App::instance().closeDashboard();
} catch (const std::exception& e) {
#ifndef NDEBUG
fmt::println(stderr, "Dashboard::load(const std::string& grcData,const std::string& dashboardData): error: {}", e.what());
#endif
components::Notification::error(fmt::format("Error: {}", e.what()));
App::instance().closeDashboard();
}
Expand Down Expand Up @@ -299,7 +309,7 @@ void Dashboard::doLoad(const std::string& desc) {
}
const property_map srcMap = std::get<property_map>(src);

if (!srcMap.contains("block") || !std::holds_alternative<std::string>(srcMap.at("block")) //
if (!srcMap.contains("block") || !std::holds_alternative<std::string>(srcMap.at("block")) //
|| !srcMap.contains("name") || !std::holds_alternative<std::string>(srcMap.at("name")) //
|| !srcMap.contains("color")) {
throw std::runtime_error("invalid source color definition");
Expand Down Expand Up @@ -331,8 +341,8 @@ void Dashboard::doLoad(const std::string& desc) {
}
const property_map plotMap = std::get<property_map>(plotPmt);

if (!plotMap.contains("name") || !std::holds_alternative<std::string>(plotMap.at("name")) //
|| !plotMap.contains("axes") || !std::holds_alternative<std::vector<pmtv::pmt>>(plotMap.at("axes")) //
if (!plotMap.contains("name") || !std::holds_alternative<std::string>(plotMap.at("name")) //
|| !plotMap.contains("axes") || !std::holds_alternative<std::vector<pmtv::pmt>>(plotMap.at("axes")) //
|| !plotMap.contains("sources") || !std::holds_alternative<std::vector<pmtv::pmt>>(plotMap.at("sources")) //
|| !plotMap.contains("rect") || !std::holds_alternative<std::vector<pmtv::pmt>>(plotMap.at("rect"))) {
throw gr::exception("invalid plot definition");
Expand Down Expand Up @@ -623,8 +633,8 @@ void Dashboard::Service::emplaceBlock(std::string type, std::string params) {
message.cmd = gr::message::Command::Set;
message.endpoint = gr::graph::property::kEmplaceBlock;
message.data = gr::property_map{
{"type"s, std::move(type)}, //
{"parameters"s, std::move(params)} //
{"type"s, std::move(type)}, //
{"parameters"s, std::move(params)} //
};

opendigitizer::flowgraph::SerialisedFlowgraphMessage serialisedMessage{opendigitizer::gnuradio::serialiseMessage(message)};
Expand Down Expand Up @@ -711,4 +721,4 @@ void DashboardDescription::load(const std::shared_ptr<DashboardSource>& source,

std::shared_ptr<DashboardDescription> DashboardDescription::createEmpty(const std::string& name) { return std::make_shared<DashboardDescription>(DashboardDescription{.name = name, .source = unsavedSource(), .isFavorite = false, .lastUsed = std::nullopt}); }

} // namespace DigitizerUi
} // namespace DigitizerUi
Loading

0 comments on commit 1dd0ad4

Please sign in to comment.