mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 12:30:04 +00:00 
			
		
		
		
	Display expired data as soon as it's reloaded
This commit is contained in:
		
							parent
							
								
									16044efbf3
								
							
						
					
					
						commit
						df2474c383
					
				
					 12 changed files with 114 additions and 80 deletions
				
			
		|  | @ -883,7 +883,17 @@ RadarProductManagerImpl::GetLevel2ProductRecord( | |||
|       if (record == nullptr) | ||||
|       { | ||||
|          // Product is expired, reload it
 | ||||
|          self_->LoadLevel2Data(recordPtr->first, nullptr); | ||||
|          std::shared_ptr<request::NexradFileRequest> request = | ||||
|             std::make_shared<request::NexradFileRequest>(); | ||||
| 
 | ||||
|          QObject::connect( | ||||
|             request.get(), | ||||
|             &request::NexradFileRequest::RequestComplete, | ||||
|             self_, | ||||
|             [this](std::shared_ptr<request::NexradFileRequest> request) | ||||
|             { emit self_->DataReloaded(request->radar_product_record()); }); | ||||
| 
 | ||||
|          self_->LoadLevel2Data(recordPtr->first, request); | ||||
|       } | ||||
|    } | ||||
| 
 | ||||
|  | @ -924,7 +934,17 @@ RadarProductManagerImpl::GetLevel3ProductRecord( | |||
|       if (record == nullptr) | ||||
|       { | ||||
|          // Product is expired, reload it
 | ||||
|          self_->LoadLevel3Data(product, recordPtr->first, nullptr); | ||||
|          std::shared_ptr<request::NexradFileRequest> request = | ||||
|             std::make_shared<request::NexradFileRequest>(); | ||||
| 
 | ||||
|          QObject::connect( | ||||
|             request.get(), | ||||
|             &request::NexradFileRequest::RequestComplete, | ||||
|             self_, | ||||
|             [this](std::shared_ptr<request::NexradFileRequest> request) | ||||
|             { emit self_->DataReloaded(request->radar_product_record()); }); | ||||
| 
 | ||||
|          self_->LoadLevel3Data(product, recordPtr->first, request); | ||||
|       } | ||||
|    } | ||||
| 
 | ||||
|  |  | |||
|  | @ -97,6 +97,7 @@ public: | |||
|    void                             UpdateAvailableProducts(); | ||||
| 
 | ||||
| signals: | ||||
|    void DataReloaded(std::shared_ptr<types::RadarProductRecord> record); | ||||
|    void Level3ProductsChanged(); | ||||
|    void NewDataAvailable(common::RadarProductGroup             group, | ||||
|                          const std::string&                    product, | ||||
|  |  | |||
|  | @ -44,7 +44,6 @@ public: | |||
|    explicit Level2ProductViewImpl(common::Level2Product product) : | ||||
|        product_ {product}, | ||||
|        selectedElevation_ {0.0f}, | ||||
|        selectedTime_ {}, | ||||
|        elevationScan_ {nullptr}, | ||||
|        momentDataBlock0_ {nullptr}, | ||||
|        latitude_ {}, | ||||
|  | @ -72,8 +71,7 @@ public: | |||
|    common::Level2Product      product_; | ||||
|    wsr88d::rda::DataBlockType dataBlockType_; | ||||
| 
 | ||||
|    float                                 selectedElevation_; | ||||
|    std::chrono::system_clock::time_point selectedTime_; | ||||
|    float selectedElevation_; | ||||
| 
 | ||||
|    std::shared_ptr<wsr88d::rda::ElevationScan>   elevationScan_; | ||||
|    std::shared_ptr<wsr88d::rda::MomentDataBlock> momentDataBlock0_; | ||||
|  | @ -108,6 +106,20 @@ Level2ProductView::Level2ProductView( | |||
|     RadarProductView(radarProductManager), | ||||
|     p(std::make_unique<Level2ProductViewImpl>(product)) | ||||
| { | ||||
|    connect(radarProductManager.get(), | ||||
|            &manager::RadarProductManager::DataReloaded, | ||||
|            this, | ||||
|            [this](std::shared_ptr<types::RadarProductRecord> record) | ||||
|            { | ||||
|               if (record->radar_product_group() == | ||||
|                      common::RadarProductGroup::Level2 && | ||||
|                   record->time() == selected_time()) | ||||
|               { | ||||
|                  // If the data associated with the currently selected time is
 | ||||
|                  // reloaded, update the view
 | ||||
|                  Update(); | ||||
|               } | ||||
|            }); | ||||
| } | ||||
| Level2ProductView::~Level2ProductView() = default; | ||||
| 
 | ||||
|  | @ -243,11 +255,6 @@ void Level2ProductView::SelectProduct(const std::string& productName) | |||
|    p->SetProduct(productName); | ||||
| } | ||||
| 
 | ||||
| void Level2ProductView::SelectTime(std::chrono::system_clock::time_point time) | ||||
| { | ||||
|    p->selectedTime_ = time; | ||||
| } | ||||
| 
 | ||||
| void Level2ProductViewImpl::SetProduct(const std::string& productName) | ||||
| { | ||||
|    SetProduct(common::GetLevel2Product(productName)); | ||||
|  | @ -378,7 +385,7 @@ void Level2ProductView::ComputeSweep() | |||
|    std::shared_ptr<wsr88d::rda::ElevationScan> radarData; | ||||
|    std::tie(radarData, p->elevationCut_, p->elevationCuts_) = | ||||
|       radarProductManager->GetLevel2Data( | ||||
|          p->dataBlockType_, p->selectedElevation_, p->selectedTime_); | ||||
|          p->dataBlockType_, p->selectedElevation_, selected_time()); | ||||
|    if (radarData == nullptr || radarData == p->elevationScan_) | ||||
|    { | ||||
|       return; | ||||
|  |  | |||
|  | @ -28,25 +28,26 @@ public: | |||
|    ~Level2ProductView(); | ||||
| 
 | ||||
|    const std::vector<boost::gil::rgba8_pixel_t>& color_table() const override; | ||||
|    uint16_t                              color_table_min() const override; | ||||
|    uint16_t                              color_table_max() const override; | ||||
|    std::uint16_t                         color_table_min() const override; | ||||
|    std::uint16_t                         color_table_max() const override; | ||||
|    float                                 elevation() const override; | ||||
|    float                                 range() const override; | ||||
|    std::chrono::system_clock::time_point sweep_time() const override; | ||||
|    uint16_t                              vcp() const override; | ||||
|    std::uint16_t                         vcp() const override; | ||||
|    const std::vector<float>&             vertices() const override; | ||||
| 
 | ||||
|    void LoadColorTable(std::shared_ptr<common::ColorTable> colorTable) override; | ||||
|    void SelectElevation(float elevation) override; | ||||
|    void SelectProduct(const std::string& productName) override; | ||||
|    void SelectTime(std::chrono::system_clock::time_point time) override; | ||||
|    void Update() override; | ||||
| 
 | ||||
|    common::RadarProductGroup GetRadarProductGroup() const override; | ||||
|    std::string               GetRadarProductName() const override; | ||||
|    std::vector<float>        GetElevationCuts() const override; | ||||
|    std::tuple<const void*, size_t, size_t> GetMomentData() const override; | ||||
|    std::tuple<const void*, size_t, size_t> GetCfpMomentData() const override; | ||||
|    std::tuple<const void*, std::size_t, std::size_t> | ||||
|    GetMomentData() const override; | ||||
|    std::tuple<const void*, std::size_t, std::size_t> | ||||
|    GetCfpMomentData() const override; | ||||
| 
 | ||||
|    static std::shared_ptr<Level2ProductView> | ||||
|    Create(common::Level2Product                         product, | ||||
|  |  | |||
|  | @ -59,6 +59,21 @@ Level3ProductView::Level3ProductView( | |||
|     RadarProductView(radarProductManager), | ||||
|     p(std::make_unique<Level3ProductViewImpl>(product)) | ||||
| { | ||||
|    connect(radarProductManager.get(), | ||||
|            &manager::RadarProductManager::DataReloaded, | ||||
|            this, | ||||
|            [this](std::shared_ptr<types::RadarProductRecord> record) | ||||
|            { | ||||
|               if (record->radar_product_group() == | ||||
|                      common::RadarProductGroup::Level3 && | ||||
|                   record->radar_product() == p->product_ && | ||||
|                   record->time() == selected_time()) | ||||
|               { | ||||
|                  // If the data associated with the currently selected time is
 | ||||
|                  // reloaded, update the view
 | ||||
|                  Update(); | ||||
|               } | ||||
|            }); | ||||
| } | ||||
| Level3ProductView::~Level3ProductView() = default; | ||||
| 
 | ||||
|  |  | |||
|  | @ -28,8 +28,8 @@ public: | |||
|    virtual ~Level3ProductView(); | ||||
| 
 | ||||
|    const std::vector<boost::gil::rgba8_pixel_t>& color_table() const override; | ||||
|    uint16_t color_table_min() const override; | ||||
|    uint16_t color_table_max() const override; | ||||
|    std::uint16_t color_table_min() const override; | ||||
|    std::uint16_t color_table_max() const override; | ||||
| 
 | ||||
|    void LoadColorTable(std::shared_ptr<common::ColorTable> colorTable) override; | ||||
|    void Update() override; | ||||
|  |  | |||
|  | @ -27,25 +27,18 @@ class Level3RadialViewImpl | |||
| { | ||||
| public: | ||||
|    explicit Level3RadialViewImpl() : | ||||
|        selectedTime_ {}, | ||||
|        latitude_ {}, | ||||
|        longitude_ {}, | ||||
|        range_ {}, | ||||
|        vcp_ {}, | ||||
|        sweepTime_ {} | ||||
|        latitude_ {}, longitude_ {}, range_ {}, vcp_ {}, sweepTime_ {} | ||||
|    { | ||||
|    } | ||||
|    ~Level3RadialViewImpl() = default; | ||||
| 
 | ||||
|    std::chrono::system_clock::time_point selectedTime_; | ||||
|    std::vector<float>        vertices_; | ||||
|    std::vector<std::uint8_t> dataMoments8_; | ||||
| 
 | ||||
|    std::vector<float>   vertices_; | ||||
|    std::vector<uint8_t> dataMoments8_; | ||||
| 
 | ||||
|    float    latitude_; | ||||
|    float    longitude_; | ||||
|    float    range_; | ||||
|    uint16_t vcp_; | ||||
|    float         latitude_; | ||||
|    float         longitude_; | ||||
|    float         range_; | ||||
|    std::uint16_t vcp_; | ||||
| 
 | ||||
|    std::chrono::system_clock::time_point sweepTime_; | ||||
| }; | ||||
|  | @ -92,11 +85,6 @@ std::tuple<const void*, size_t, size_t> Level3RadialView::GetMomentData() const | |||
|    return std::tie(data, dataSize, componentSize); | ||||
| } | ||||
| 
 | ||||
| void Level3RadialView::SelectTime(std::chrono::system_clock::time_point time) | ||||
| { | ||||
|    p->selectedTime_ = time; | ||||
| } | ||||
| 
 | ||||
| void Level3RadialView::ComputeSweep() | ||||
| { | ||||
|    logger_->debug("ComputeSweep()"); | ||||
|  | @ -111,7 +99,7 @@ void Level3RadialView::ComputeSweep() | |||
|    // Retrieve message from Radar Product Manager
 | ||||
|    std::shared_ptr<wsr88d::rpg::Level3Message> message = | ||||
|       radarProductManager->GetLevel3Data(GetRadarProductName(), | ||||
|                                          p->selectedTime_); | ||||
|                                          selected_time()); | ||||
|    if (message == nullptr) | ||||
|    { | ||||
|       logger_->debug("Level 3 data not found"); | ||||
|  |  | |||
|  | @ -27,12 +27,11 @@ public: | |||
| 
 | ||||
|    float                                 range() const override; | ||||
|    std::chrono::system_clock::time_point sweep_time() const override; | ||||
|    uint16_t                              vcp() const override; | ||||
|    std::uint16_t                         vcp() const override; | ||||
|    const std::vector<float>&             vertices() const override; | ||||
| 
 | ||||
|    void SelectTime(std::chrono::system_clock::time_point time) override; | ||||
| 
 | ||||
|    std::tuple<const void*, size_t, size_t> GetMomentData() const override; | ||||
|    std::tuple<const void*, std::size_t, std::size_t> | ||||
|    GetMomentData() const override; | ||||
| 
 | ||||
|    static std::shared_ptr<Level3RadialView> | ||||
|    Create(const std::string&                            product, | ||||
|  |  | |||
|  | @ -27,18 +27,11 @@ class Level3RasterViewImpl | |||
| { | ||||
| public: | ||||
|    explicit Level3RasterViewImpl() : | ||||
|        selectedTime_ {}, | ||||
|        latitude_ {}, | ||||
|        longitude_ {}, | ||||
|        range_ {}, | ||||
|        vcp_ {}, | ||||
|        sweepTime_ {} | ||||
|        latitude_ {}, longitude_ {}, range_ {}, vcp_ {}, sweepTime_ {} | ||||
|    { | ||||
|    } | ||||
|    ~Level3RasterViewImpl() = default; | ||||
| 
 | ||||
|    std::chrono::system_clock::time_point selectedTime_; | ||||
| 
 | ||||
|    std::vector<float>   vertices_; | ||||
|    std::vector<uint8_t> dataMoments8_; | ||||
| 
 | ||||
|  | @ -92,11 +85,6 @@ std::tuple<const void*, size_t, size_t> Level3RasterView::GetMomentData() const | |||
|    return std::tie(data, dataSize, componentSize); | ||||
| } | ||||
| 
 | ||||
| void Level3RasterView::SelectTime(std::chrono::system_clock::time_point time) | ||||
| { | ||||
|    p->selectedTime_ = time; | ||||
| } | ||||
| 
 | ||||
| void Level3RasterView::ComputeSweep() | ||||
| { | ||||
|    logger_->debug("ComputeSweep()"); | ||||
|  | @ -111,7 +99,7 @@ void Level3RasterView::ComputeSweep() | |||
|    // Retrieve message from Radar Product Manager
 | ||||
|    std::shared_ptr<wsr88d::rpg::Level3Message> message = | ||||
|       radarProductManager->GetLevel3Data(GetRadarProductName(), | ||||
|                                          p->selectedTime_); | ||||
|                                          selected_time()); | ||||
|    if (message == nullptr) | ||||
|    { | ||||
|       logger_->debug("Level 3 data not found"); | ||||
|  |  | |||
|  | @ -27,12 +27,11 @@ public: | |||
| 
 | ||||
|    float                                 range() const override; | ||||
|    std::chrono::system_clock::time_point sweep_time() const override; | ||||
|    uint16_t                              vcp() const override; | ||||
|    std::uint16_t                         vcp() const override; | ||||
|    const std::vector<float>&             vertices() const override; | ||||
| 
 | ||||
|    void SelectTime(std::chrono::system_clock::time_point time) override; | ||||
| 
 | ||||
|    std::tuple<const void*, size_t, size_t> GetMomentData() const override; | ||||
|    std::tuple<const void*, std::size_t, std::size_t> | ||||
|    GetMomentData() const override; | ||||
| 
 | ||||
|    static std::shared_ptr<Level3RasterView> | ||||
|    Create(const std::string&                            product, | ||||
|  |  | |||
|  | @ -16,12 +16,12 @@ static const std::string logPrefix_ = "scwx::qt::view::radar_product_view"; | |||
| static const auto        logger_    = scwx::util::Logger::Create(logPrefix_); | ||||
| 
 | ||||
| // Default color table should be transparent to prevent flicker
 | ||||
| static const std::vector<boost::gil::rgba8_pixel_t> DEFAULT_COLOR_TABLE = { | ||||
| static const std::vector<boost::gil::rgba8_pixel_t> kDefaultColorTable_ = { | ||||
|    boost::gil::rgba8_pixel_t(0, 128, 0, 0), | ||||
|    boost::gil::rgba8_pixel_t(255, 192, 0, 0), | ||||
|    boost::gil::rgba8_pixel_t(255, 0, 0, 0)}; | ||||
| static const uint16_t DEFAULT_COLOR_TABLE_MIN = 2u; | ||||
| static const uint16_t DEFAULT_COLOR_TABLE_MAX = 255u; | ||||
| static const std::uint16_t kDefaultColorTableMin_ = 2u; | ||||
| static const std::uint16_t kDefaultColorTableMax_ = 255u; | ||||
| 
 | ||||
| class RadarProductViewImpl | ||||
| { | ||||
|  | @ -30,6 +30,7 @@ public: | |||
|       std::shared_ptr<manager::RadarProductManager> radarProductManager) : | ||||
|        initialized_ {false}, | ||||
|        sweepMutex_ {}, | ||||
|        selectedTime_ {}, | ||||
|        radarProductManager_ {radarProductManager} | ||||
|    { | ||||
|    } | ||||
|  | @ -38,6 +39,8 @@ public: | |||
|    bool       initialized_; | ||||
|    std::mutex sweepMutex_; | ||||
| 
 | ||||
|    std::chrono::system_clock::time_point selectedTime_; | ||||
| 
 | ||||
|    std::shared_ptr<manager::RadarProductManager> radarProductManager_; | ||||
| }; | ||||
| 
 | ||||
|  | @ -49,17 +52,17 @@ RadarProductView::~RadarProductView() = default; | |||
| const std::vector<boost::gil::rgba8_pixel_t>& | ||||
| RadarProductView::color_table() const | ||||
| { | ||||
|    return DEFAULT_COLOR_TABLE; | ||||
|    return kDefaultColorTable_; | ||||
| } | ||||
| 
 | ||||
| uint16_t RadarProductView::color_table_min() const | ||||
| std::uint16_t RadarProductView::color_table_min() const | ||||
| { | ||||
|    return DEFAULT_COLOR_TABLE_MIN; | ||||
|    return kDefaultColorTableMin_; | ||||
| } | ||||
| 
 | ||||
| uint16_t RadarProductView::color_table_max() const | ||||
| std::uint16_t RadarProductView::color_table_max() const | ||||
| { | ||||
|    return DEFAULT_COLOR_TABLE_MAX; | ||||
|    return kDefaultColorTableMax_; | ||||
| } | ||||
| 
 | ||||
| float RadarProductView::elevation() const | ||||
|  | @ -78,6 +81,11 @@ float RadarProductView::range() const | |||
|    return 0.0f; | ||||
| } | ||||
| 
 | ||||
| std::chrono::system_clock::time_point RadarProductView::selected_time() const | ||||
| { | ||||
|    return p->selectedTime_; | ||||
| } | ||||
| 
 | ||||
| std::chrono::system_clock::time_point RadarProductView::sweep_time() const | ||||
| { | ||||
|    return {}; | ||||
|  | @ -103,6 +111,11 @@ void RadarProductView::Initialize() | |||
| 
 | ||||
| void RadarProductView::SelectElevation(float /*elevation*/) {} | ||||
| 
 | ||||
| void RadarProductView::SelectTime(std::chrono::system_clock::time_point time) | ||||
| { | ||||
|    p->selectedTime_ = time; | ||||
| } | ||||
| 
 | ||||
| bool RadarProductView::IsInitialized() const | ||||
| { | ||||
|    return p->initialized_; | ||||
|  | @ -113,12 +126,12 @@ std::vector<float> RadarProductView::GetElevationCuts() const | |||
|    return {}; | ||||
| } | ||||
| 
 | ||||
| std::tuple<const void*, size_t, size_t> | ||||
| std::tuple<const void*, std::size_t, std::size_t> | ||||
| RadarProductView::GetCfpMomentData() const | ||||
| { | ||||
|    const void* data          = nullptr; | ||||
|    size_t      dataSize      = 0; | ||||
|    size_t      componentSize = 0; | ||||
|    std::size_t dataSize      = 0; | ||||
|    std::size_t componentSize = 0; | ||||
| 
 | ||||
|    return std::tie(data, dataSize, componentSize); | ||||
| } | ||||
|  |  | |||
|  | @ -30,15 +30,16 @@ public: | |||
|    virtual ~RadarProductView(); | ||||
| 
 | ||||
|    virtual const std::vector<boost::gil::rgba8_pixel_t>& color_table() const; | ||||
|    virtual uint16_t                              color_table_min() const; | ||||
|    virtual uint16_t                              color_table_max() const; | ||||
|    virtual std::uint16_t                         color_table_min() const; | ||||
|    virtual std::uint16_t                         color_table_max() const; | ||||
|    virtual float                                 elevation() const; | ||||
|    virtual float                                 range() const; | ||||
|    virtual std::chrono::system_clock::time_point sweep_time() const; | ||||
|    virtual uint16_t                              vcp() const      = 0; | ||||
|    virtual std::uint16_t                         vcp() const      = 0; | ||||
|    virtual const std::vector<float>&             vertices() const = 0; | ||||
| 
 | ||||
|    std::shared_ptr<manager::RadarProductManager> radar_product_manager() const; | ||||
|    std::chrono::system_clock::time_point         selected_time() const; | ||||
|    std::mutex&                                   sweep_mutex(); | ||||
| 
 | ||||
|    void set_radar_product_manager( | ||||
|  | @ -48,17 +49,19 @@ public: | |||
|    virtual void | ||||
|    LoadColorTable(std::shared_ptr<common::ColorTable> colorTable) = 0; | ||||
|    virtual void SelectElevation(float elevation); | ||||
|    virtual void SelectProduct(const std::string& productName)          = 0; | ||||
|    virtual void SelectTime(std::chrono::system_clock::time_point time) = 0; | ||||
|    virtual void Update()                                               = 0; | ||||
|    virtual void SelectProduct(const std::string& productName) = 0; | ||||
|    void         SelectTime(std::chrono::system_clock::time_point time); | ||||
|    virtual void Update() = 0; | ||||
| 
 | ||||
|    bool IsInitialized() const; | ||||
| 
 | ||||
|    virtual common::RadarProductGroup GetRadarProductGroup() const = 0; | ||||
|    virtual std::string               GetRadarProductName() const  = 0; | ||||
|    virtual std::vector<float>        GetElevationCuts() const; | ||||
|    virtual std::tuple<const void*, size_t, size_t> GetMomentData() const = 0; | ||||
|    virtual std::tuple<const void*, size_t, size_t> GetCfpMomentData() const; | ||||
|    virtual std::tuple<const void*, std::size_t, std::size_t> | ||||
|    GetMomentData() const = 0; | ||||
|    virtual std::tuple<const void*, std::size_t, std::size_t> | ||||
|    GetCfpMomentData() const; | ||||
| 
 | ||||
| protected: | ||||
|    virtual void UpdateColorTable() = 0; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat