From 6b179fe35c83af61c9263c6907eda146457565df Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Wed, 7 Jun 2023 23:07:01 -0500 Subject: [PATCH] Emit signals when a sweep is not updated (with reason) --- scwx-qt/source/scwx/qt/map/map_widget.cpp | 8 ++++++++ scwx-qt/source/scwx/qt/map/map_widget.hpp | 2 ++ scwx-qt/source/scwx/qt/types/map_types.hpp | 8 ++++++++ scwx-qt/source/scwx/qt/view/level2_product_view.cpp | 10 +++++++++- scwx-qt/source/scwx/qt/view/level3_radial_view.cpp | 8 ++++++++ scwx-qt/source/scwx/qt/view/level3_raster_view.cpp | 7 +++++++ scwx-qt/source/scwx/qt/view/radar_product_view.hpp | 2 ++ 7 files changed, 44 insertions(+), 1 deletion(-) diff --git a/scwx-qt/source/scwx/qt/map/map_widget.cpp b/scwx-qt/source/scwx/qt/map/map_widget.cpp index a91b9c7d..a5283c7e 100644 --- a/scwx-qt/source/scwx/qt/map/map_widget.cpp +++ b/scwx-qt/source/scwx/qt/map/map_widget.cpp @@ -1010,6 +1010,10 @@ void MapWidgetImpl::RadarProductViewConnect() Q_EMIT widget_->RadarSweepUpdated(); }, Qt::QueuedConnection); + connect(radarProductView.get(), + &view::RadarProductView::SweepNotComputed, + widget_, + &MapWidget::RadarSweepNotUpdated); } } @@ -1027,6 +1031,10 @@ void MapWidgetImpl::RadarProductViewDisconnect() &view::RadarProductView::SweepComputed, this, nullptr); + disconnect(radarProductView.get(), + &view::RadarProductView::SweepNotComputed, + widget_, + nullptr); } } diff --git a/scwx-qt/source/scwx/qt/map/map_widget.hpp b/scwx-qt/source/scwx/qt/map/map_widget.hpp index 51cfb230..7126f0de 100644 --- a/scwx-qt/source/scwx/qt/map/map_widget.hpp +++ b/scwx-qt/source/scwx/qt/map/map_widget.hpp @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -143,6 +144,7 @@ signals: void MapStyleChanged(const std::string& styleName); void RadarSiteUpdated(std::shared_ptr radarSite); void RadarSweepUpdated(); + void RadarSweepNotUpdated(types::NoUpdateReason reason); }; } // namespace map diff --git a/scwx-qt/source/scwx/qt/types/map_types.hpp b/scwx-qt/source/scwx/qt/types/map_types.hpp index d2c804a2..5853a188 100644 --- a/scwx-qt/source/scwx/qt/types/map_types.hpp +++ b/scwx-qt/source/scwx/qt/types/map_types.hpp @@ -21,6 +21,14 @@ enum class MapTime Archive }; +enum class NoUpdateReason +{ + NoChange, + NotLoaded, + InvalidProduct, + InvalidData +}; + std::string GetMapTimeName(MapTime mapTime); } // namespace types diff --git a/scwx-qt/source/scwx/qt/view/level2_product_view.cpp b/scwx-qt/source/scwx/qt/view/level2_product_view.cpp index 9e341ddd..06c912bc 100644 --- a/scwx-qt/source/scwx/qt/view/level2_product_view.cpp +++ b/scwx-qt/source/scwx/qt/view/level2_product_view.cpp @@ -402,6 +402,7 @@ void Level2ProductView::ComputeSweep() if (p->dataBlockType_ == wsr88d::rda::DataBlockType::Unknown) { + Q_EMIT SweepNotComputed(types::NoUpdateReason::InvalidProduct); return; } @@ -423,8 +424,14 @@ void Level2ProductView::ComputeSweep() SelectTime(foundTime); } - if (radarData == nullptr || radarData == p->elevationScan_) + if (radarData == nullptr) { + Q_EMIT SweepNotComputed(types::NoUpdateReason::NotLoaded); + return; + } + if (radarData == p->elevationScan_) + { + Q_EMIT SweepNotComputed(types::NoUpdateReason::NoChange); return; } @@ -443,6 +450,7 @@ void Level2ProductView::ComputeSweep() { logger_->warn("No moment data for {}", common::GetLevel2Name(p->product_)); + Q_EMIT SweepNotComputed(types::NoUpdateReason::InvalidData); return; } diff --git a/scwx-qt/source/scwx/qt/view/level3_radial_view.cpp b/scwx-qt/source/scwx/qt/view/level3_radial_view.cpp index ad87c7c4..9ec04d0b 100644 --- a/scwx-qt/source/scwx/qt/view/level3_radial_view.cpp +++ b/scwx-qt/source/scwx/qt/view/level3_radial_view.cpp @@ -133,6 +133,7 @@ void Level3RadialView::ComputeSweep() if (message == nullptr) { logger_->debug("Level 3 data not found"); + Q_EMIT SweepNotComputed(types::NoUpdateReason::NotLoaded); return; } @@ -142,11 +143,13 @@ void Level3RadialView::ComputeSweep() if (gpm == nullptr) { logger_->warn("Graphic Product Message not found"); + Q_EMIT SweepNotComputed(types::NoUpdateReason::InvalidData); return; } else if (gpm == graphic_product_message()) { // Skip if this is the message we previously processed + Q_EMIT SweepNotComputed(types::NoUpdateReason::NoChange); return; } set_graphic_product_message(gpm); @@ -160,6 +163,7 @@ void Level3RadialView::ComputeSweep() if (descriptionBlock == nullptr || symbologyBlock == nullptr) { logger_->warn("Missing blocks"); + Q_EMIT SweepNotComputed(types::NoUpdateReason::InvalidData); return; } @@ -168,6 +172,7 @@ void Level3RadialView::ComputeSweep() if (numberOfLayers < 1) { logger_->warn("No layers present in symbology block"); + Q_EMIT SweepNotComputed(types::NoUpdateReason::InvalidData); return; } @@ -219,6 +224,7 @@ void Level3RadialView::ComputeSweep() else { logger_->debug("No radial data found"); + Q_EMIT SweepNotComputed(types::NoUpdateReason::InvalidData); return; } @@ -227,6 +233,7 @@ void Level3RadialView::ComputeSweep() if (radials < 1 || radials > 720) { logger_->warn("Unsupported number of radials: {}", radials); + Q_EMIT SweepNotComputed(types::NoUpdateReason::InvalidData); return; } @@ -254,6 +261,7 @@ void Level3RadialView::ComputeSweep() if (gates < 1) { logger_->warn("No range bins in radial data"); + Q_EMIT SweepNotComputed(types::NoUpdateReason::InvalidData); return; } diff --git a/scwx-qt/source/scwx/qt/view/level3_raster_view.cpp b/scwx-qt/source/scwx/qt/view/level3_raster_view.cpp index e3347689..01bc3d54 100644 --- a/scwx-qt/source/scwx/qt/view/level3_raster_view.cpp +++ b/scwx-qt/source/scwx/qt/view/level3_raster_view.cpp @@ -116,6 +116,7 @@ void Level3RasterView::ComputeSweep() if (message == nullptr) { logger_->debug("Level 3 data not found"); + Q_EMIT SweepNotComputed(types::NoUpdateReason::NotLoaded); return; } @@ -125,11 +126,13 @@ void Level3RasterView::ComputeSweep() if (gpm == nullptr) { logger_->warn("Graphic Product Message not found"); + Q_EMIT SweepNotComputed(types::NoUpdateReason::InvalidData); return; } else if (gpm == graphic_product_message()) { // Skip if this is the message we previously processed + Q_EMIT SweepNotComputed(types::NoUpdateReason::NoChange); return; } set_graphic_product_message(gpm); @@ -143,6 +146,7 @@ void Level3RasterView::ComputeSweep() if (descriptionBlock == nullptr || symbologyBlock == nullptr) { logger_->warn("Missing blocks"); + Q_EMIT SweepNotComputed(types::NoUpdateReason::InvalidData); return; } @@ -151,6 +155,7 @@ void Level3RasterView::ComputeSweep() if (numberOfLayers < 1) { logger_->warn("No layers present in symbology block"); + Q_EMIT SweepNotComputed(types::NoUpdateReason::InvalidData); return; } @@ -182,6 +187,7 @@ void Level3RasterView::ComputeSweep() if (rasterData == nullptr) { logger_->debug("No raster data found"); + Q_EMIT SweepNotComputed(types::NoUpdateReason::InvalidData); return; } @@ -196,6 +202,7 @@ void Level3RasterView::ComputeSweep() if (maxColumns == 0) { logger_->debug("No raster bins found"); + Q_EMIT SweepNotComputed(types::NoUpdateReason::InvalidData); return; } diff --git a/scwx-qt/source/scwx/qt/view/radar_product_view.hpp b/scwx-qt/source/scwx/qt/view/radar_product_view.hpp index 16d23a80..dd92db58 100644 --- a/scwx-qt/source/scwx/qt/view/radar_product_view.hpp +++ b/scwx-qt/source/scwx/qt/view/radar_product_view.hpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -75,6 +76,7 @@ protected slots: signals: void ColorTableUpdated(); void SweepComputed(); + void SweepNotComputed(types::NoUpdateReason reason); private: std::unique_ptr p;