1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-14 20:20:35 +00:00
This commit is contained in:
Carles Fernandez 2018-10-18 09:30:50 +02:00
commit 4bb13684aa
4 changed files with 96 additions and 5 deletions

View File

@ -388,6 +388,46 @@ 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)

View File

@ -46,6 +46,8 @@ extern "C"
#include "gps_acq_assist.h"
#include "gps_ref_time.h"
#include "gps_ref_location.h"
#include "gps_cnav_ephemeris.h"
#include "galileo_ephemeris.h"
#include <boost/archive/xml_oarchive.hpp>
#include <boost/archive/xml_iarchive.hpp>
#include <boost/serialization/map.hpp>
@ -77,6 +79,8 @@ public:
int request;
// ephemeris map
std::map<int, Gps_Ephemeris> gps_ephemeris_map;
std::map<int, Galileo_Ephemeris> gal_ephemeris_map;
std::map<int, Gps_CNAV_Ephemeris> gps_cnav_ephemeris_map;
// almanac map
std::map<int, Gps_Almanac> gps_almanac_map;
@ -107,10 +111,20 @@ public:
void read_supl_data();
/*!
* \brief Read ephemeris map from XML file
* \brief Read GPS NAV ephemeris map from XML file
*/
bool load_ephemeris_xml(const std::string file_name);
/*!
* \brief Read GPS CNAV ephemeris map from XML file
*/
bool load_cnav_ephemeris_xml(const std::string file_name);
/*!
* \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.
*/

View File

@ -203,8 +203,15 @@ bool ControlThread::read_assistance_from_XML()
std::string iono_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_iono_xml", iono_default_xml_filename);
std::string ref_time_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_ref_time_xml", ref_time_default_xml_filename);
std::string ref_location_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_ref_location_xml", ref_location_default_xml_filename);
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::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::endl;
std::cout << "SUPL: Try read GPS ephemeris from XML file " << eph_xml_filename << std::endl;
if (supl_client_ephemeris_.load_ephemeris_xml(eph_xml_filename) == true)
{
std::map<int, Gps_Ephemeris>::const_iterator gps_eph_iter;
@ -212,13 +219,41 @@ bool ControlThread::read_assistance_from_XML()
gps_eph_iter != supl_client_ephemeris_.gps_ephemeris_map.cend();
gps_eph_iter++)
{
std::cout << "SUPL: Read XML Ephemeris for GPS SV " << gps_eph_iter->first << std::endl;
std::cout << "From XML file: Read NAV ephemeris for satellite " << Gnss_Satellite("GPS", gps_eph_iter->first) << std::endl;
std::shared_ptr<Gps_Ephemeris> tmp_obj = std::make_shared<Gps_Ephemeris>(gps_eph_iter->second);
flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj));
}
ret = true;
}
else
if (supl_client_ephemeris_.load_gal_ephemeris_xml(eph_gal_xml_filename) == true)
{
std::map<int, Galileo_Ephemeris>::const_iterator gal_eph_iter;
for (gal_eph_iter = supl_client_ephemeris_.gal_ephemeris_map.cbegin();
gal_eph_iter != supl_client_ephemeris_.gal_ephemeris_map.cend();
gal_eph_iter++)
{
std::cout << "From XML file: Read ephemeris for satellite " << Gnss_Satellite("Galileo", gal_eph_iter->first) << std::endl;
std::shared_ptr<Galileo_Ephemeris> tmp_obj = std::make_shared<Galileo_Ephemeris>(gal_eph_iter->second);
flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj));
}
ret = true;
}
if (supl_client_ephemeris_.load_cnav_ephemeris_xml(eph_cnav_xml_filename) == true)
{
std::map<int, Gps_CNAV_Ephemeris>::const_iterator gps_cnav_eph_iter;
for (gps_cnav_eph_iter = supl_client_ephemeris_.gps_cnav_ephemeris_map.cbegin();
gps_cnav_eph_iter != supl_client_ephemeris_.gps_cnav_ephemeris_map.cend();
gps_cnav_eph_iter++)
{
std::cout << "From XML file: Read CNAV ephemeris for satellite " << Gnss_Satellite("GPS", gps_cnav_eph_iter->first) << std::endl;
std::shared_ptr<Gps_CNAV_Ephemeris> tmp_obj = std::make_shared<Gps_CNAV_Ephemeris>(gps_cnav_eph_iter->second);
flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj));
}
ret = true;
}
if (ret == false)
{
std::cout << "ERROR: SUPL client error reading XML" << std::endl;
std::cout << "Disabling SUPL assistance..." << std::endl;
@ -324,7 +359,7 @@ void ControlThread::assist_GNSS()
// read assistance from file
if (read_assistance_from_XML())
{
std::cout << "GPS assistance data loaded from local XML file." << std::endl;
std::cout << "GNSS assistance data loaded from local XML file(s)." << std::endl;
}
}
else

View File

@ -167,6 +167,8 @@ private:
const std::string iono_default_xml_filename = "./gps_iono.xml";
const std::string ref_time_default_xml_filename = "./gps_ref_time.xml";
const std::string ref_location_default_xml_filename = "./gps_ref_location.xml";
const std::string eph_gal_default_xml_filename = "./gal_ephemeris.xml";
const std::string eph_cnav_default_xml_filename = "./gps_cnav_ephemeris.xml";
};
#endif /*GNSS_SDR_CONTROL_THREAD_H_*/