diff --git a/src/core/receiver/control_thread.cc b/src/core/receiver/control_thread.cc index 9b2e48287..88f71bacc 100644 --- a/src/core/receiver/control_thread.cc +++ b/src/core/receiver/control_thread.cc @@ -87,6 +87,11 @@ ControlThread::ControlThread(ConfigurationInterface *configuration) ControlThread::~ControlThread() { + // save navigation data to files + gps_ephemeris_data_write_to_XML(); + gps_iono_data_write_to_XML(); + gps_utc_model_data_write_to_XML(); + delete flowgraph_; if (delete_configuration_) delete configuration_; delete control_message_factory_; @@ -479,7 +484,7 @@ void ControlThread::gps_utc_model_data_collector() while(stop_==false) { global_gps_utc_model_queue.wait_and_pop(gps_utc); - std::cout << "New UTC MODEL record has arrived "<< std::endl; + std::cout << "New UTC MODEL record has arrived with A0="<< gps_utc.d_A0<< std::endl; // insert new ephemeris record to the global ephemeris map if (global_gps_utc_model_map.read(0,gps_utc_old)) { @@ -493,6 +498,80 @@ void ControlThread::gps_utc_model_data_collector() } +void ControlThread::gps_ephemeris_data_write_to_XML() +{ + //Save ephemeris to XML file + std::string eph_xml_filename="gps_ephemeris_rx.xml"; + std::map eph_copy; + + eph_copy=global_gps_ephemeris_map.get_map_copy(); + if (eph_copy.size()>0) + { + try + { + std::ofstream ofs(eph_xml_filename.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_ephemeris_map", eph_copy); + ofs.close(); + std::cout<<"Saved Ephemeris data"< map_copy; + + map_copy=global_gps_utc_model_map.get_map_copy(); + if (map_copy.size()>0) + { + try + { + std::ofstream ofs(xml_filename.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_utc_map", map_copy); + ofs.close(); + std::cout<<"Saved UTC Model data"< map_copy; + std::map::iterator gps_iono_iter; + + map_copy=global_gps_iono_map.get_map_copy(); + if (map_copy.size()>0) + { + try + { + std::ofstream ofs(xml_filename.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_iono_map", map_copy); + ofs.close(); + std::cout<<"Saved IONO Model data"< /*! @@ -60,6 +62,25 @@ public: * Default constructor */ Gps_Iono(); + + + template + /* + * \brief Serialize is a boost standard method to be called by the boost XML serialization. Here is used to save the ephemeris data on disk file. + */ + void serialize(Archive& archive, const unsigned int version) + { + using boost::serialization::make_nvp; + + archive & make_nvp("d_alpha0",d_alpha0); + archive & make_nvp("d_alpha1",d_alpha1); + archive & make_nvp("d_alpha2",d_alpha2); + archive & make_nvp("d_alpha3",d_alpha3); + archive & make_nvp("d_beta0",d_beta0); + archive & make_nvp("d_beta1",d_beta1); + archive & make_nvp("d_beta2",d_beta2); + archive & make_nvp("d_beta3",d_beta3); + } }; #endif diff --git a/src/core/system_parameters/gps_utc_model.h b/src/core/system_parameters/gps_utc_model.h index 34a695dde..769b3fb27 100644 --- a/src/core/system_parameters/gps_utc_model.h +++ b/src/core/system_parameters/gps_utc_model.h @@ -33,6 +33,8 @@ #define GNSS_SDR_GPS_UTC_MODEL_H_ #include "GPS_L1_CA.h" +#include "boost/assign.hpp" +#include /*! @@ -59,6 +61,25 @@ public: */ Gps_Utc_Model(); + template + /* + * \brief Serialize is a boost standard method to be called by the boost XML serialization. Here is used to save the ephemeris data on disk file. + */ + void serialize(Archive& archive, const unsigned int version) + { + using boost::serialization::make_nvp; + + archive & make_nvp("valid",valid); + archive & make_nvp("d_A1",d_A1); + archive & make_nvp("d_A0",d_A0); + archive & make_nvp("d_t_OT",d_t_OT); + archive & make_nvp("i_WN_T",i_WN_T); + archive & make_nvp("d_DeltaT_LS",d_DeltaT_LS); + archive & make_nvp("i_WN_LSF",i_WN_LSF); + archive & make_nvp("i_DN",i_DN); + archive & make_nvp("d_DeltaT_LSF",d_DeltaT_LSF); + } + /*! * \brief Computes the Coordinated Universal Time (UTC) and * returns it in [s] (IS-GPS-200E, 20.3.3.5.2.4)