From a10b1fe0f4331ef817a677dc16faef58e62c3889 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 19 Oct 2018 14:48:41 +0200 Subject: [PATCH] Store and read CNAV UTC parameters in Assisted mode --- .../PVT/gnuradio_blocks/rtklib_pvt_cc.cc | 34 +++++++++++--- src/core/libs/gnss_sdr_supl_client.cc | 46 +++++++++++++++++++ src/core/libs/gnss_sdr_supl_client.h | 13 ++++++ src/core/receiver/control_thread.cc | 14 ++++-- src/core/receiver/control_thread.h | 1 + 5 files changed, 98 insertions(+), 10 deletions(-) diff --git a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.cc b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.cc index 8490d1fb0..13498ee71 100644 --- a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.cc +++ b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.cc @@ -414,7 +414,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc() } else { - LOG(WARNING) << "Failed to save GPS L2CM or L5 Ephemeris, map is empty"; + LOG(INFO) << "Failed to save GPS L2CM or L5 Ephemeris, map is empty"; } // save GPS L1 CA ephemeris to XML file @@ -436,7 +436,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc() } else { - LOG(WARNING) << "Failed to save GPS L1 CA Ephemeris, map is empty"; + LOG(INFO) << "Failed to save GPS L1 CA Ephemeris, map is empty"; } // save Galileo E1 ephemeris to XML file @@ -458,7 +458,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc() } else { - LOG(WARNING) << "Failed to save Galileo E1 Ephemeris, map is empty"; + LOG(INFO) << "Failed to save Galileo E1 Ephemeris, map is empty"; } // save GLONASS GNAV ephemeris to XML file @@ -480,7 +480,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc() } else { - LOG(WARNING) << "Failed to save GLONASS GNAV Ephemeris, map is empty"; + LOG(INFO) << "Failed to save GLONASS GNAV Ephemeris, map is empty"; } // Save GPS UTC model parameters @@ -502,7 +502,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc() } else { - LOG(WARNING) << "Failed to save GPS UTC model parameters, not valid data"; + LOG(INFO) << "Failed to save GPS UTC model parameters, not valid data"; } // Save Galileo UTC model parameters @@ -524,7 +524,29 @@ rtklib_pvt_cc::~rtklib_pvt_cc() } else { - LOG(WARNING) << "Failed to save Galileo UTC model parameters, not valid data"; + LOG(INFO) << "Failed to save Galileo UTC model parameters, not valid data"; + } + + // Save GPS CNAV UTC model parameters + file_name = "gps_cnav_utc_model.xml"; + if (d_ls_pvt->gps_cnav_utc_model.valid) + { + 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_cnav_utc_model", d_ls_pvt->gps_cnav_utc_model); + LOG(INFO) << "Saved GPS CNAV UTC model parameters"; + } + catch (std::exception& e) + { + LOG(WARNING) << e.what(); + } + } + else + { + LOG(INFO) << "Failed to save GPS CNAV UTC model parameters, not valid data"; } } diff --git a/src/core/libs/gnss_sdr_supl_client.cc b/src/core/libs/gnss_sdr_supl_client.cc index 6d2d8d726..ce4df68f0 100644 --- a/src/core/libs/gnss_sdr_supl_client.cc +++ b/src/core/libs/gnss_sdr_supl_client.cc @@ -555,6 +555,52 @@ bool gnss_sdr_supl_client::save_utc_xml(const std::string file_name, Gps_Utc_Mod } +bool gnss_sdr_supl_client::load_cnav_utc_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); + xml >> boost::serialization::make_nvp("GNSS-SDR_cnav_utc_model", this->gps_cnav_utc); + LOG(INFO) << "Loaded CNAV UTC model data"; + } + catch (std::exception& e) + { + LOG(WARNING) << e.what() << "File: " << file_name; + return false; + } + return true; +} + + +bool gnss_sdr_supl_client::save_cnav_utc_xml(const std::string file_name, Gps_CNAV_Utc_Model& utc) +{ + if (utc.valid) + { + 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_cnav_utc_model", utc); + LOG(INFO) << "Saved GPS CNAV UTC model data"; + } + catch (std::exception& e) + { + LOG(WARNING) << e.what(); + return false; + } + } + else + { + LOG(WARNING) << "Failed to save GPS CNAV UTC model, no valid data"; + return false; + } + return true; +} + + bool gnss_sdr_supl_client::load_gal_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 4e9fdbbb9..9aea60492 100644 --- a/src/core/libs/gnss_sdr_supl_client.h +++ b/src/core/libs/gnss_sdr_supl_client.h @@ -43,6 +43,7 @@ extern "C" #include "gps_iono.h" #include "gps_almanac.h" #include "gps_utc_model.h" +#include "gps_cnav_utc_model.h" #include "gps_acq_assist.h" #include "gps_ref_time.h" #include "gps_ref_location.h" @@ -94,6 +95,7 @@ public: // UTC model Gps_Utc_Model gps_utc; Galileo_Utc_Model gal_utc; + Gps_CNAV_Utc_Model gps_cnav_utc; // reference location Gps_Ref_Location gps_ref_loc; // Acquisition Assistance map @@ -158,6 +160,17 @@ public: */ bool save_utc_xml(const std::string file_name, Gps_Utc_Model& utc); + /*! + * \brief Read CNAV GPS utc model from XML file + */ + bool load_cnav_utc_xml(const std::string file_name); + + /*! + * \brief Save CNAV UTC model map to XML file + * To be called by ControlThread::gps_utc_model_data_write_to_XML() + */ + bool save_cnav_utc_xml(const std::string file_name, Gps_CNAV_Utc_Model& utc); + /*! * \brief Read Galileo utc model from XML file */ diff --git a/src/core/receiver/control_thread.cc b/src/core/receiver/control_thread.cc index de3dc893b..98daa01b5 100644 --- a/src/core/receiver/control_thread.cc +++ b/src/core/receiver/control_thread.cc @@ -207,11 +207,9 @@ bool ControlThread::read_assistance_from_XML() std::string eph_gal_xml_filename = configuration_->property("GNSS-SDR.SUPL_gal_ephemeris_xml", eph_gal_default_xml_filename); std::string eph_cnav_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_cnav_ephemeris_xml", eph_cnav_default_xml_filename); std::string gal_utc_xml_filename = configuration_->property("GNSS-SDR.SUPL_gal_utc_model.xml", gal_utc_default_xml_filename); + std::string cnav_utc_xml_filename = configuration_->property("GNSS-SDR.SUPL_cnav_utc_model.xml", cnav_utc_default_xml_filename); - std::cout << "Trying to read GNSS ephemeris from XML file(s): " - << ((eph_xml_filename.compare(eph_default_xml_filename) != 0) ? eph_xml_filename + " " : "") - << ((eph_gal_xml_filename.compare(eph_gal_default_xml_filename) != 0) ? eph_gal_xml_filename + " " : "") - << ((eph_cnav_xml_filename.compare(eph_cnav_default_xml_filename) != 0) ? eph_gal_xml_filename : "") + std::cout << "Trying to read GNSS ephemeris from XML file(s)..." << std::endl; if (supl_client_ephemeris_.load_ephemeris_xml(eph_xml_filename) == true) @@ -288,6 +286,14 @@ bool ControlThread::read_assistance_from_XML() ret = true; } + if (supl_client_acquisition_.load_cnav_utc_xml(cnav_utc_xml_filename) == true) + { + std::shared_ptr tmp_obj = std::make_shared(supl_client_acquisition_.gps_cnav_utc); + flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); + std::cout << "From XML file: Read GPS CNAV UTC parameters." << std::endl; + ret = true; + } + if (ret == false) { std::cout << "ERROR: SUPL client error reading XML" << std::endl; diff --git a/src/core/receiver/control_thread.h b/src/core/receiver/control_thread.h index b978b7757..534fc968e 100644 --- a/src/core/receiver/control_thread.h +++ b/src/core/receiver/control_thread.h @@ -171,6 +171,7 @@ private: const std::string eph_cnav_default_xml_filename = "./gps_cnav_ephemeris.xml"; const std::string gal_iono_default_xml_filename = "./gal_iono.xml"; const std::string gal_utc_default_xml_filename = "./gal_utc_model.xml"; + const std::string cnav_utc_default_xml_filename = "./gps_cnav_utc_model.xml"; }; #endif /*GNSS_SDR_CONTROL_THREAD_H_*/