mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 13:00:05 +00:00 
			
		
		
		
	Fix reload of expired (garbage collected) live data
This commit is contained in:
		
							parent
							
								
									92bb5154a4
								
							
						
					
					
						commit
						f1a5d4a744
					
				
					 5 changed files with 70 additions and 19 deletions
				
			
		|  | @ -177,10 +177,10 @@ public: | |||
|    void RefreshData(std::shared_ptr<ProviderManager> providerManager); | ||||
| 
 | ||||
|    std::shared_ptr<types::RadarProductRecord> | ||||
|    GetLevel2ProductRecord(std::chrono::system_clock::time_point time); | ||||
|    GetLevel2ProductRecord(std::chrono::system_clock::time_point& time); | ||||
|    std::shared_ptr<types::RadarProductRecord> | ||||
|    GetLevel3ProductRecord(const std::string&                    product, | ||||
|                           std::chrono::system_clock::time_point time); | ||||
|    GetLevel3ProductRecord(const std::string&                     product, | ||||
|                           std::chrono::system_clock::time_point& time); | ||||
|    std::shared_ptr<types::RadarProductRecord> | ||||
|    StoreRadarProductRecord(std::shared_ptr<types::RadarProductRecord> record); | ||||
|    void UpdateRecentRecords(RadarProductRecordList& recentList, | ||||
|  | @ -859,7 +859,7 @@ void RadarProductManagerImpl::LoadNexradFile( | |||
| 
 | ||||
| std::shared_ptr<types::RadarProductRecord> | ||||
| RadarProductManagerImpl::GetLevel2ProductRecord( | ||||
|    std::chrono::system_clock::time_point time) | ||||
|    std::chrono::system_clock::time_point& time) | ||||
| { | ||||
|    std::shared_ptr<types::RadarProductRecord> record; | ||||
|    RadarProductRecordMap::const_pointer       recordPtr {nullptr}; | ||||
|  | @ -879,6 +879,7 @@ RadarProductManagerImpl::GetLevel2ProductRecord( | |||
| 
 | ||||
|    if (recordPtr != nullptr) | ||||
|    { | ||||
|       time   = recordPtr->first; | ||||
|       record = recordPtr->second.lock(); | ||||
|       if (record == nullptr) | ||||
|       { | ||||
|  | @ -902,7 +903,7 @@ RadarProductManagerImpl::GetLevel2ProductRecord( | |||
| 
 | ||||
| std::shared_ptr<types::RadarProductRecord> | ||||
| RadarProductManagerImpl::GetLevel3ProductRecord( | ||||
|    const std::string& product, std::chrono::system_clock::time_point time) | ||||
|    const std::string& product, std::chrono::system_clock::time_point& time) | ||||
| { | ||||
|    std::shared_ptr<types::RadarProductRecord> record = nullptr; | ||||
|    RadarProductRecordMap::const_pointer       recordPtr {nullptr}; | ||||
|  | @ -930,6 +931,7 @@ RadarProductManagerImpl::GetLevel3ProductRecord( | |||
| 
 | ||||
|    if (recordPtr != nullptr) | ||||
|    { | ||||
|       time   = recordPtr->first; | ||||
|       record = recordPtr->second.lock(); | ||||
|       if (record == nullptr) | ||||
|       { | ||||
|  | @ -1046,7 +1048,8 @@ void RadarProductManagerImpl::UpdateRecentRecords( | |||
| 
 | ||||
| std::tuple<std::shared_ptr<wsr88d::rda::ElevationScan>, | ||||
|            float, | ||||
|            std::vector<float>> | ||||
|            std::vector<float>, | ||||
|            std::chrono::system_clock::time_point> | ||||
| RadarProductManager::GetLevel2Data(wsr88d::rda::DataBlockType dataBlockType, | ||||
|                                    float                      elevation, | ||||
|                                    std::chrono::system_clock::time_point time) | ||||
|  | @ -1065,10 +1068,11 @@ RadarProductManager::GetLevel2Data(wsr88d::rda::DataBlockType dataBlockType, | |||
|             dataBlockType, elevation, time); | ||||
|    } | ||||
| 
 | ||||
|    return std::tie(radarData, elevationCut, elevationCuts); | ||||
|    return std::tie(radarData, elevationCut, elevationCuts, time); | ||||
| } | ||||
| 
 | ||||
| std::shared_ptr<wsr88d::rpg::Level3Message> | ||||
| std::tuple<std::shared_ptr<wsr88d::rpg::Level3Message>, | ||||
|            std::chrono::system_clock::time_point> | ||||
| RadarProductManager::GetLevel3Data(const std::string& product, | ||||
|                                    std::chrono::system_clock::time_point time) | ||||
| { | ||||
|  | @ -1082,7 +1086,7 @@ RadarProductManager::GetLevel3Data(const std::string& product, | |||
|       message = record->level3_file()->message(); | ||||
|    } | ||||
| 
 | ||||
|    return message; | ||||
|    return std::tie(message, time); | ||||
| } | ||||
| 
 | ||||
| common::Level3ProductCategoryMap | ||||
|  |  | |||
|  | @ -63,14 +63,34 @@ public: | |||
|                       bool                      enabled, | ||||
|                       boost::uuids::uuid uuid = boost::uuids::nil_uuid()); | ||||
| 
 | ||||
|    /**
 | ||||
|     * @brief Get level 2 radar data for a data block type, elevation, and time. | ||||
|     * | ||||
|     * @param [in] dataBlockType Data block type | ||||
|     * @param [in] elevation Elevation tilt | ||||
|     * @param [in] time Radar product time | ||||
|     * | ||||
|     * @return Level 2 radar data, selected elevation cut, available elevation | ||||
|     * cuts and selected time | ||||
|     */ | ||||
|    std::tuple<std::shared_ptr<wsr88d::rda::ElevationScan>, | ||||
|               float, | ||||
|               std::vector<float>> | ||||
|               std::vector<float>, | ||||
|               std::chrono::system_clock::time_point> | ||||
|    GetLevel2Data(wsr88d::rda::DataBlockType            dataBlockType, | ||||
|                  float                                 elevation, | ||||
|                  std::chrono::system_clock::time_point time = {}); | ||||
| 
 | ||||
|    std::shared_ptr<wsr88d::rpg::Level3Message> | ||||
|    /**
 | ||||
|     * @brief Get level 3 message data for a product and time. | ||||
|     * | ||||
|     * @param [in] product Radar product name | ||||
|     * @param [in] time Radar product time | ||||
|     * | ||||
|     * @return Level 3 message data and selected time | ||||
|     */ | ||||
|    std::tuple<std::shared_ptr<wsr88d::rpg::Level3Message>, | ||||
|               std::chrono::system_clock::time_point> | ||||
|    GetLevel3Data(const std::string&                    product, | ||||
|                  std::chrono::system_clock::time_point time = {}); | ||||
| 
 | ||||
|  |  | |||
|  | @ -383,9 +383,18 @@ void Level2ProductView::ComputeSweep() | |||
|       radar_product_manager(); | ||||
| 
 | ||||
|    std::shared_ptr<wsr88d::rda::ElevationScan> radarData; | ||||
|    std::tie(radarData, p->elevationCut_, p->elevationCuts_) = | ||||
|    std::chrono::system_clock::time_point       requestedTime {selected_time()}; | ||||
|    std::chrono::system_clock::time_point       foundTime; | ||||
|    std::tie(radarData, p->elevationCut_, p->elevationCuts_, foundTime) = | ||||
|       radarProductManager->GetLevel2Data( | ||||
|          p->dataBlockType_, p->selectedElevation_, selected_time()); | ||||
|          p->dataBlockType_, p->selectedElevation_, requestedTime); | ||||
| 
 | ||||
|    // If a different time was found than what was requested, update it
 | ||||
|    if (requestedTime != foundTime) | ||||
|    { | ||||
|       SelectTime(foundTime); | ||||
|    } | ||||
| 
 | ||||
|    if (radarData == nullptr || radarData == p->elevationScan_) | ||||
|    { | ||||
|       return; | ||||
|  |  | |||
|  | @ -97,9 +97,18 @@ void Level3RadialView::ComputeSweep() | |||
|       radar_product_manager(); | ||||
| 
 | ||||
|    // Retrieve message from Radar Product Manager
 | ||||
|    std::shared_ptr<wsr88d::rpg::Level3Message> message = | ||||
|       radarProductManager->GetLevel3Data(GetRadarProductName(), | ||||
|                                          selected_time()); | ||||
|    std::shared_ptr<wsr88d::rpg::Level3Message> message; | ||||
|    std::chrono::system_clock::time_point       requestedTime {selected_time()}; | ||||
|    std::chrono::system_clock::time_point       foundTime; | ||||
|    std::tie(message, foundTime) = | ||||
|       radarProductManager->GetLevel3Data(GetRadarProductName(), requestedTime); | ||||
| 
 | ||||
|    // If a different time was found than what was requested, update it
 | ||||
|    if (requestedTime != foundTime) | ||||
|    { | ||||
|       SelectTime(foundTime); | ||||
|    } | ||||
| 
 | ||||
|    if (message == nullptr) | ||||
|    { | ||||
|       logger_->debug("Level 3 data not found"); | ||||
|  |  | |||
|  | @ -97,9 +97,18 @@ void Level3RasterView::ComputeSweep() | |||
|       radar_product_manager(); | ||||
| 
 | ||||
|    // Retrieve message from Radar Product Manager
 | ||||
|    std::shared_ptr<wsr88d::rpg::Level3Message> message = | ||||
|       radarProductManager->GetLevel3Data(GetRadarProductName(), | ||||
|                                          selected_time()); | ||||
|    std::shared_ptr<wsr88d::rpg::Level3Message> message; | ||||
|    std::chrono::system_clock::time_point       requestedTime {selected_time()}; | ||||
|    std::chrono::system_clock::time_point       foundTime; | ||||
|    std::tie(message, foundTime) = | ||||
|       radarProductManager->GetLevel3Data(GetRadarProductName(), requestedTime); | ||||
| 
 | ||||
|    // If a different time was found than what was requested, update it
 | ||||
|    if (requestedTime != foundTime) | ||||
|    { | ||||
|       SelectTime(foundTime); | ||||
|    } | ||||
| 
 | ||||
|    if (message == nullptr) | ||||
|    { | ||||
|       logger_->debug("Level 3 data not found"); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat