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

Sort out names when storing XML files

This commit is contained in:
Carles Fernandez 2018-10-19 13:48:21 +02:00
parent 4d2f7ef966
commit 6f6bb21c76
5 changed files with 254 additions and 83 deletions

View File

@ -396,8 +396,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc()
msgctl(sysv_msqid, IPC_RMID, NULL);
// save GPS L2CM ephemeris to XML file
std::string file_name = "eph_GPS_CNAV.xml";
std::string file_name = "gps_cnav_ephemeris.xml";
if (d_ls_pvt->gps_cnav_ephemeris_map.empty() == false)
{
std::ofstream ofs;
@ -405,7 +404,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc()
{
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_ephemeris_map", d_ls_pvt->gps_cnav_ephemeris_map);
xml << boost::serialization::make_nvp("GNSS-SDR_cnav_ephemeris_map", d_ls_pvt->gps_cnav_ephemeris_map);
LOG(INFO) << "Saved GPS L2CM or L5 Ephemeris map data";
}
catch (std::exception& e)
@ -419,8 +418,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc()
}
// save GPS L1 CA ephemeris to XML file
file_name = "eph_GPS_L1CA.xml";
file_name = "gps_ephemeris.xml";
if (d_ls_pvt->gps_ephemeris_map.empty() == false)
{
std::ofstream ofs;
@ -442,8 +440,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc()
}
// save Galileo E1 ephemeris to XML file
file_name = "eph_Galileo_E1.xml";
file_name = "gal_ephemeris.xml";
if (d_ls_pvt->galileo_ephemeris_map.empty() == false)
{
std::ofstream ofs;
@ -451,7 +448,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc()
{
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_ephemeris_map", d_ls_pvt->galileo_ephemeris_map);
xml << boost::serialization::make_nvp("GNSS-SDR_gal_ephemeris_map", d_ls_pvt->galileo_ephemeris_map);
LOG(INFO) << "Saved Galileo E1 Ephemeris map data";
}
catch (const std::exception& e)
@ -466,7 +463,6 @@ rtklib_pvt_cc::~rtklib_pvt_cc()
// save GLONASS GNAV ephemeris to XML file
file_name = "eph_GLONASS_GNAV.xml";
if (d_ls_pvt->glonass_gnav_ephemeris_map.empty() == false)
{
std::ofstream ofs;
@ -474,7 +470,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc()
{
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_ephemeris_map", d_ls_pvt->glonass_gnav_ephemeris_map);
xml << boost::serialization::make_nvp("GNSS-SDR_gnav_ephemeris_map", d_ls_pvt->glonass_gnav_ephemeris_map);
LOG(INFO) << "Saved GLONASS GNAV Ephemeris map data";
}
catch (std::exception& e)
@ -486,6 +482,50 @@ rtklib_pvt_cc::~rtklib_pvt_cc()
{
LOG(WARNING) << "Failed to save GLONASS GNAV Ephemeris, map is empty";
}
// Save GPS UTC model parameters
file_name = "gps_utc_model.xml";
if (d_ls_pvt->gps_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_utc_model", d_ls_pvt->gps_utc_model);
LOG(INFO) << "Saved GPS UTC model parameters";
}
catch (std::exception& e)
{
LOG(WARNING) << e.what();
}
}
else
{
LOG(WARNING) << "Failed to save GPS UTC model parameters, not valid data";
}
// Save Galileo UTC model parameters
file_name = "gal_utc_model.xml";
if (d_ls_pvt->galileo_utc_model.A0_6 != 0.0)
{
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_utc_model", d_ls_pvt->galileo_utc_model);
LOG(INFO) << "Saved Galileo UTC model parameters";
}
catch (std::exception& e)
{
LOG(WARNING) << e.what();
}
}
else
{
LOG(WARNING) << "Failed to save Galileo UTC model parameters, not valid data";
}
}

View File

@ -388,46 +388,6 @@ bool gnss_sdr_supl_client::load_ephemeris_xml(const std::string file_name)
}
bool gnss_sdr_supl_client::load_gal_ephemeris_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_ephemeris_map.clear();
xml >> boost::serialization::make_nvp("GNSS-SDR_ephemeris_map", this->gal_ephemeris_map);
LOG(INFO) << "Loaded Ephemeris map data with " << this->gal_ephemeris_map.size() << " satellites";
}
catch (std::exception& e)
{
LOG(WARNING) << e.what() << "File: " << file_name;
return false;
}
return true;
}
bool gnss_sdr_supl_client::load_cnav_ephemeris_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_cnav_ephemeris_map.clear();
xml >> boost::serialization::make_nvp("GNSS-SDR_ephemeris_map", this->gps_cnav_ephemeris_map);
LOG(INFO) << "Loaded Ephemeris map data with " << this->gps_cnav_ephemeris_map.size() << " satellites";
}
catch (std::exception& e)
{
LOG(WARNING) << e.what() << "File: " << file_name;
return false;
}
return true;
}
bool gnss_sdr_supl_client::save_ephemeris_map_xml(const std::string file_name, std::map<int, Gps_Ephemeris> eph_map)
{
if (eph_map.empty() == false)
@ -455,6 +415,100 @@ bool gnss_sdr_supl_client::save_ephemeris_map_xml(const std::string file_name, s
}
bool gnss_sdr_supl_client::load_gal_ephemeris_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_ephemeris_map.clear();
xml >> boost::serialization::make_nvp("GNSS-SDR_gal_ephemeris_map", this->gal_ephemeris_map);
LOG(INFO) << "Loaded Ephemeris map data with " << this->gal_ephemeris_map.size() << " satellites";
}
catch (std::exception& e)
{
LOG(WARNING) << e.what() << "File: " << file_name;
return false;
}
return true;
}
bool save_gal_ephemeris_map_xml(const std::string file_name, std::map<int, Galileo_Ephemeris> eph_map)
{
if (eph_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_ephemeris_map", eph_map);
LOG(INFO) << "Saved Galileo ephemeris map data";
}
catch (std::exception& e)
{
LOG(WARNING) << e.what();
return false;
}
}
else
{
LOG(WARNING) << "Failed to save Galileo ephemeris, map is empty";
return false;
}
return true;
}
bool gnss_sdr_supl_client::load_cnav_ephemeris_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_cnav_ephemeris_map.clear();
xml >> boost::serialization::make_nvp("GNSS-SDR_cnav_ephemeris_map", this->gps_cnav_ephemeris_map);
LOG(INFO) << "Loaded Ephemeris map data with " << this->gps_cnav_ephemeris_map.size() << " satellites";
}
catch (std::exception& e)
{
LOG(WARNING) << e.what() << "File: " << file_name;
return false;
}
return true;
}
bool save_cnav_ephemeris_map_xml(const std::string file_name, std::map<int, Gps_CNAV_Ephemeris> eph_map)
{
if (eph_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_cnav_ephemeris_map", eph_map);
LOG(INFO) << "Saved GPS CNAV ephemeris map data";
}
catch (std::exception& e)
{
LOG(WARNING) << e.what();
return false;
}
}
else
{
LOG(WARNING) << "Failed to save GPS CNAV ephemeris, map is empty";
return false;
}
return true;
}
bool gnss_sdr_supl_client::load_utc_xml(const std::string file_name)
{
std::ifstream ifs;
@ -462,7 +516,7 @@ bool gnss_sdr_supl_client::load_utc_xml(const std::string file_name)
{
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_utc_map", this->gps_utc);
xml >> boost::serialization::make_nvp("GNSS-SDR_utc_model", this->gps_utc);
LOG(INFO) << "Loaded UTC model data";
}
catch (std::exception& e)
@ -474,6 +528,33 @@ bool gnss_sdr_supl_client::load_utc_xml(const std::string file_name)
}
bool gnss_sdr_supl_client::save_utc_xml(const std::string file_name, Gps_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_utc_model", utc);
LOG(INFO) << "Saved GPS UTC Model data";
}
catch (std::exception& e)
{
LOG(WARNING) << e.what();
return false;
}
}
else
{
LOG(WARNING) << "Failed to save GPS 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;
@ -481,7 +562,7 @@ bool gnss_sdr_supl_client::load_gal_utc_xml(const std::string file_name)
{
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_gal_utc_map", this->gal_utc);
xml >> boost::serialization::make_nvp("GNSS-SDR_gal_utc_model", this->gal_utc);
LOG(INFO) << "Loaded Galileo UTC model data";
}
catch (std::exception& e)
@ -493,17 +574,17 @@ bool gnss_sdr_supl_client::load_gal_utc_xml(const std::string file_name)
}
bool gnss_sdr_supl_client::save_utc_map_xml(const std::string file_name, std::map<int, Gps_Utc_Model> utc_map)
bool gnss_sdr_supl_client::save_gal_utc_xml(const std::string file_name, Galileo_Utc_Model& utc)
{
if (utc_map.empty() == false)
if (utc.flag_utc_model)
{
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_utc_map", utc_map);
LOG(INFO) << "Saved UTC Model data";
xml << boost::serialization::make_nvp("GNSS-SDR_gal_utc_model", utc);
LOG(INFO) << "Saved Galileo UTC Model data";
}
catch (std::exception& e)
{
@ -513,7 +594,7 @@ bool gnss_sdr_supl_client::save_utc_map_xml(const std::string file_name, std::ma
}
else
{
LOG(WARNING) << "Failed to save UTC model, map is empty";
LOG(WARNING) << "Failed to save Galileo UTC model, no valid data";
return false;
}
return true;
@ -527,7 +608,7 @@ bool gnss_sdr_supl_client::load_iono_xml(const std::string file_name)
{
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_iono_map", this->gps_iono);
xml >> boost::serialization::make_nvp("GNSS-SDR_iono_model", this->gps_iono);
LOG(INFO) << "Loaded IONO model data";
}
catch (std::exception& e)
@ -539,6 +620,33 @@ bool gnss_sdr_supl_client::load_iono_xml(const std::string file_name)
}
bool gnss_sdr_supl_client::save_iono_xml(const std::string file_name, Gps_Iono& iono)
{
if (iono.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_iono_model", iono);
LOG(INFO) << "Saved IONO Model data";
}
catch (std::exception& e)
{
LOG(WARNING) << e.what();
return false;
}
}
else
{
LOG(WARNING) << "Failed to save IONO model, map is empty";
return false;
}
return true;
}
bool gnss_sdr_supl_client::load_gal_iono_xml(const std::string file_name)
{
std::ifstream ifs;
@ -546,7 +654,7 @@ bool gnss_sdr_supl_client::load_gal_iono_xml(const std::string file_name)
{
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_iono_gal_map", this->gal_iono);
xml >> boost::serialization::make_nvp("GNSS-SDR_gal_iono_model", this->gal_iono);
LOG(INFO) << "Loaded Galileo IONO model data";
}
catch (std::exception& e)
@ -558,17 +666,17 @@ bool gnss_sdr_supl_client::load_gal_iono_xml(const std::string file_name)
}
bool gnss_sdr_supl_client::save_iono_map_xml(const std::string file_name, std::map<int, Gps_Iono> iono_map)
bool gnss_sdr_supl_client::save_gal_iono_xml(const std::string file_name, Galileo_Iono& iono)
{
if (iono_map.empty() == false)
if (iono.ai0_5 != 0.0)
{
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_iono_map", iono_map);
LOG(INFO) << "Saved IONO Model data";
xml << boost::serialization::make_nvp("GNSS-SDR_gal_iono_model", iono);
LOG(INFO) << "Saved Galileo IONO Model data";
}
catch (std::exception& e)
{
@ -578,7 +686,7 @@ bool gnss_sdr_supl_client::save_iono_map_xml(const std::string file_name, std::m
}
else
{
LOG(WARNING) << "Failed to save IONO model, map is empty";
LOG(WARNING) << "Failed to save Galileo IONO model, map is empty";
return false;
}
return true;

View File

@ -119,54 +119,75 @@ public:
*/
bool load_ephemeris_xml(const std::string file_name);
/*!
* \brief Save ephemeris map to XML file.
*/
bool save_ephemeris_map_xml(const std::string file_name,
std::map<int, Gps_Ephemeris> eph_map);
/*!
* \brief Read GPS CNAV ephemeris map from XML file
*/
bool load_cnav_ephemeris_xml(const std::string file_name);
/*!
* \brief Save GPS CNAV ephemeris map to XML file.
*/
bool save_cnav_ephemeris_map_xml(const std::string file_name,
std::map<int, Gps_CNAV_Ephemeris> eph_map);
/*!
* \brief Read Galileo ephemeris map from XML file
*/
bool load_gal_ephemeris_xml(const std::string file_name);
/*!
* \brief Save ephemeris map to XML file.
* \brief Save Galileo ephemeris map to XML file.
*/
bool save_ephemeris_map_xml(const std::string file_name,
std::map<int, Gps_Ephemeris> eph_map);
bool save_gal_ephemeris_map_xml(const std::string file_name,
std::map<int, Galileo_Ephemeris> eph_map);
/*!
* \brief Read GPS utc model from XML file
*/
bool load_utc_xml(const std::string file_name);
/*!
* \brief Save UTC model map to XML file
* To be called by ControlThread::gps_utc_model_data_write_to_XML()
*/
bool save_utc_xml(const std::string file_name, Gps_Utc_Model& utc);
/*!
* \brief Read Galileo utc model from XML file
*/
bool load_gal_utc_xml(const std::string file_name);
/*!
* \brief Save utc model map to XML file
* To be called by ControlThread::gps_utc_model_data_write_to_XML()
* \brief Save Galileo UTC model map to XML file
* To be called by ControlThread::gal_utc_model_data_write_to_XML()
*/
bool save_utc_map_xml(const std::string file_name,
std::map<int, Gps_Utc_Model> utc_map);
bool save_gal_utc_xml(const std::string file_name, Galileo_Utc_Model& utc);
/*!
* \brief Read iono from XML file
*/
bool load_iono_xml(const std::string file_name);
/*!
* \brief Save iono map to XML file
*/
bool save_iono_xml(const std::string file_name, Gps_Iono& iono);
/*!
* \brief Read Galileo iono from XML file
*/
bool load_gal_iono_xml(const std::string file_name);
/*!
* \brief Save iono map to XML file
* \brief Save Galileo iono map to XML file
*/
bool save_iono_map_xml(const std::string file_name,
std::map<int, Gps_Iono> iono_map);
bool save_gal_iono_xml(const std::string file_name, Galileo_Iono& iono);
/*!
* \brief Read ref time from XML file

View File

@ -80,6 +80,7 @@ public:
archive& make_nvp("WN_LSF_6", WN_LSF_6);
archive& make_nvp("DN_6", DN_6);
archive& make_nvp("Delta_tLSF_6", Delta_tLSF_6);
archive& make_nvp("flag_utc_model", flag_utc_model);
}
};

View File

@ -132,6 +132,7 @@ int main(int argc, char** argv)
gal_utc_model.WN_LSF_6 = hdr.leapWeek;
gal_utc_model.DN_6 = hdr.leapDay;
gal_utc_model.Delta_tLSF_6 = hdr.leapDelta;
gal_utc_model.flag_utc_model = (hdr.mapTimeCorr["GAUT"].A0 == 0.0);
gal_iono.ai0_5 = hdr.mapIonoCorr["GAL"].param[0];
gal_iono.ai1_5 = hdr.mapIonoCorr["GAL"].param[1];
gal_iono.ai2_5 = hdr.mapIonoCorr["GAL"].param[2];
@ -242,7 +243,7 @@ int main(int argc, char** argv)
std::ofstream ofs;
if (xml_filename.empty())
{
xml_filename = "eph_GPS_L1CA.xml";
xml_filename = "gps_ephemeris.xml";
}
try
{
@ -261,12 +262,12 @@ int main(int argc, char** argv)
if (j != 0)
{
std::ofstream ofs2;
xml_filename = "eph_Galileo_E1.xml";
xml_filename = "gal_ephemeris.xml";
try
{
ofs2.open(xml_filename.c_str(), std::ofstream::trunc | std::ofstream::out);
boost::archive::xml_oarchive xml(ofs2);
xml << boost::serialization::make_nvp("GNSS-SDR_ephemeris_map", eph_gal_map);
xml << boost::serialization::make_nvp("GNSS-SDR_gal_ephemeris_map", eph_gal_map);
}
catch (std::exception& e)
{
@ -281,12 +282,12 @@ int main(int argc, char** argv)
if (gps_utc_model.valid)
{
std::ofstream ofs3;
xml_filename = "gps_utc.xml";
xml_filename = "gps_utc_model.xml";
try
{
ofs3.open(xml_filename.c_str(), std::ofstream::trunc | std::ofstream::out);
boost::archive::xml_oarchive xml(ofs3);
xml << boost::serialization::make_nvp("GNSS-SDR_gps_utc", gps_utc_model);
xml << boost::serialization::make_nvp("GNSS-SDR_utc_model", gps_utc_model);
}
catch (std::exception& e)
{
@ -306,7 +307,7 @@ int main(int argc, char** argv)
{
ofs4.open(xml_filename.c_str(), std::ofstream::trunc | std::ofstream::out);
boost::archive::xml_oarchive xml(ofs4);
xml << boost::serialization::make_nvp("GNSS-SDR_gps_iono", gps_iono);
xml << boost::serialization::make_nvp("GNSS-SDR_iono_model", gps_iono);
}
catch (std::exception& e)
{
@ -320,12 +321,12 @@ int main(int argc, char** argv)
if (gal_utc_model.A0_6 != 0)
{
std::ofstream ofs5;
xml_filename = "gal_utc.xml";
xml_filename = "gal_utc_model.xml";
try
{
ofs5.open(xml_filename.c_str(), std::ofstream::trunc | std::ofstream::out);
boost::archive::xml_oarchive xml(ofs5);
xml << boost::serialization::make_nvp("GNSS-SDR_gal_utc", gal_utc_model);
xml << boost::serialization::make_nvp("GNSS-SDR_gal_utc_model", gal_utc_model);
}
catch (std::exception& e)
{
@ -343,7 +344,7 @@ int main(int argc, char** argv)
{
ofs7.open(xml_filename.c_str(), std::ofstream::trunc | std::ofstream::out);
boost::archive::xml_oarchive xml(ofs7);
xml << boost::serialization::make_nvp("GNSS-SDR_gal_iono", gal_iono);
xml << boost::serialization::make_nvp("GNSS-SDR_gal_iono_model", gal_iono);
}
catch (std::exception& e)
{