mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 15:50:05 +00:00
Allow radar product manager to be updated in a view
This commit is contained in:
parent
c9936a5ea4
commit
5dd1a327c8
11 changed files with 87 additions and 53 deletions
|
|
@ -67,12 +67,15 @@ class RadarProductManagerImpl
|
|||
public:
|
||||
struct ProviderManager
|
||||
{
|
||||
explicit ProviderManager(common::RadarProductGroup group) :
|
||||
ProviderManager(group, "???")
|
||||
explicit ProviderManager(const std::string& radarId,
|
||||
common::RadarProductGroup group) :
|
||||
ProviderManager(radarId, group, "???")
|
||||
{
|
||||
}
|
||||
explicit ProviderManager(common::RadarProductGroup group,
|
||||
explicit ProviderManager(const std::string& radarId,
|
||||
common::RadarProductGroup group,
|
||||
const std::string& product) :
|
||||
radarId_ {radarId},
|
||||
group_ {group},
|
||||
product_ {product},
|
||||
refreshEnabled_ {false},
|
||||
|
|
@ -87,6 +90,7 @@ public:
|
|||
|
||||
void Disable();
|
||||
|
||||
const std::string radarId_;
|
||||
const common::RadarProductGroup group_;
|
||||
const std::string product_;
|
||||
bool refreshEnabled_;
|
||||
|
|
@ -108,8 +112,8 @@ public:
|
|||
level3ProductRecordsMap_ {},
|
||||
level2ProductRecordMutex_ {},
|
||||
level3ProductRecordMutex_ {},
|
||||
level2ProviderManager_ {
|
||||
std::make_shared<ProviderManager>(common::RadarProductGroup::Level2)},
|
||||
level2ProviderManager_ {std::make_shared<ProviderManager>(
|
||||
radarId_, common::RadarProductGroup::Level2)},
|
||||
level3ProviderManagerMap_ {},
|
||||
level3ProviderManagerMutex_ {},
|
||||
initializeMutex_ {},
|
||||
|
|
@ -173,9 +177,9 @@ public:
|
|||
std::shared_ptr<request::NexradFileRequest> request,
|
||||
std::mutex& mutex);
|
||||
|
||||
std::string radarId_;
|
||||
bool initialized_;
|
||||
bool level3ProductsInitialized_;
|
||||
const std::string radarId_;
|
||||
bool initialized_;
|
||||
bool level3ProductsInitialized_;
|
||||
|
||||
std::shared_ptr<config::RadarSite> radarSite_;
|
||||
|
||||
|
|
@ -215,12 +219,15 @@ std::string RadarProductManagerImpl::ProviderManager::name() const
|
|||
|
||||
if (group_ == common::RadarProductGroup::Level3)
|
||||
{
|
||||
name = std::format(
|
||||
"{}, {}", common::GetRadarProductGroupName(group_), product_);
|
||||
name = std::format("{}, {}, {}",
|
||||
radarId_,
|
||||
common::GetRadarProductGroupName(group_),
|
||||
product_);
|
||||
}
|
||||
else
|
||||
{
|
||||
name = common::GetRadarProductGroupName(group_);
|
||||
name = std::format(
|
||||
"{}, {}", radarId_, common::GetRadarProductGroupName(group_));
|
||||
}
|
||||
|
||||
return name;
|
||||
|
|
@ -380,7 +387,7 @@ RadarProductManagerImpl::GetLevel3ProviderManager(const std::string& product)
|
|||
std::forward_as_tuple(product),
|
||||
std::forward_as_tuple(
|
||||
std::make_shared<RadarProductManagerImpl::ProviderManager>(
|
||||
common::RadarProductGroup::Level3, product)));
|
||||
radarId_, common::RadarProductGroup::Level3, product)));
|
||||
level3ProviderManagerMap_.at(product)->provider_ =
|
||||
provider::NexradDataProviderFactory::CreateLevel3DataProvider(radarId_,
|
||||
product);
|
||||
|
|
|
|||
|
|
@ -41,11 +41,8 @@ static const std::unordered_map<common::Level2Product,
|
|||
class Level2ProductViewImpl
|
||||
{
|
||||
public:
|
||||
explicit Level2ProductViewImpl(
|
||||
common::Level2Product product,
|
||||
std::shared_ptr<manager::RadarProductManager> radarProductManager) :
|
||||
explicit Level2ProductViewImpl(common::Level2Product product) :
|
||||
product_ {product},
|
||||
radarProductManager_ {radarProductManager},
|
||||
selectedElevation_ {0.0f},
|
||||
selectedTime_ {},
|
||||
elevationScan_ {nullptr},
|
||||
|
|
@ -72,9 +69,8 @@ public:
|
|||
void SetProduct(const std::string& productName);
|
||||
void SetProduct(common::Level2Product product);
|
||||
|
||||
common::Level2Product product_;
|
||||
wsr88d::rda::DataBlockType dataBlockType_;
|
||||
std::shared_ptr<manager::RadarProductManager> radarProductManager_;
|
||||
common::Level2Product product_;
|
||||
wsr88d::rda::DataBlockType dataBlockType_;
|
||||
|
||||
float selectedElevation_;
|
||||
std::chrono::system_clock::time_point selectedTime_;
|
||||
|
|
@ -109,7 +105,8 @@ public:
|
|||
Level2ProductView::Level2ProductView(
|
||||
common::Level2Product product,
|
||||
std::shared_ptr<manager::RadarProductManager> radarProductManager) :
|
||||
p(std::make_unique<Level2ProductViewImpl>(product, radarProductManager))
|
||||
RadarProductView(radarProductManager),
|
||||
p(std::make_unique<Level2ProductViewImpl>(product))
|
||||
{
|
||||
}
|
||||
Level2ProductView::~Level2ProductView() = default;
|
||||
|
|
@ -375,9 +372,12 @@ void Level2ProductView::ComputeSweep()
|
|||
|
||||
std::scoped_lock sweepLock(sweep_mutex());
|
||||
|
||||
std::shared_ptr<manager::RadarProductManager> radarProductManager =
|
||||
radar_product_manager();
|
||||
|
||||
std::shared_ptr<wsr88d::rda::ElevationScan> radarData;
|
||||
std::tie(radarData, p->elevationCut_, p->elevationCuts_) =
|
||||
p->radarProductManager_->GetLevel2Data(
|
||||
radarProductManager->GetLevel2Data(
|
||||
p->dataBlockType_, p->selectedElevation_, p->selectedTime_);
|
||||
if (radarData == nullptr || radarData == p->elevationScan_)
|
||||
{
|
||||
|
|
@ -390,7 +390,7 @@ void Level2ProductView::ComputeSweep()
|
|||
common::RadialSize::_0_5Degree :
|
||||
common::RadialSize::_1Degree;
|
||||
const std::vector<float>& coordinates =
|
||||
p->radarProductManager_->coordinates(radialSize);
|
||||
radarProductManager->coordinates(radialSize);
|
||||
|
||||
auto radarData0 = (*radarData)[0];
|
||||
auto momentData0 = radarData0->moment_data_block(p->dataBlockType_);
|
||||
|
|
@ -492,7 +492,7 @@ void Level2ProductView::ComputeSweep()
|
|||
|
||||
// Compute gate size (number of base 250m gates per bin)
|
||||
const uint16_t gateSizeMeters =
|
||||
static_cast<uint16_t>(p->radarProductManager_->gate_size());
|
||||
static_cast<uint16_t>(radarProductManager->gate_size());
|
||||
const uint16_t gateSize =
|
||||
std::max<uint16_t>(1, dataMomentInterval / gateSizeMeters);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
#include <scwx/common/color_table.hpp>
|
||||
#include <scwx/common/products.hpp>
|
||||
#include <scwx/qt/manager/radar_product_manager.hpp>
|
||||
#include <scwx/qt/view/radar_product_view.hpp>
|
||||
|
||||
#include <chrono>
|
||||
|
|
|
|||
|
|
@ -53,7 +53,10 @@ public:
|
|||
float savedOffset_;
|
||||
};
|
||||
|
||||
Level3ProductView::Level3ProductView(const std::string& product) :
|
||||
Level3ProductView::Level3ProductView(
|
||||
const std::string& product,
|
||||
std::shared_ptr<manager::RadarProductManager> radarProductManager) :
|
||||
RadarProductView(radarProductManager),
|
||||
p(std::make_unique<Level3ProductViewImpl>(product))
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,9 @@ class Level3ProductView : public RadarProductView
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Level3ProductView(const std::string& product);
|
||||
explicit Level3ProductView(
|
||||
const std::string& product,
|
||||
std::shared_ptr<manager::RadarProductManager> radarProductManager);
|
||||
virtual ~Level3ProductView();
|
||||
|
||||
const std::vector<boost::gil::rgba8_pixel_t>& color_table() const override;
|
||||
|
|
|
|||
|
|
@ -26,9 +26,7 @@ static constexpr uint32_t VALUES_PER_VERTEX = 2u;
|
|||
class Level3RadialViewImpl
|
||||
{
|
||||
public:
|
||||
explicit Level3RadialViewImpl(
|
||||
std::shared_ptr<manager::RadarProductManager> radarProductManager) :
|
||||
radarProductManager_ {radarProductManager},
|
||||
explicit Level3RadialViewImpl() :
|
||||
selectedTime_ {},
|
||||
latitude_ {},
|
||||
longitude_ {},
|
||||
|
|
@ -39,8 +37,6 @@ public:
|
|||
}
|
||||
~Level3RadialViewImpl() = default;
|
||||
|
||||
std::shared_ptr<manager::RadarProductManager> radarProductManager_;
|
||||
|
||||
std::chrono::system_clock::time_point selectedTime_;
|
||||
|
||||
std::vector<float> vertices_;
|
||||
|
|
@ -57,8 +53,8 @@ public:
|
|||
Level3RadialView::Level3RadialView(
|
||||
const std::string& product,
|
||||
std::shared_ptr<manager::RadarProductManager> radarProductManager) :
|
||||
Level3ProductView(product),
|
||||
p(std::make_unique<Level3RadialViewImpl>(radarProductManager))
|
||||
Level3ProductView(product, radarProductManager),
|
||||
p(std::make_unique<Level3RadialViewImpl>())
|
||||
{
|
||||
}
|
||||
Level3RadialView::~Level3RadialView() = default;
|
||||
|
|
@ -109,10 +105,13 @@ void Level3RadialView::ComputeSweep()
|
|||
|
||||
std::scoped_lock sweepLock(sweep_mutex());
|
||||
|
||||
std::shared_ptr<manager::RadarProductManager> radarProductManager =
|
||||
radar_product_manager();
|
||||
|
||||
// Retrieve message from Radar Product Manager
|
||||
std::shared_ptr<wsr88d::rpg::Level3Message> message =
|
||||
p->radarProductManager_->GetLevel3Data(GetRadarProductName(),
|
||||
p->selectedTime_);
|
||||
radarProductManager->GetLevel3Data(GetRadarProductName(),
|
||||
p->selectedTime_);
|
||||
if (message == nullptr)
|
||||
{
|
||||
logger_->debug("Level 3 data not found");
|
||||
|
|
@ -218,7 +217,7 @@ void Level3RadialView::ComputeSweep()
|
|||
common::RadialSize::_0_5Degree :
|
||||
common::RadialSize::_1Degree;
|
||||
const std::vector<float>& coordinates =
|
||||
p->radarProductManager_->coordinates(radialSize);
|
||||
radarProductManager->coordinates(radialSize);
|
||||
|
||||
// There should be a positive number of range bins in radial data
|
||||
const uint16_t gates = radialData->number_of_range_bins();
|
||||
|
|
@ -270,7 +269,7 @@ void Level3RadialView::ComputeSweep()
|
|||
const uint16_t gateSize = std::max<uint16_t>(
|
||||
1,
|
||||
dataMomentInterval /
|
||||
static_cast<uint16_t>(p->radarProductManager_->gate_size()));
|
||||
static_cast<uint16_t>(radarProductManager->gate_size()));
|
||||
|
||||
// Compute gate range [startGate, endGate)
|
||||
const uint16_t startGate = 0;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <scwx/qt/view/level3_product_view.hpp>
|
||||
#include <scwx/qt/manager/radar_product_manager.hpp>
|
||||
|
||||
#include <chrono>
|
||||
#include <memory>
|
||||
|
|
|
|||
|
|
@ -26,9 +26,7 @@ static constexpr uint32_t VALUES_PER_VERTEX = 2u;
|
|||
class Level3RasterViewImpl
|
||||
{
|
||||
public:
|
||||
explicit Level3RasterViewImpl(
|
||||
std::shared_ptr<manager::RadarProductManager> radarProductManager) :
|
||||
radarProductManager_ {radarProductManager},
|
||||
explicit Level3RasterViewImpl() :
|
||||
selectedTime_ {},
|
||||
latitude_ {},
|
||||
longitude_ {},
|
||||
|
|
@ -39,8 +37,6 @@ public:
|
|||
}
|
||||
~Level3RasterViewImpl() = default;
|
||||
|
||||
std::shared_ptr<manager::RadarProductManager> radarProductManager_;
|
||||
|
||||
std::chrono::system_clock::time_point selectedTime_;
|
||||
|
||||
std::vector<float> vertices_;
|
||||
|
|
@ -57,8 +53,8 @@ public:
|
|||
Level3RasterView::Level3RasterView(
|
||||
const std::string& product,
|
||||
std::shared_ptr<manager::RadarProductManager> radarProductManager) :
|
||||
Level3ProductView(product),
|
||||
p(std::make_unique<Level3RasterViewImpl>(radarProductManager))
|
||||
Level3ProductView(product, radarProductManager),
|
||||
p(std::make_unique<Level3RasterViewImpl>())
|
||||
{
|
||||
}
|
||||
Level3RasterView::~Level3RasterView() = default;
|
||||
|
|
@ -109,10 +105,13 @@ void Level3RasterView::ComputeSweep()
|
|||
|
||||
std::scoped_lock sweepLock(sweep_mutex());
|
||||
|
||||
std::shared_ptr<manager::RadarProductManager> radarProductManager =
|
||||
radar_product_manager();
|
||||
|
||||
// Retrieve message from Radar Product Manager
|
||||
std::shared_ptr<wsr88d::rpg::Level3Message> message =
|
||||
p->radarProductManager_->GetLevel3Data(GetRadarProductName(),
|
||||
p->selectedTime_);
|
||||
radarProductManager->GetLevel3Data(GetRadarProductName(),
|
||||
p->selectedTime_);
|
||||
if (message == nullptr)
|
||||
{
|
||||
logger_->debug("Level 3 data not found");
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <scwx/qt/view/level3_product_view.hpp>
|
||||
#include <scwx/qt/manager/radar_product_manager.hpp>
|
||||
|
||||
#include <chrono>
|
||||
#include <memory>
|
||||
|
|
|
|||
|
|
@ -26,15 +26,24 @@ static const uint16_t DEFAULT_COLOR_TABLE_MAX = 255u;
|
|||
class RadarProductViewImpl
|
||||
{
|
||||
public:
|
||||
explicit RadarProductViewImpl() : initialized_ {false}, sweepMutex_ {} {}
|
||||
explicit RadarProductViewImpl(
|
||||
std::shared_ptr<manager::RadarProductManager> radarProductManager) :
|
||||
initialized_ {false},
|
||||
sweepMutex_ {},
|
||||
radarProductManager_ {radarProductManager}
|
||||
{
|
||||
}
|
||||
~RadarProductViewImpl() = default;
|
||||
|
||||
bool initialized_;
|
||||
std::mutex sweepMutex_;
|
||||
|
||||
std::shared_ptr<manager::RadarProductManager> radarProductManager_;
|
||||
};
|
||||
|
||||
RadarProductView::RadarProductView() :
|
||||
p(std::make_unique<RadarProductViewImpl>()) {};
|
||||
RadarProductView::RadarProductView(
|
||||
std::shared_ptr<manager::RadarProductManager> radarProductManager) :
|
||||
p(std::make_unique<RadarProductViewImpl>(radarProductManager)) {};
|
||||
RadarProductView::~RadarProductView() = default;
|
||||
|
||||
const std::vector<boost::gil::rgba8_pixel_t>&
|
||||
|
|
@ -58,6 +67,12 @@ float RadarProductView::elevation() const
|
|||
return 0.0f;
|
||||
}
|
||||
|
||||
std::shared_ptr<manager::RadarProductManager>
|
||||
RadarProductView::radar_product_manager() const
|
||||
{
|
||||
return p->radarProductManager_;
|
||||
}
|
||||
|
||||
float RadarProductView::range() const
|
||||
{
|
||||
return 0.0f;
|
||||
|
|
@ -73,6 +88,12 @@ std::mutex& RadarProductView::sweep_mutex()
|
|||
return p->sweepMutex_;
|
||||
}
|
||||
|
||||
void RadarProductView::set_radar_product_manager(
|
||||
std::shared_ptr<manager::RadarProductManager> radarProductManager)
|
||||
{
|
||||
p->radarProductManager_ = radarProductManager;
|
||||
}
|
||||
|
||||
void RadarProductView::Initialize()
|
||||
{
|
||||
ComputeSweep();
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <scwx/common/color_table.hpp>
|
||||
#include <scwx/common/products.hpp>
|
||||
#include <scwx/qt/manager/radar_product_manager.hpp>
|
||||
|
||||
#include <chrono>
|
||||
#include <memory>
|
||||
|
|
@ -24,7 +25,8 @@ class RadarProductView : public QObject
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit RadarProductView();
|
||||
explicit RadarProductView(
|
||||
std::shared_ptr<manager::RadarProductManager> radarProductManager);
|
||||
virtual ~RadarProductView();
|
||||
|
||||
virtual const std::vector<boost::gil::rgba8_pixel_t>& color_table() const;
|
||||
|
|
@ -36,7 +38,11 @@ public:
|
|||
virtual uint16_t vcp() const = 0;
|
||||
virtual const std::vector<float>& vertices() const = 0;
|
||||
|
||||
std::mutex& sweep_mutex();
|
||||
std::shared_ptr<manager::RadarProductManager> radar_product_manager() const;
|
||||
std::mutex& sweep_mutex();
|
||||
|
||||
void set_radar_product_manager(
|
||||
std::shared_ptr<manager::RadarProductManager> radarProductManager);
|
||||
|
||||
void Initialize();
|
||||
virtual void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue