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, 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,10 +802,10 @@ 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;
@ -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,15 +1843,24 @@ 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_ &&
context_->radar_product_group() == group && context_->radar_product_group() == group &&
(group == common::RadarProductGroup::Level2 || (group == common::RadarProductGroup::Level2 ||
context_->radar_product() == product)) 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 // Create file request
std::shared_ptr<request::NexradFileRequest> request = const std::shared_ptr<request::NexradFileRequest> request =
std::make_shared<request::NexradFileRequest>( std::make_shared<request::NexradFileRequest>(
radarProductManager_->radar_id()); radarProductManager_->radar_id());
@ -1862,8 +1871,9 @@ void MapWidgetImpl::RadarProductManagerConnect()
request.get(), request.get(),
&request::NexradFileRequest::RequestComplete, &request::NexradFileRequest::RequestComplete,
this, this,
[=, [group, product, this](
this](std::shared_ptr<request::NexradFileRequest> request) const std::shared_ptr<request::NexradFileRequest>&
request)
{ {
// Select loaded record // Select loaded record
auto record = request->radar_product_record(); auto record = request->radar_product_record();
@ -1880,8 +1890,8 @@ void MapWidgetImpl::RadarProductManagerConnect()
{ {
if (group == common::RadarProductGroup::Level2) if (group == common::RadarProductGroup::Level2)
{ {
// Level 2 products may have multiple time points, // Level 2 products may have multiple time
// ensure the latest is selected // points, ensure the latest is selected
widget_->SelectRadarProduct(group, product); widget_->SelectRadarProduct(group, product);
} }
else else
@ -1895,7 +1905,7 @@ void MapWidgetImpl::RadarProductManagerConnect()
// Load file // Load file
boost::asio::post( boost::asio::post(
threadPool_, threadPool_,
[=, this]() [group, latestTime, request, product, this]()
{ {
try try
{ {
@ -1916,6 +1926,7 @@ void MapWidgetImpl::RadarProductManagerConnect()
} }
}); });
} }
}
}, },
Qt::QueuedConnection); Qt::QueuedConnection);
} }

View file

@ -118,6 +118,7 @@ void OverlayProductView::Impl::ConnectRadarProductManager()
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_ &&