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

@ -91,16 +91,22 @@ public:
std::string radarId,
common::RadarProductGroup group,
std::string product = "???",
bool fastRefresh = false) :
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,10 +802,10 @@ void RadarProductManagerImpl::RefreshDataSync(
// Level2 chunked data is updated quickly and uses a faster interval
const std::chrono::milliseconds fastRetryInterval =
providerManager->fastRefresh_ ? kFastRetryIntervalChunks_ :
providerManager->isChunks_ ? kFastRetryIntervalChunks_ :
kFastRetryInterval_;
const std::chrono::milliseconds slowRetryInterval =
providerManager->fastRefresh_ ? kSlowRetryIntervalChunks_ :
providerManager->isChunks_ ? kSlowRetryIntervalChunks_ :
kSlowRetryInterval_;
std::chrono::milliseconds interval = fastRetryInterval;
@ -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,15 +1843,24 @@ void MapWidgetImpl::RadarProductManagerConnect()
this,
[this](common::RadarProductGroup group,
const std::string& product,
bool isChunks,
std::chrono::system_clock::time_point latestTime)
{
if (autoRefreshEnabled_ &&
context_->radar_product_group() == group &&
(group == common::RadarProductGroup::Level2 ||
context_->radar_product() == product))
{
if (isChunks && autoUpdateEnabled_)
{
// Level 2 products may have multiple time points,
// ensure the latest is selected
widget_->SelectRadarProduct(group, product);
}
else
{
// Create file request
std::shared_ptr<request::NexradFileRequest> request =
const std::shared_ptr<request::NexradFileRequest> request =
std::make_shared<request::NexradFileRequest>(
radarProductManager_->radar_id());
@ -1862,8 +1871,9 @@ void MapWidgetImpl::RadarProductManagerConnect()
request.get(),
&request::NexradFileRequest::RequestComplete,
this,
[=,
this](std::shared_ptr<request::NexradFileRequest> request)
[group, product, this](
const std::shared_ptr<request::NexradFileRequest>&
request)
{
// Select loaded record
auto record = request->radar_product_record();
@ -1880,8 +1890,8 @@ void MapWidgetImpl::RadarProductManagerConnect()
{
if (group == common::RadarProductGroup::Level2)
{
// Level 2 products may have multiple time points,
// ensure the latest is selected
// Level 2 products may have multiple time
// points, ensure the latest is selected
widget_->SelectRadarProduct(group, product);
}
else
@ -1895,7 +1905,7 @@ void MapWidgetImpl::RadarProductManagerConnect()
// Load file
boost::asio::post(
threadPool_,
[=, this]()
[group, latestTime, request, product, this]()
{
try
{
@ -1916,6 +1926,7 @@ void MapWidgetImpl::RadarProductManagerConnect()
}
});
}
}
},
Qt::QueuedConnection);
}

View file

@ -118,6 +118,7 @@ void OverlayProductView::Impl::ConnectRadarProductManager()
self_,
[this](common::RadarProductGroup group,
const std::string& product,
bool /*isChunks*/,
std::chrono::system_clock::time_point latestTime)
{
if (autoRefreshEnabled_ &&