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

View file

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

View file

@ -1843,6 +1843,7 @@ void MapWidgetImpl::RadarProductManagerConnect()
this,
[this](common::RadarProductGroup group,
const std::string& product,
bool isChunks,
std::chrono::system_clock::time_point latestTime)
{
if (autoRefreshEnabled_ &&
@ -1850,71 +1851,81 @@ void MapWidgetImpl::RadarProductManagerConnect()
(group == common::RadarProductGroup::Level2 ||
context_->radar_product() == product))
{
// Create file request
std::shared_ptr<request::NexradFileRequest> request =
std::make_shared<request::NexradFileRequest>(
radarProductManager_->radar_id());
// File request callback
if (autoUpdateEnabled_)
if (isChunks && autoUpdateEnabled_)
{
connect(
request.get(),
&request::NexradFileRequest::RequestComplete,
this,
[=,
this](std::shared_ptr<request::NexradFileRequest> request)
{
// Select loaded record
auto record = request->radar_product_record();
// Level 2 products may have multiple time points,
// ensure the latest is selected
widget_->SelectRadarProduct(group, product);
}
else
{
// Create file request
const std::shared_ptr<request::NexradFileRequest> request =
std::make_shared<request::NexradFileRequest>(
radarProductManager_->radar_id());
// 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))
// File request callback
if (autoUpdateEnabled_)
{
connect(
request.get(),
&request::NexradFileRequest::RequestComplete,
this,
[group, product, this](
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)
{
// Level 2 products may have multiple time points,
// ensure the latest is selected
widget_->SelectRadarProduct(group, product);
radarProductManager_->LoadLevel2Data(latestTime,
request);
}
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);

View file

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