Fix issue where level 2 archive files where put in a cache at times of level 2

chunk files
This commit is contained in:
AdenKoperczak 2025-05-10 15:06:46 -04:00
parent 0438b65208
commit 8989c0e88c
No known key found for this signature in database
GPG key ID: 9843017036F62EE7
4 changed files with 84 additions and 71 deletions

View file

@ -90,17 +90,23 @@ public:
explicit ProviderManager(RadarProductManager* self, explicit ProviderManager(RadarProductManager* self,
std::string radarId, std::string radarId,
common::RadarProductGroup group, common::RadarProductGroup group,
std::string product = "???", std::string product = "???",
bool fastRefresh = false) : bool isChunks = false) :
radarId_ {std::move(radarId)}, radarId_ {std::move(radarId)},
group_ {group}, group_ {group},
product_ {std::move(product)}, product_ {std::move(product)},
fastRefresh_ {fastRefresh} isChunks_ {isChunks}
{ {
connect(this, connect(this,
&ProviderManager::NewDataAvailable, &ProviderManager::NewDataAvailable,
self, self,
&RadarProductManager::NewDataAvailable); [this, self](common::RadarProductGroup group,
const std::string& product,
std::chrono::system_clock::time_point latestTime)
{
Q_EMIT self->NewDataAvailable(
group, product, isChunks_, latestTime);
});
} }
~ProviderManager() { threadPool_.join(); }; ~ProviderManager() { threadPool_.join(); };
@ -113,7 +119,7 @@ public:
const std::string radarId_; const std::string radarId_;
const common::RadarProductGroup group_; const common::RadarProductGroup group_;
const std::string product_; const std::string product_;
const bool fastRefresh_; const bool isChunks_;
bool refreshEnabled_ {false}; bool refreshEnabled_ {false};
boost::asio::steady_timer refreshTimer_ {threadPool_}; boost::asio::steady_timer refreshTimer_ {threadPool_};
std::mutex refreshTimerMutex_ {}; std::mutex refreshTimerMutex_ {};
@ -796,11 +802,11 @@ void RadarProductManagerImpl::RefreshDataSync(
// Level2 chunked data is updated quickly and uses a faster interval // Level2 chunked data is updated quickly and uses a faster interval
const std::chrono::milliseconds fastRetryInterval = const std::chrono::milliseconds fastRetryInterval =
providerManager->fastRefresh_ ? kFastRetryIntervalChunks_ : providerManager->isChunks_ ? kFastRetryIntervalChunks_ :
kFastRetryInterval_; kFastRetryInterval_;
const std::chrono::milliseconds slowRetryInterval = const std::chrono::milliseconds slowRetryInterval =
providerManager->fastRefresh_ ? kSlowRetryIntervalChunks_ : providerManager->isChunks_ ? kSlowRetryIntervalChunks_ :
kSlowRetryInterval_; kSlowRetryInterval_;
std::chrono::milliseconds interval = fastRetryInterval; std::chrono::milliseconds interval = fastRetryInterval;
if (totalObjects > 0) if (totalObjects > 0)
@ -1019,12 +1025,6 @@ void RadarProductManager::LoadLevel2Data(
p->level2ProductRecordMutex_, p->level2ProductRecordMutex_,
p->loadLevel2DataMutex_, p->loadLevel2DataMutex_,
request); request);
p->LoadProviderData(time,
p->level2ChunksProviderManager_,
p->level2ProductRecords_,
p->level2ProductRecordMutex_,
p->loadLevel2DataMutex_,
request);
} }
void RadarProductManager::LoadLevel3Data( void RadarProductManager::LoadLevel3Data(
@ -1460,7 +1460,7 @@ RadarProductManagerImpl::StoreRadarProductRecord(
if (storedRecord != nullptr) if (storedRecord != nullptr)
{ {
logger_->trace( logger_->error(
"Level 2 product previously loaded, loading from cache"); "Level 2 product previously loaded, loading from cache");
} }
} }

View file

@ -148,6 +148,7 @@ signals:
void Level3ProductsChanged(); void Level3ProductsChanged();
void NewDataAvailable(common::RadarProductGroup group, void NewDataAvailable(common::RadarProductGroup group,
const std::string& product, const std::string& product,
bool isChunks,
std::chrono::system_clock::time_point latestTime); std::chrono::system_clock::time_point latestTime);
void IncomingLevel2ElevationChanged(std::optional<float> incomingElevation); void IncomingLevel2ElevationChanged(std::optional<float> incomingElevation);

View file

@ -1843,6 +1843,7 @@ void MapWidgetImpl::RadarProductManagerConnect()
this, this,
[this](common::RadarProductGroup group, [this](common::RadarProductGroup group,
const std::string& product, const std::string& product,
bool isChunks,
std::chrono::system_clock::time_point latestTime) std::chrono::system_clock::time_point latestTime)
{ {
if (autoRefreshEnabled_ && if (autoRefreshEnabled_ &&
@ -1850,71 +1851,81 @@ void MapWidgetImpl::RadarProductManagerConnect()
(group == common::RadarProductGroup::Level2 || (group == common::RadarProductGroup::Level2 ||
context_->radar_product() == product)) context_->radar_product() == product))
{ {
// Create file request if (isChunks && autoUpdateEnabled_)
std::shared_ptr<request::NexradFileRequest> request =
std::make_shared<request::NexradFileRequest>(
radarProductManager_->radar_id());
// File request callback
if (autoUpdateEnabled_)
{ {
connect( // Level 2 products may have multiple time points,
request.get(), // ensure the latest is selected
&request::NexradFileRequest::RequestComplete, widget_->SelectRadarProduct(group, product);
this, }
[=, else
this](std::shared_ptr<request::NexradFileRequest> request) {
{ // Create file request
// Select loaded record const std::shared_ptr<request::NexradFileRequest> request =
auto record = request->radar_product_record(); std::make_shared<request::NexradFileRequest>(
radarProductManager_->radar_id());
// Validate record, and verify current map context // File request callback
// still displays site and product if (autoUpdateEnabled_)
if (record != nullptr && {
radarProductManager_ != nullptr && connect(
radarProductManager_->radar_id() == request.get(),
request->current_radar_site() && &request::NexradFileRequest::RequestComplete,
context_->radar_product_group() == group && this,
(group == common::RadarProductGroup::Level2 || [group, product, this](
context_->radar_product() == product)) const std::shared_ptr<request::NexradFileRequest>&
request)
{
// Select loaded record
auto record = request->radar_product_record();
// Validate record, and verify current map context
// still displays site and product
if (record != nullptr &&
radarProductManager_ != nullptr &&
radarProductManager_->radar_id() ==
request->current_radar_site() &&
context_->radar_product_group() == group &&
(group == common::RadarProductGroup::Level2 ||
context_->radar_product() == product))
{
if (group == common::RadarProductGroup::Level2)
{
// Level 2 products may have multiple time
// points, ensure the latest is selected
widget_->SelectRadarProduct(group, product);
}
else
{
widget_->SelectRadarProduct(record);
}
}
});
}
// Load file
boost::asio::post(
threadPool_,
[group, latestTime, request, product, this]()
{
try
{ {
if (group == common::RadarProductGroup::Level2) if (group == common::RadarProductGroup::Level2)
{ {
// Level 2 products may have multiple time points, radarProductManager_->LoadLevel2Data(latestTime,
// ensure the latest is selected request);
widget_->SelectRadarProduct(group, product);
} }
else else
{ {
widget_->SelectRadarProduct(record); radarProductManager_->LoadLevel3Data(
product, latestTime, request);
} }
} }
catch (const std::exception& ex)
{
logger_->error(ex.what());
}
}); });
} }
// Load file
boost::asio::post(
threadPool_,
[=, this]()
{
try
{
if (group == common::RadarProductGroup::Level2)
{
radarProductManager_->LoadLevel2Data(latestTime,
request);
}
else
{
radarProductManager_->LoadLevel3Data(
product, latestTime, request);
}
}
catch (const std::exception& ex)
{
logger_->error(ex.what());
}
});
} }
}, },
Qt::QueuedConnection); Qt::QueuedConnection);

View file

@ -116,8 +116,9 @@ void OverlayProductView::Impl::ConnectRadarProductManager()
radarProductManager_.get(), radarProductManager_.get(),
&manager::RadarProductManager::NewDataAvailable, &manager::RadarProductManager::NewDataAvailable,
self_, self_,
[this](common::RadarProductGroup group, [this](common::RadarProductGroup group,
const std::string& product, const std::string& product,
bool /*isChunks*/,
std::chrono::system_clock::time_point latestTime) std::chrono::system_clock::time_point latestTime)
{ {
if (autoRefreshEnabled_ && if (autoRefreshEnabled_ &&