Added a functionaity that saves the latest GPS Ephemeris/IONO/UTC model data to XML disk files when gnss-sdr end its operations.

git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@408 64b25241-fba3-4117-9849-534c7e92360d
This commit is contained in:
Javier Arribas 2013-08-21 15:17:02 +00:00
parent 74817d6d07
commit 0139591baa
4 changed files with 157 additions and 1 deletions

View File

@ -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<int,Gps_Ephemeris> 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"<<std::endl;
}
catch (std::exception& e)
{
LOG_AT_LEVEL(ERROR) << e.what();
}
}
}
void ControlThread::gps_utc_model_data_write_to_XML()
{
//Save ephemeris to XML file
std::string xml_filename="gps_utc_model_rx.xml";
std::map<int,Gps_Utc_Model> 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"<<std::endl;
}
catch (std::exception& e)
{
LOG_AT_LEVEL(ERROR) << e.what();
}
}
}
void ControlThread::gps_iono_data_write_to_XML()
{
//Save ephemeris to XML file
std::string xml_filename="gps_iono_rx.xml";
std::map<int,Gps_Iono> map_copy;
std::map<int,Gps_Iono>::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"<<std::endl;
}
catch (std::exception& e)
{
LOG_AT_LEVEL(ERROR) << e.what();
}
}
}
void ControlThread::keyboard_listener()
{
bool read_keys = true;

View File

@ -117,13 +117,48 @@ private:
int supl_ci; // Cell Identity (16 bits, 0-65535 are valid values).
void init();
/*
* \brief Read ephemeris assistance from a local XML file previously recorded
*/
bool read_assistance_from_XML();
void read_control_messages();
void process_control_messages();
/*
* \brief Blocking function that reads the GPS ephemeris queue and updates the shared ephemeris map, accessible from the PVT block
*/
void gps_ephemeris_data_collector();
/*
* \brief Writes the ephemeris map to a local XML file
*/
void gps_ephemeris_data_write_to_XML();
/*
* \brief Blocking function that reads the UTC model queue and updates the shared map, accessible from the PVT block
*/
void gps_utc_model_data_collector();
/*
* \brief Write the latest GPS UTC model to XML file
*/
void gps_utc_model_data_write_to_XML();
/*
* \brief Blocking function that reads the iono model queue and updates the shared map, accessible from the PVT block
*/
void gps_iono_data_collector();
/*
* \brief Write the latest GPS IONO model to XML file
*/
void gps_iono_data_write_to_XML();
/*
* \brief Blocking function that reads the GPS assistance queue
*/
void gps_acq_assist_data_collector();
void apply_action(unsigned int what);
GNSSFlowgraph *flowgraph_;
ConfigurationInterface *configuration_;

View File

@ -33,6 +33,8 @@
#define GNSS_SDR_GPS_IONO_H_
#include "GPS_L1_CA.h"
#include "boost/assign.hpp"
#include <boost/serialization/nvp.hpp>
/*!
@ -60,6 +62,25 @@ public:
* Default constructor
*/
Gps_Iono();
template<class Archive>
/*
* \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

View File

@ -33,6 +33,8 @@
#define GNSS_SDR_GPS_UTC_MODEL_H_
#include "GPS_L1_CA.h"
#include "boost/assign.hpp"
#include <boost/serialization/nvp.hpp>
/*!
@ -59,6 +61,25 @@ public:
*/
Gps_Utc_Model();
template<class Archive>
/*
* \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)