Load radar data asynchronously

This commit is contained in:
Dan Paulat 2021-11-11 23:47:27 -06:00
parent 803a25e884
commit 3625515b8a
6 changed files with 71 additions and 13 deletions

View file

@ -1,5 +1,6 @@
#include <scwx/qt/manager/radar_product_manager.hpp>
#include <scwx/common/constants.hpp>
#include <scwx/util/threads.hpp>
#include <deque>
#include <execution>
@ -182,6 +183,33 @@ void RadarProductManager::LoadLevel2Data(const std::string& filename)
emit Level2DataLoaded();
}
std::unordered_map<uint16_t, std::shared_ptr<wsr88d::rda::DigitalRadarData>>
RadarProductManager::GetLevel2Data(wsr88d::rda::DataBlockType dataBlockType,
uint8_t elevationIndex,
std::chrono::system_clock::time_point time)
{
std::unordered_map<uint16_t, std::shared_ptr<wsr88d::rda::DigitalRadarData>>
radarData;
if (p->level2Data_.size() > 0)
{
// TODO: Pull this from the database
radarData = p->level2Data_[0]->radar_data()[elevationIndex];
}
else
{
scwx::util::async([&]() {
QString filename = qgetenv("AR2V_FILE");
if (!filename.isEmpty())
{
LoadLevel2Data(filename.toUtf8().constData());
}
});
}
return radarData;
}
} // namespace manager
} // namespace qt
} // namespace scwx

View file

@ -33,6 +33,11 @@ public:
void Initialize();
void LoadLevel2Data(const std::string& filename);
std::unordered_map<uint16_t, std::shared_ptr<wsr88d::rda::DigitalRadarData>>
GetLevel2Data(wsr88d::rda::DataBlockType dataBlockType,
uint8_t elevationIndex,
std::chrono::system_clock::time_point time = {});
signals:
void Level2DataLoaded();