1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-15 12:40:35 +00:00

Read GPS almanac file if present

This commit is contained in:
Carles Fernandez 2018-10-25 11:01:29 +02:00
parent 20302ed28f
commit bc058d33da
7 changed files with 118 additions and 0 deletions

View File

@ -538,6 +538,28 @@ rtklib_pvt_cc::~rtklib_pvt_cc()
LOG(INFO) << "Failed to save Galileo UTC model parameters, not valid data";
}
// save GPS almanac to XML file
file_name = "gps_almanac.xml";
if (d_ls_pvt->gps_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_gps_almanac_map", d_ls_pvt->gps_almanac_map);
LOG(INFO) << "Saved GPS almanac map data";
}
catch (const std::exception& e)
{
LOG(WARNING) << e.what();
}
}
else
{
LOG(INFO) << "Failed to save GPS almanac, map is empty";
}
// Save Galileo almanac
file_name = "gal_almanac.xml";
if (d_ls_pvt->galileo_almanac_map.empty() == false)

View File

@ -104,6 +104,7 @@ public:
Gps_Utc_Model gps_utc_model;
Gps_Iono gps_iono;
std::map<int, Gps_Almanac> gps_almanac_map;
Gps_CNAV_Iono gps_cnav_iono;
Gps_CNAV_Utc_Model gps_cnav_utc_model;

View File

@ -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_gps_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);
gps_almanac_map.clear();
xml >> boost::serialization::make_nvp("GNSS-SDR_gps_almanac_map", this->gps_almanac_map);
LOG(INFO) << "Loaded GPS almanac map data with " << this->gps_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_gps_almanac_xml(const std::string file_name, std::map<int, Gps_Almanac> gps_almanac_map)
{
if (gps_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_gps_almanac_map", gps_almanac_map);
LOG(INFO) << "Saved GPS almanac data";
}
catch (std::exception& e)
{
LOG(WARNING) << e.what();
return false;
}
}
else
{
LOG(WARNING) << "Failed to save GPS almanac, map is empty";
return false;
}
return true;
}
bool gnss_sdr_supl_client::load_gal_almanac_xml(const std::string file_name)
{
std::ifstream ifs;

View File

@ -207,6 +207,16 @@ public:
*/
bool save_gal_almanac_xml(const std::string file_name, std::map<int, Galileo_Almanac> gal_almanac);
/*!
* \brief Read GPS almanac map from XML file
*/
bool load_gps_almanac_xml(const std::string file_name);
/*!
* \brief Save GPS almanac map to XML file
*/
bool save_gps_almanac_xml(const std::string file_name, std::map<int, Gps_Almanac> gps_almanac_map);
/*!
* \brief Read iono from XML file
*/

View File

@ -235,6 +235,7 @@ bool ControlThread::read_assistance_from_XML()
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);
std::string gps_almanac_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_almanacl_xml", gps_almanac_default_xml_filename);
if (configuration_->property("GNSS-SDR.AGNSS_XML_enabled", false) == true)
{
@ -286,6 +287,20 @@ bool ControlThread::read_assistance_from_XML()
std::cout << "From XML file: Read GPS ionosphere model parameters." << std::endl;
ret = true;
}
if (supl_client_ephemeris_.load_gps_almanac_xml(gps_almanac_xml_filename) == true)
{
std::map<int, Gps_Almanac>::const_iterator gps_alm_iter;
for (gps_alm_iter = supl_client_ephemeris_.gps_almanac_map.cbegin();
gps_alm_iter != supl_client_ephemeris_.gps_almanac_map.cend();
gps_alm_iter++)
{
std::cout << "From XML file: Read GPS almanac for satellite " << Gnss_Satellite("GPS", gps_alm_iter->second.i_satellite_PRN) << std::endl;
std::shared_ptr<Gps_Almanac> tmp_obj = std::make_shared<Gps_Almanac>(gps_alm_iter->second);
flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj));
}
ret = true;
}
}
if ((configuration_->property("Channels_1B.count", 0) > 0) or (configuration_->property("Channels_5X.count", 0) > 0))

View File

@ -181,6 +181,7 @@ private:
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";
const std::string gps_almanac_default_xml_filename = "./gps_almanac.xml";
};
#endif /*GNSS_SDR_CONTROL_THREAD_H_*/

View File

@ -32,6 +32,7 @@
#ifndef GNSS_SDR_GPS_ALMANAC_H_
#define GNSS_SDR_GPS_ALMANAC_H_
#include <boost/serialization/nvp.hpp>
#include <cstdint>
/*!
@ -59,6 +60,27 @@ public:
* Default constructor
*/
Gps_Almanac();
template <class Archive>
void serialize(Archive& ar, const unsigned int version)
{
if (version)
{
};
ar& BOOST_SERIALIZATION_NVP(i_satellite_PRN);
ar& BOOST_SERIALIZATION_NVP(d_Delta_i);
ar& BOOST_SERIALIZATION_NVP(d_Toa);
ar& BOOST_SERIALIZATION_NVP(d_M_0);
ar& BOOST_SERIALIZATION_NVP(d_e_eccentricity);
ar& BOOST_SERIALIZATION_NVP(d_sqrt_A);
ar& BOOST_SERIALIZATION_NVP(d_OMEGA0);
ar& BOOST_SERIALIZATION_NVP(d_OMEGA);
ar& BOOST_SERIALIZATION_NVP(d_OMEGA_DOT);
ar& BOOST_SERIALIZATION_NVP(i_SV_health);
ar& BOOST_SERIALIZATION_NVP(d_A_f0);
ar& BOOST_SERIALIZATION_NVP(d_A_f1);
}
};
#endif