mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-01-14 19:25:47 +00:00
Changing raw pointers by smart pointers
This commit is contained in:
parent
4dc8b055f7
commit
14970bf2c3
@ -73,17 +73,17 @@ galileo_e1_pvt_cc::galileo_e1_pvt_cc(unsigned int nchannels, boost::shared_ptr<g
|
||||
std::string kml_dump_filename;
|
||||
kml_dump_filename = d_dump_filename;
|
||||
kml_dump_filename.append(".kml");
|
||||
d_kml_dump.set_headers(kml_dump_filename);
|
||||
d_kml_dump = std::make_shared<Kml_Printer>();
|
||||
d_kml_dump->set_headers(kml_dump_filename);
|
||||
|
||||
//initialize nmea_printer
|
||||
d_nmea_printer = new Nmea_Printer(nmea_dump_filename, flag_nmea_tty_port, nmea_dump_devname);
|
||||
|
||||
d_nmea_printer = std::make_shared<Nmea_Printer>(nmea_dump_filename, flag_nmea_tty_port, nmea_dump_devname);
|
||||
d_dump_filename.append("_raw.dat");
|
||||
dump_ls_pvt_filename.append("_ls_pvt.dat");
|
||||
d_averaging_depth = averaging_depth;
|
||||
d_flag_averaging = flag_averaging;
|
||||
|
||||
d_ls_pvt = new galileo_e1_ls_pvt(nchannels, dump_ls_pvt_filename, d_dump);
|
||||
d_ls_pvt = std::make_shared<galileo_e1_ls_pvt>(nchannels, dump_ls_pvt_filename, d_dump);
|
||||
d_ls_pvt->set_averaging_depth(d_averaging_depth);
|
||||
|
||||
d_sample_counter = 0;
|
||||
@ -91,7 +91,7 @@ galileo_e1_pvt_cc::galileo_e1_pvt_cc(unsigned int nchannels, boost::shared_ptr<g
|
||||
d_rx_time = 0.0;
|
||||
|
||||
b_rinex_header_writen = false;
|
||||
rp = new Rinex_Printer();
|
||||
rp = std::make_shared<Rinex_Printer>();
|
||||
|
||||
// ############# ENABLE DATA FILE LOG #################
|
||||
if (d_dump == true)
|
||||
@ -115,12 +115,7 @@ galileo_e1_pvt_cc::galileo_e1_pvt_cc(unsigned int nchannels, boost::shared_ptr<g
|
||||
|
||||
|
||||
galileo_e1_pvt_cc::~galileo_e1_pvt_cc()
|
||||
{
|
||||
d_kml_dump.close_file();
|
||||
delete d_ls_pvt;
|
||||
delete rp;
|
||||
delete d_nmea_printer;
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
|
||||
@ -180,21 +175,21 @@ int galileo_e1_pvt_cc::general_work (int noutput_items, gr_vector_int &ninput_it
|
||||
|
||||
if (pvt_result == true)
|
||||
{
|
||||
d_kml_dump.print_position_galileo(d_ls_pvt, d_flag_averaging);
|
||||
d_kml_dump->print_position_galileo(d_ls_pvt, d_flag_averaging);
|
||||
//ToDo: Implement Galileo RINEX and Galileo NMEA outputs
|
||||
// d_nmea_printer->Print_Nmea_Line(d_ls_pvt, d_flag_averaging);
|
||||
//
|
||||
// if (!b_rinex_header_writen) // & we have utc data in nav message!
|
||||
// {
|
||||
// std::map<int,Gps_Ephemeris>::iterator gps_ephemeris_iter;
|
||||
// gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.begin();
|
||||
// if (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.end())
|
||||
// {
|
||||
// rp->rinex_obs_header(rp->obsFile, gps_ephemeris_iter->second,d_rx_time);
|
||||
// rp->rinex_nav_header(rp->navFile,d_ls_pvt->gps_iono, d_ls_pvt->gps_utc_model);
|
||||
// b_rinex_header_writen = true; // do not write header anymore
|
||||
// }
|
||||
// }
|
||||
// if (!b_rinex_header_writen) // & we have utc data in nav message!
|
||||
// {
|
||||
// std::map<int,Galileo_Ephemeris>::iterator galileo_ephemeris_iter;
|
||||
// galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.begin();
|
||||
// if (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.end())
|
||||
// {
|
||||
// rp->rinex_obs_header(rp->obsFile, galileo_ephemeris_iter->second, d_rx_time);
|
||||
// rp->rinex_nav_header(rp->navFile, d_ls_pvt->galielo_iono, d_ls_pvt->galileo_utc_model);
|
||||
// b_rinex_header_writen = true; // do not write header anymore
|
||||
// }
|
||||
// }
|
||||
// if(b_rinex_header_writen) // Put here another condition to separate annotations (e.g 30 s)
|
||||
// {
|
||||
// // Limit the RINEX navigation output rate to 1/6 seg
|
||||
|
@ -96,7 +96,7 @@ private:
|
||||
boost::shared_ptr<gr::msg_queue> d_queue;
|
||||
bool d_dump;
|
||||
bool b_rinex_header_writen;
|
||||
Rinex_Printer *rp;
|
||||
std::shared_ptr<Rinex_Printer> rp;
|
||||
unsigned int d_nchannels;
|
||||
std::string d_dump_filename;
|
||||
std::ofstream d_dump_file;
|
||||
@ -106,10 +106,10 @@ private:
|
||||
int d_display_rate_ms;
|
||||
long unsigned int d_sample_counter;
|
||||
long unsigned int d_last_sample_nav_output;
|
||||
Kml_Printer d_kml_dump;
|
||||
Nmea_Printer *d_nmea_printer;
|
||||
std::shared_ptr<Kml_Printer> d_kml_dump;
|
||||
std::shared_ptr<Nmea_Printer> d_nmea_printer;
|
||||
double d_rx_time;
|
||||
galileo_e1_ls_pvt *d_ls_pvt;
|
||||
std::shared_ptr<galileo_e1_ls_pvt> d_ls_pvt;
|
||||
bool pseudoranges_pairCompare_min(std::pair<int,Gnss_Synchro> a, std::pair<int,Gnss_Synchro> b);
|
||||
|
||||
public:
|
||||
|
@ -87,17 +87,18 @@ gps_l1_ca_pvt_cc::gps_l1_ca_pvt_cc(unsigned int nchannels,
|
||||
std::string kml_dump_filename;
|
||||
kml_dump_filename = d_dump_filename;
|
||||
kml_dump_filename.append(".kml");
|
||||
d_kml_dump.set_headers(kml_dump_filename);
|
||||
d_kml_dump = std::make_shared<Kml_Printer>();
|
||||
d_kml_dump->set_headers(kml_dump_filename);
|
||||
|
||||
//initialize nmea_printer
|
||||
d_nmea_printer = new Nmea_Printer(nmea_dump_filename, flag_nmea_tty_port, nmea_dump_devname);
|
||||
d_nmea_printer = std::make_shared<Nmea_Printer>(nmea_dump_filename, flag_nmea_tty_port, nmea_dump_devname);
|
||||
|
||||
d_dump_filename.append("_raw.dat");
|
||||
dump_ls_pvt_filename.append("_ls_pvt.dat");
|
||||
d_averaging_depth = averaging_depth;
|
||||
d_flag_averaging = flag_averaging;
|
||||
|
||||
d_ls_pvt = new gps_l1_ca_ls_pvt(nchannels,dump_ls_pvt_filename,d_dump);
|
||||
d_ls_pvt = std::make_shared<gps_l1_ca_ls_pvt>((int)nchannels, dump_ls_pvt_filename, d_dump);
|
||||
d_ls_pvt->set_averaging_depth(d_averaging_depth);
|
||||
|
||||
d_sample_counter = 0;
|
||||
@ -106,7 +107,7 @@ gps_l1_ca_pvt_cc::gps_l1_ca_pvt_cc(unsigned int nchannels,
|
||||
|
||||
b_rinex_header_writen = false;
|
||||
b_rinex_sbs_header_writen = false;
|
||||
rp = new Rinex_Printer();
|
||||
rp = std::make_shared<Rinex_Printer>();
|
||||
|
||||
// ############# ENABLE DATA FILE LOG #################
|
||||
if (d_dump == true)
|
||||
@ -130,12 +131,7 @@ gps_l1_ca_pvt_cc::gps_l1_ca_pvt_cc(unsigned int nchannels,
|
||||
|
||||
|
||||
gps_l1_ca_pvt_cc::~gps_l1_ca_pvt_cc()
|
||||
{
|
||||
d_kml_dump.close_file();
|
||||
delete d_ls_pvt;
|
||||
delete rp;
|
||||
delete d_nmea_printer;
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
|
||||
@ -237,7 +233,7 @@ int gps_l1_ca_pvt_cc::general_work (int noutput_items, gr_vector_int &ninput_ite
|
||||
pvt_result = d_ls_pvt->get_PVT(gnss_pseudoranges_map, d_rx_time, d_flag_averaging);
|
||||
if (pvt_result == true)
|
||||
{
|
||||
d_kml_dump.print_position(d_ls_pvt, d_flag_averaging);
|
||||
d_kml_dump->print_position(d_ls_pvt, d_flag_averaging);
|
||||
d_nmea_printer->Print_Nmea_Line(d_ls_pvt, d_flag_averaging);
|
||||
|
||||
if (!b_rinex_header_writen) // & we have utc data in nav message!
|
||||
|
@ -96,7 +96,7 @@ private:
|
||||
bool d_dump;
|
||||
bool b_rinex_header_writen;
|
||||
bool b_rinex_sbs_header_writen;
|
||||
Rinex_Printer *rp;
|
||||
std::shared_ptr<Rinex_Printer> rp;
|
||||
unsigned int d_nchannels;
|
||||
std::string d_dump_filename;
|
||||
std::ofstream d_dump_file;
|
||||
@ -106,10 +106,10 @@ private:
|
||||
int d_display_rate_ms;
|
||||
long unsigned int d_sample_counter;
|
||||
long unsigned int d_last_sample_nav_output;
|
||||
Kml_Printer d_kml_dump;
|
||||
Nmea_Printer *d_nmea_printer;
|
||||
std::shared_ptr<Kml_Printer> d_kml_dump;
|
||||
std::shared_ptr<Nmea_Printer> d_nmea_printer;
|
||||
double d_rx_time;
|
||||
gps_l1_ca_ls_pvt *d_ls_pvt;
|
||||
std::shared_ptr<gps_l1_ca_ls_pvt> d_ls_pvt;
|
||||
|
||||
public:
|
||||
~gps_l1_ca_pvt_cc (); //!< Default destructor
|
||||
|
@ -82,22 +82,25 @@ bool Kml_Printer::set_headers(std::string filename)
|
||||
|
||||
|
||||
|
||||
bool Kml_Printer::print_position(gps_l1_ca_ls_pvt* position,bool print_average_values)
|
||||
bool Kml_Printer::print_position(const std::shared_ptr<gps_l1_ca_ls_pvt>& position, bool print_average_values)
|
||||
{
|
||||
double latitude;
|
||||
double longitude;
|
||||
double height;
|
||||
|
||||
std::shared_ptr<gps_l1_ca_ls_pvt> position_ = position;
|
||||
|
||||
if (print_average_values == false)
|
||||
{
|
||||
latitude = position->d_latitude_d;
|
||||
longitude = position->d_longitude_d;
|
||||
height = position->d_height_m;
|
||||
latitude = position_->d_latitude_d;
|
||||
longitude = position_->d_longitude_d;
|
||||
height = position_->d_height_m;
|
||||
}
|
||||
else
|
||||
{
|
||||
latitude = position->d_avg_latitude_d;
|
||||
longitude = position->d_avg_longitude_d;
|
||||
height = position->d_avg_height_m;
|
||||
latitude = position_->d_avg_latitude_d;
|
||||
longitude = position_->d_avg_longitude_d;
|
||||
height = position_->d_avg_height_m;
|
||||
}
|
||||
|
||||
if (kml_file.is_open())
|
||||
@ -113,22 +116,23 @@ bool Kml_Printer::print_position(gps_l1_ca_ls_pvt* position,bool print_average_v
|
||||
|
||||
//ToDo: make the class ls_pvt generic and heritate the particular gps/gal/glo ls_pvt in order to
|
||||
// reuse kml_printer functions
|
||||
bool Kml_Printer::print_position_galileo(galileo_e1_ls_pvt* position,bool print_average_values)
|
||||
bool Kml_Printer::print_position_galileo(const std::shared_ptr<galileo_e1_ls_pvt>& position, bool print_average_values)
|
||||
{
|
||||
double latitude;
|
||||
double longitude;
|
||||
double height;
|
||||
std::shared_ptr<galileo_e1_ls_pvt> position_ = position;
|
||||
if (print_average_values == false)
|
||||
{
|
||||
latitude = position->d_latitude_d;
|
||||
longitude = position->d_longitude_d;
|
||||
height = position->d_height_m;
|
||||
latitude = position_->d_latitude_d;
|
||||
longitude = position_->d_longitude_d;
|
||||
height = position_->d_height_m;
|
||||
}
|
||||
else
|
||||
{
|
||||
latitude = position->d_avg_latitude_d;
|
||||
longitude = position->d_avg_longitude_d;
|
||||
height = position->d_avg_height_m;
|
||||
latitude = position_->d_avg_latitude_d;
|
||||
longitude = position_->d_avg_longitude_d;
|
||||
height = position_->d_avg_height_m;
|
||||
}
|
||||
|
||||
if (kml_file.is_open())
|
||||
@ -167,5 +171,8 @@ Kml_Printer::Kml_Printer () {}
|
||||
|
||||
|
||||
|
||||
Kml_Printer::~Kml_Printer () {}
|
||||
Kml_Printer::~Kml_Printer ()
|
||||
{
|
||||
close_file();
|
||||
}
|
||||
|
||||
|
@ -51,8 +51,8 @@ private:
|
||||
std::ofstream kml_file;
|
||||
public:
|
||||
bool set_headers(std::string filename);
|
||||
bool print_position(gps_l1_ca_ls_pvt* position, bool print_average_values);
|
||||
bool print_position_galileo(galileo_e1_ls_pvt* position, bool print_average_values);
|
||||
bool print_position(const std::shared_ptr<gps_l1_ca_ls_pvt>& position, bool print_average_values);
|
||||
bool print_position_galileo(const std::shared_ptr<galileo_e1_ls_pvt>& position, bool print_average_values);
|
||||
bool close_file();
|
||||
Kml_Printer();
|
||||
~Kml_Printer();
|
||||
|
@ -132,7 +132,7 @@ void Nmea_Printer::close_serial ()
|
||||
}
|
||||
|
||||
|
||||
bool Nmea_Printer::Print_Nmea_Line(gps_l1_ca_ls_pvt* pvt_data, bool print_average_values)
|
||||
bool Nmea_Printer::Print_Nmea_Line(const std::shared_ptr<gps_l1_ca_ls_pvt>& pvt_data, bool print_average_values)
|
||||
{
|
||||
std::string GPRMC;
|
||||
std::string GPGGA;
|
||||
|
@ -60,7 +60,7 @@ public:
|
||||
/*!
|
||||
* \brief Print NMEA PVT and satellite info to the initialized device
|
||||
*/
|
||||
bool Print_Nmea_Line(gps_l1_ca_ls_pvt* position, bool print_average_values);
|
||||
bool Print_Nmea_Line(const std::shared_ptr<gps_l1_ca_ls_pvt>& position, bool print_average_values);
|
||||
|
||||
/*!
|
||||
* \brief Default destructor.
|
||||
@ -72,9 +72,9 @@ private:
|
||||
std::ofstream nmea_file_descriptor; // Output file stream for NMEA log file
|
||||
std::string nmea_devname;
|
||||
int nmea_dev_descriptor; // NMEA serial device descriptor (i.e. COM port)
|
||||
gps_l1_ca_ls_pvt* d_PVT_data;
|
||||
int init_serial (std::string serial_device); //serial port control
|
||||
void close_serial ();
|
||||
std::shared_ptr<gps_l1_ca_ls_pvt> d_PVT_data;
|
||||
int init_serial(std::string serial_device); //serial port control
|
||||
void close_serial();
|
||||
std::string get_GPGGA(); // fix data
|
||||
std::string get_GPGSV(); // satellite data
|
||||
std::string get_GPGSA(); // overall satellite reception data
|
||||
|
Loading…
Reference in New Issue
Block a user