From c4b2aa8cc42cc2d5dc7d1235f9dfc880291a0545 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 25 Oct 2018 00:43:25 +0200 Subject: [PATCH] Read Galileo almamac xml file if present --- src/core/libs/gnss_sdr_supl_client.cc | 47 +++++++++++++++++++++++++++ src/core/libs/gnss_sdr_supl_client.h | 12 +++++++ src/core/receiver/control_thread.cc | 16 +++++++++ src/core/receiver/control_thread.h | 1 + 4 files changed, 76 insertions(+) diff --git a/src/core/libs/gnss_sdr_supl_client.cc b/src/core/libs/gnss_sdr_supl_client.cc index 022f658fe..9218009c6 100644 --- a/src/core/libs/gnss_sdr_supl_client.cc +++ b/src/core/libs/gnss_sdr_supl_client.cc @@ -786,6 +786,53 @@ bool gnss_sdr_supl_client::save_gal_iono_xml(const std::string file_name, Galile } +bool gnss_sdr_supl_client::load_gal_almanac_xml(const std::string file_name) +{ + std::ifstream ifs; + try + { + ifs.open(file_name.c_str(), std::ifstream::binary | std::ifstream::in); + boost::archive::xml_iarchive xml(ifs); + gal_almanac_map.clear(); + xml >> boost::serialization::make_nvp("GNSS-SDR_gal_almanac_map", this->gal_almanac_map); + LOG(INFO) << "Loaded Galileo almanac map data with " << this->gal_almanac_map.size() << " satellites"; + } + catch (std::exception& e) + { + LOG(WARNING) << e.what() << "File: " << file_name; + return false; + } + return true; +} + + +bool gnss_sdr_supl_client::save_gal_almanac_xml(const std::string file_name, std::map gal_almanac_map) +{ + if (gal_almanac_map.empty() == false) + { + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_gal_almanac_map", gal_almanac_map); + LOG(INFO) << "Saved Galileo almanac data"; + } + catch (std::exception& e) + { + LOG(WARNING) << e.what(); + return false; + } + } + else + { + LOG(WARNING) << "Failed to save Galileo almanac, map is empty"; + return false; + } + return true; +} + + bool gnss_sdr_supl_client::load_glo_utc_xml(const std::string file_name) { std::ifstream ifs; diff --git a/src/core/libs/gnss_sdr_supl_client.h b/src/core/libs/gnss_sdr_supl_client.h index 465e552f3..b58b4a62f 100644 --- a/src/core/libs/gnss_sdr_supl_client.h +++ b/src/core/libs/gnss_sdr_supl_client.h @@ -51,6 +51,7 @@ extern "C" #include "galileo_ephemeris.h" #include "galileo_utc_model.h" #include "galileo_iono.h" +#include "galileo_almanac.h" #include "glonass_gnav_ephemeris.h" #include "glonass_gnav_utc_model.h" #include @@ -90,6 +91,7 @@ public: // almanac map std::map gps_almanac_map; + std::map gal_almanac_map; // ionospheric model Gps_Iono gps_iono; @@ -195,6 +197,16 @@ public: */ bool save_gal_utc_xml(const std::string file_name, Galileo_Utc_Model& utc); + /*! + * \brief Read Galileo almanac map from XML file + */ + bool load_gal_almanac_xml(const std::string file_name); + + /*! + * \brief Save Galileo almanac map to XML file + */ + bool save_gal_almanac_xml(const std::string file_name, std::map gal_almanac); + /*! * \brief Read iono from XML file */ diff --git a/src/core/receiver/control_thread.cc b/src/core/receiver/control_thread.cc index ff4cd82c7..49f31dafa 100644 --- a/src/core/receiver/control_thread.cc +++ b/src/core/receiver/control_thread.cc @@ -234,6 +234,7 @@ bool ControlThread::read_assistance_from_XML() std::string cnav_utc_xml_filename = configuration_->property("GNSS-SDR.SUPL_cnav_utc_model_xml", cnav_utc_default_xml_filename); std::string eph_glo_xml_filename = configuration_->property("GNSS-SDR.SUPL_glo_ephemeris_xml", eph_glo_gnav_default_xml_filename); std::string glo_utc_xml_filename = configuration_->property("GNSS-SDR.SUPL_glo_utc_model_xml", glo_utc_default_xml_filename); + std::string gal_almanac_xml_filename = configuration_->property("GNSS-SDR.SUPL_gal_almanacl_xml", gal_almanac_default_xml_filename); if (configuration_->property("GNSS-SDR.AGNSS_XML_enabled", false) == true) { @@ -249,6 +250,7 @@ bool ControlThread::read_assistance_from_XML() cnav_utc_xml_filename = configuration_->property("GNSS-SDR.AGNSS_cnav_utc_model_xml", cnav_utc_default_xml_filename); eph_glo_xml_filename = configuration_->property("GNSS-SDR.AGNSS_glo_ephemeris_xml", eph_glo_gnav_default_xml_filename); glo_utc_xml_filename = configuration_->property("GNSS-SDR.AGNSS_glo_utc_model_xml", glo_utc_default_xml_filename); + gal_almanac_xml_filename = configuration_->property("GNSS-SDR.AGNSS_gal_almanacl_xml", gal_almanac_default_xml_filename); } std::cout << "Trying to read GNSS ephemeris from XML file(s)..." << std::endl; @@ -317,6 +319,20 @@ bool ControlThread::read_assistance_from_XML() std::cout << "From XML file: Read Galileo UTC model parameters." << std::endl; ret = true; } + + if (supl_client_ephemeris_.load_gal_almanac_xml(gal_almanac_xml_filename) == true) + { + std::map::const_iterator gal_alm_iter; + for (gal_alm_iter = supl_client_ephemeris_.gal_almanac_map.cbegin(); + gal_alm_iter != supl_client_ephemeris_.gal_almanac_map.cend(); + gal_alm_iter++) + { + std::cout << "From XML file: Read Galileo almanac for satellite " << Gnss_Satellite("Galileo", gal_alm_iter->second.i_satellite_PRN) << std::endl; + std::shared_ptr tmp_obj = std::make_shared(gal_alm_iter->second); + flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); + } + ret = true; + } } if ((configuration_->property("Channels_2S.count", 0) > 0) or (configuration_->property("Channels_L5.count", 0) > 0)) diff --git a/src/core/receiver/control_thread.h b/src/core/receiver/control_thread.h index e8e62b5fe..2fda50752 100644 --- a/src/core/receiver/control_thread.h +++ b/src/core/receiver/control_thread.h @@ -180,6 +180,7 @@ private: const std::string cnav_utc_default_xml_filename = "./gps_cnav_utc_model.xml"; const std::string eph_glo_gnav_default_xml_filename = "./glo_gnav_ephemeris.xml"; const std::string glo_utc_default_xml_filename = "./glo_utc_model.xml"; + const std::string gal_almanac_default_xml_filename = "./gal_almanac.xml"; }; #endif /*GNSS_SDR_CONTROL_THREAD_H_*/