mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 01:40:04 +00:00 
			
		
		
		
	Add Radar Product Manager debug dump
- Allows visibility of currently loaded products
This commit is contained in:
		
							parent
							
								
									6e10ca88d5
								
							
						
					
					
						commit
						871cae68dd
					
				
					 5 changed files with 73 additions and 3 deletions
				
			
		|  | @ -357,6 +357,11 @@ void MainWindow::on_actionImGuiDebug_triggered() | |||
|    p->imGuiDebugDialog_->show(); | ||||
| } | ||||
| 
 | ||||
| void MainWindow::on_actionDumpRadarProductRecords_triggered() | ||||
| { | ||||
|    manager::RadarProductManager::DumpRecords(); | ||||
| } | ||||
| 
 | ||||
| void MainWindow::on_actionUserManual_triggered() | ||||
| { | ||||
|    QDesktopServices::openUrl(QUrl {"https://supercell-wx.readthedocs.io/"}); | ||||
|  |  | |||
|  | @ -37,6 +37,7 @@ private slots: | |||
|    void on_actionSettings_triggered(); | ||||
|    void on_actionExit_triggered(); | ||||
|    void on_actionImGuiDebug_triggered(); | ||||
|    void on_actionDumpRadarProductRecords_triggered(); | ||||
|    void on_actionUserManual_triggered(); | ||||
|    void on_actionDiscord_triggered(); | ||||
|    void on_actionGitHubRepository_triggered(); | ||||
|  |  | |||
|  | @ -83,6 +83,8 @@ | |||
|      <string>&Debug</string> | ||||
|     </property> | ||||
|     <addaction name="actionImGuiDebug"/> | ||||
|     <addaction name="separator"/> | ||||
|     <addaction name="actionDumpRadarProductRecords"/> | ||||
|    </widget> | ||||
|    <addaction name="menuFile"/> | ||||
|    <addaction name="menuView"/> | ||||
|  | @ -397,6 +399,11 @@ | |||
|     <string>&GitHub Repository</string> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionDumpRadarProductRecords"> | ||||
|    <property name="text"> | ||||
|     <string>Dump Radar &Product Records</string> | ||||
|    </property> | ||||
|   </action> | ||||
|  </widget> | ||||
|  <resources> | ||||
|   <include location="../../../../scwx-qt.qrc"/> | ||||
|  |  | |||
|  | @ -55,7 +55,7 @@ static constexpr std::chrono::seconds kRetryInterval_ {15}; | |||
| 
 | ||||
| static std::unordered_map<std::string, std::weak_ptr<RadarProductManager>> | ||||
|                          instanceMap_; | ||||
| static std::mutex instanceMutex_; | ||||
| static std::shared_mutex instanceMutex_; | ||||
| 
 | ||||
| static std::unordered_map<std::string, | ||||
|                           std::shared_ptr<types::RadarProductRecord>> | ||||
|  | @ -276,6 +276,58 @@ void RadarProductManager::Cleanup() | |||
|    } | ||||
| } | ||||
| 
 | ||||
| void RadarProductManager::DumpRecords() | ||||
| { | ||||
|    scwx::util::async( | ||||
|       [] | ||||
|       { | ||||
|          logger_->info("Record Dump"); | ||||
| 
 | ||||
|          std::shared_lock instanceLock {instanceMutex_}; | ||||
|          for (auto& instance : instanceMap_) | ||||
|          { | ||||
|             auto radarProductManager = instance.second.lock(); | ||||
|             if (radarProductManager != nullptr) | ||||
|             { | ||||
|                logger_->info(" {}", radarProductManager->radar_site()->id()); | ||||
|                logger_->info("  Level 2"); | ||||
| 
 | ||||
|                { | ||||
|                   std::shared_lock level2ProductLock { | ||||
|                      radarProductManager->p->level2ProductRecordMutex_}; | ||||
| 
 | ||||
|                   for (auto& record : | ||||
|                        radarProductManager->p->level2ProductRecords_) | ||||
|                   { | ||||
|                      logger_->info("   {}", | ||||
|                                    scwx::util::TimeString(record.first)); | ||||
|                   } | ||||
|                } | ||||
| 
 | ||||
|                logger_->info("  Level 3"); | ||||
| 
 | ||||
|                { | ||||
|                   std::shared_lock level3ProductLock { | ||||
|                      radarProductManager->p->level3ProductRecordMutex_}; | ||||
| 
 | ||||
|                   for (auto& recordMap : | ||||
|                        radarProductManager->p->level3ProductRecordsMap_) | ||||
|                   { | ||||
|                      // Product Name
 | ||||
|                      logger_->info("   {}", recordMap.first); | ||||
| 
 | ||||
|                      for (auto& record : recordMap.second) | ||||
|                      { | ||||
|                         logger_->info("    {}", | ||||
|                                       scwx::util::TimeString(record.first)); | ||||
|                      } | ||||
|                   } | ||||
|                } | ||||
|             } | ||||
|          } | ||||
|       }); | ||||
| } | ||||
| 
 | ||||
| const std::vector<float>& | ||||
| RadarProductManager::coordinates(common::RadialSize radialSize) const | ||||
| { | ||||
|  | @ -1030,7 +1082,7 @@ RadarProductManager::Instance(const std::string& radarSite) | |||
|    bool                                 instanceCreated = false; | ||||
| 
 | ||||
|    { | ||||
|       std::lock_guard<std::mutex> guard(instanceMutex_); | ||||
|       std::unique_lock lock {instanceMutex_}; | ||||
| 
 | ||||
|       // Look up instance weak pointer
 | ||||
|       auto it = instanceMap_.find(radarSite); | ||||
|  |  | |||
|  | @ -34,6 +34,11 @@ public: | |||
| 
 | ||||
|    static void Cleanup(); | ||||
| 
 | ||||
|    /**
 | ||||
|     * @brief Debug function to dump currently loaded products to the log. | ||||
|     */ | ||||
|    static void DumpRecords(); | ||||
| 
 | ||||
|    const std::vector<float>& coordinates(common::RadialSize radialSize) const; | ||||
|    float                     gate_size() const; | ||||
|    std::shared_ptr<config::RadarSite> radar_site() const; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat