From c0f81dd9e252051c4ad625a8af0265ce6c138f12 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 19 Jul 2020 09:39:32 +0200 Subject: [PATCH] Improve const correctness. Improve usage of typeid --- .../PVT/gnuradio_blocks/rtklib_pvt_gs.cc | 184 +-- .../PVT/gnuradio_blocks/rtklib_pvt_gs.h | 21 + src/algorithms/PVT/libs/geojson_printer.cc | 4 +- src/algorithms/PVT/libs/gpx_printer.cc | 34 +- src/algorithms/PVT/libs/kml_printer.cc | 186 +-- src/algorithms/PVT/libs/nmea_printer.cc | 46 +- src/algorithms/PVT/libs/rinex_printer.cc | 839 ++++++----- src/algorithms/PVT/libs/rtcm.cc | 1274 ++++++++--------- src/algorithms/PVT/libs/rtcm_printer.cc | 46 +- src/algorithms/PVT/libs/rtklib_solver.cc | 64 +- src/algorithms/PVT/libs/rtklib_solver.h | 4 +- .../gnuradio_blocks/pcps_acquisition.cc | 26 +- .../gnuradio_blocks/pcps_acquisition_fpga.cc | 6 +- .../gnuradio_blocks/hybrid_observables_gs.cc | 29 +- .../gnuradio_blocks/hybrid_observables_gs.h | 4 + .../beidou_b1i_telemetry_decoder_gs.cc | 11 +- .../beidou_b3i_telemetry_decoder_gs.cc | 8 +- .../galileo_telemetry_decoder_gs.cc | 14 +- .../glonass_l1_ca_telemetry_decoder_gs.cc | 10 +- .../glonass_l2_ca_telemetry_decoder_gs.cc | 10 +- .../gps_l1_ca_telemetry_decoder_gs.cc | 29 +- .../gps_l2c_telemetry_decoder_gs.cc | 8 +- .../gps_l5_telemetry_decoder_gs.cc | 8 +- .../sbas_l1_telemetry_decoder_gs.cc | 28 +- .../gnuradio_blocks/dll_pll_veml_tracking.cc | 34 +- .../gnuradio_blocks/dll_pll_veml_tracking.h | 10 +- .../dll_pll_veml_tracking_fpga.cc | 44 +- .../dll_pll_veml_tracking_fpga.h | 8 +- src/core/libs/channel_status_msg_receiver.cc | 17 +- src/core/receiver/control_thread.cc | 112 +- src/core/receiver/control_thread.h | 19 +- .../pvt/nmea_printer_test.cc | 2 +- .../pvt/rtklib_solver_test.cc | 2 +- 33 files changed, 1566 insertions(+), 1575 deletions(-) diff --git a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc index 4fc3a577f..4b04fcfc1 100644 --- a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc +++ b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc @@ -74,6 +74,7 @@ #include // for length_error #include // for IPC_CREAT #include // for msgctl +#include // for std::type_info, typeid #include // for pair #if HAS_GENERIC_LAMBDA @@ -471,26 +472,46 @@ rtklib_pvt_gs::rtklib_pvt_gs(uint32_t nchannels, { // setup two PVT solvers: internal solver for rx clock and user solver // user PVT solver - d_user_pvt_solver = std::make_shared(static_cast(nchannels), dump_ls_pvt_filename, d_dump, d_dump_mat, rtk); + d_user_pvt_solver = std::make_shared(rtk, static_cast(nchannels), dump_ls_pvt_filename, d_dump, d_dump_mat); d_user_pvt_solver->set_averaging_depth(1); d_user_pvt_solver->set_pre_2009_file(conf_.pre_2009_file); // internal PVT solver, mainly used to estimate the receiver clock rtk_t internal_rtk = rtk; internal_rtk.opt.mode = PMODE_SINGLE; // use single positioning mode in internal PVT solver - d_internal_pvt_solver = std::make_shared(static_cast(nchannels), dump_ls_pvt_filename, false, false, internal_rtk); + d_internal_pvt_solver = std::make_shared(internal_rtk, static_cast(nchannels), dump_ls_pvt_filename, false, false); d_internal_pvt_solver->set_averaging_depth(1); d_internal_pvt_solver->set_pre_2009_file(conf_.pre_2009_file); } else { // only one solver, customized by the user options - d_internal_pvt_solver = std::make_shared(static_cast(nchannels), dump_ls_pvt_filename, d_dump, d_dump_mat, rtk); + d_internal_pvt_solver = std::make_shared(rtk, static_cast(nchannels), dump_ls_pvt_filename, d_dump, d_dump_mat); d_internal_pvt_solver->set_averaging_depth(1); d_internal_pvt_solver->set_pre_2009_file(conf_.pre_2009_file); d_user_pvt_solver = d_internal_pvt_solver; } + d_gps_ephemeris_sptr_type_hash_code = typeid(std::shared_ptr).hash_code(); + d_gps_iono_sptr_type_hash_code = typeid(std::shared_ptr).hash_code(); + d_gps_utc_model_sptr_type_hash_code = typeid(std::shared_ptr).hash_code(); + d_gps_cnav_ephemeris_sptr_type_hash_code = typeid(std::shared_ptr).hash_code(); + d_gps_cnav_iono_sptr_type_hash_code = typeid(std::shared_ptr).hash_code(); + d_gps_cnav_utc_model_sptr_type_hash_code = typeid(std::shared_ptr).hash_code(); + d_gps_almanac_sptr_type_hash_code = typeid(std::shared_ptr).hash_code(); + d_galileo_ephemeris_sptr_type_hash_code = typeid(std::shared_ptr).hash_code(); + d_galileo_iono_sptr_type_hash_code = typeid(std::shared_ptr).hash_code(); + d_galileo_utc_model_sptr_type_hash_code = typeid(std::shared_ptr).hash_code(); + d_galileo_almanac_helper_sptr_type_hash_code = typeid(std::shared_ptr).hash_code(); + d_galileo_almanac_sptr_type_hash_code = typeid(std::shared_ptr).hash_code(); + d_glonass_gnav_ephemeris_sptr_type_hash_code = typeid(std::shared_ptr).hash_code(); + d_glonass_gnav_utc_model_sptr_type_hash_code = typeid(std::shared_ptr).hash_code(); + d_glonass_gnav_almanac_sptr_type_hash_code = typeid(std::shared_ptr).hash_code(); + d_beidou_dnav_ephemeris_sptr_type_hash_code = typeid(std::shared_ptr).hash_code(); + d_beidou_dnav_iono_sptr_type_hash_code = typeid(std::shared_ptr).hash_code(); + d_beidou_dnav_utc_model_sptr_type_hash_code = typeid(std::shared_ptr).hash_code(); + d_beidou_dnav_almanac_sptr_type_hash_code = typeid(std::shared_ptr).hash_code(); + d_start = std::chrono::system_clock::now(); } @@ -1050,12 +1071,12 @@ void rtklib_pvt_gs::msg_handler_telemetry(const pmt::pmt_t& msg) { try { - // ************* GPS telemetry ***************** - if (pmt::any_ref(msg).type() == typeid(std::shared_ptr)) + const size_t msg_type_hash_code = pmt::any_ref(msg).type().hash_code(); + // ************************* GPS telemetry ************************* + if (msg_type_hash_code == d_gps_ephemeris_sptr_type_hash_code) { // ### GPS EPHEMERIS ### - std::shared_ptr gps_eph; - gps_eph = boost::any_cast>(pmt::any_ref(msg)); + const std::shared_ptr gps_eph = boost::any_cast>(pmt::any_ref(msg)); DLOG(INFO) << "Ephemeris record has arrived from SAT ID " << gps_eph->i_satellite_PRN << " (Block " << gps_eph->satelliteBlock[gps_eph->i_satellite_PRN] << ")" @@ -1135,11 +1156,10 @@ void rtklib_pvt_gs::msg_handler_telemetry(const pmt::pmt_t& msg) d_user_pvt_solver->gps_ephemeris_map[gps_eph->i_satellite_PRN] = *gps_eph; } } - else if (pmt::any_ref(msg).type() == typeid(std::shared_ptr)) + else if (msg_type_hash_code == d_gps_iono_sptr_type_hash_code) { // ### GPS IONO ### - std::shared_ptr gps_iono; - gps_iono = boost::any_cast>(pmt::any_ref(msg)); + const std::shared_ptr gps_iono = boost::any_cast>(pmt::any_ref(msg)); d_internal_pvt_solver->gps_iono = *gps_iono; if (d_enable_rx_clock_correction == true) { @@ -1147,11 +1167,10 @@ void rtklib_pvt_gs::msg_handler_telemetry(const pmt::pmt_t& msg) } DLOG(INFO) << "New IONO record has arrived "; } - else if (pmt::any_ref(msg).type() == typeid(std::shared_ptr)) + else if (msg_type_hash_code == d_gps_utc_model_sptr_type_hash_code) { // ### GPS UTC MODEL ### - std::shared_ptr gps_utc_model; - gps_utc_model = boost::any_cast>(pmt::any_ref(msg)); + const std::shared_ptr gps_utc_model = boost::any_cast>(pmt::any_ref(msg)); d_internal_pvt_solver->gps_utc_model = *gps_utc_model; if (d_enable_rx_clock_correction == true) { @@ -1159,11 +1178,10 @@ void rtklib_pvt_gs::msg_handler_telemetry(const pmt::pmt_t& msg) } DLOG(INFO) << "New UTC record has arrived "; } - else if (pmt::any_ref(msg).type() == typeid(std::shared_ptr)) + else if (msg_type_hash_code == d_gps_cnav_ephemeris_sptr_type_hash_code) { // ### GPS CNAV message ### - std::shared_ptr gps_cnav_ephemeris; - gps_cnav_ephemeris = boost::any_cast>(pmt::any_ref(msg)); + const std::shared_ptr gps_cnav_ephemeris = boost::any_cast>(pmt::any_ref(msg)); // update/insert new ephemeris record to the global ephemeris map if (d_rinex_header_written) // The header is already written, we can now log the navigation message data { @@ -1212,11 +1230,10 @@ void rtklib_pvt_gs::msg_handler_telemetry(const pmt::pmt_t& msg) } DLOG(INFO) << "New GPS CNAV ephemeris record has arrived "; } - else if (pmt::any_ref(msg).type() == typeid(std::shared_ptr)) + else if (msg_type_hash_code == d_gps_cnav_iono_sptr_type_hash_code) { // ### GPS CNAV IONO ### - std::shared_ptr gps_cnav_iono; - gps_cnav_iono = boost::any_cast>(pmt::any_ref(msg)); + const std::shared_ptr gps_cnav_iono = boost::any_cast>(pmt::any_ref(msg)); d_internal_pvt_solver->gps_cnav_iono = *gps_cnav_iono; if (d_enable_rx_clock_correction == true) { @@ -1224,11 +1241,10 @@ void rtklib_pvt_gs::msg_handler_telemetry(const pmt::pmt_t& msg) } DLOG(INFO) << "New CNAV IONO record has arrived "; } - else if (pmt::any_ref(msg).type() == typeid(std::shared_ptr)) + else if (msg_type_hash_code == d_gps_cnav_utc_model_sptr_type_hash_code) { // ### GPS CNAV UTC MODEL ### - std::shared_ptr gps_cnav_utc_model; - gps_cnav_utc_model = boost::any_cast>(pmt::any_ref(msg)); + const std::shared_ptr gps_cnav_utc_model = boost::any_cast>(pmt::any_ref(msg)); d_internal_pvt_solver->gps_cnav_utc_model = *gps_cnav_utc_model; { d_user_pvt_solver->gps_cnav_utc_model = *gps_cnav_utc_model; @@ -1236,11 +1252,10 @@ void rtklib_pvt_gs::msg_handler_telemetry(const pmt::pmt_t& msg) DLOG(INFO) << "New CNAV UTC record has arrived "; } - else if (pmt::any_ref(msg).type() == typeid(std::shared_ptr)) + else if (msg_type_hash_code == d_gps_almanac_sptr_type_hash_code) { // ### GPS ALMANAC ### - std::shared_ptr gps_almanac; - gps_almanac = boost::any_cast>(pmt::any_ref(msg)); + const std::shared_ptr gps_almanac = boost::any_cast>(pmt::any_ref(msg)); d_internal_pvt_solver->gps_almanac_map[gps_almanac->i_satellite_PRN] = *gps_almanac; if (d_enable_rx_clock_correction == true) { @@ -1249,12 +1264,11 @@ void rtklib_pvt_gs::msg_handler_telemetry(const pmt::pmt_t& msg) DLOG(INFO) << "New GPS almanac record has arrived "; } - // **************** Galileo telemetry ******************** - else if (pmt::any_ref(msg).type() == typeid(std::shared_ptr)) + // *********************** Galileo telemetry *********************** + else if (msg_type_hash_code == d_galileo_ephemeris_sptr_type_hash_code) { // ### Galileo EPHEMERIS ### - std::shared_ptr galileo_eph; - galileo_eph = boost::any_cast>(pmt::any_ref(msg)); + const std::shared_ptr galileo_eph = boost::any_cast>(pmt::any_ref(msg)); // insert new ephemeris record DLOG(INFO) << "Galileo New Ephemeris record inserted in global map with TOW =" << galileo_eph->TOW_5 << ", GALILEO Week Number =" << galileo_eph->WN_5 @@ -1320,11 +1334,10 @@ void rtklib_pvt_gs::msg_handler_telemetry(const pmt::pmt_t& msg) d_user_pvt_solver->galileo_ephemeris_map[galileo_eph->i_satellite_PRN] = *galileo_eph; } } - else if (pmt::any_ref(msg).type() == typeid(std::shared_ptr)) + else if (msg_type_hash_code == d_galileo_iono_sptr_type_hash_code) { // ### Galileo IONO ### - std::shared_ptr galileo_iono; - galileo_iono = boost::any_cast>(pmt::any_ref(msg)); + const std::shared_ptr galileo_iono = boost::any_cast>(pmt::any_ref(msg)); d_internal_pvt_solver->galileo_iono = *galileo_iono; if (d_enable_rx_clock_correction == true) { @@ -1332,11 +1345,10 @@ void rtklib_pvt_gs::msg_handler_telemetry(const pmt::pmt_t& msg) } DLOG(INFO) << "New IONO record has arrived "; } - else if (pmt::any_ref(msg).type() == typeid(std::shared_ptr)) + else if (msg_type_hash_code == d_galileo_utc_model_sptr_type_hash_code) { // ### Galileo UTC MODEL ### - std::shared_ptr galileo_utc_model; - galileo_utc_model = boost::any_cast>(pmt::any_ref(msg)); + const std::shared_ptr galileo_utc_model = boost::any_cast>(pmt::any_ref(msg)); d_internal_pvt_solver->galileo_utc_model = *galileo_utc_model; if (d_enable_rx_clock_correction == true) { @@ -1344,12 +1356,10 @@ void rtklib_pvt_gs::msg_handler_telemetry(const pmt::pmt_t& msg) } DLOG(INFO) << "New UTC record has arrived "; } - else if (pmt::any_ref(msg).type() == typeid(std::shared_ptr)) + else if (msg_type_hash_code == d_galileo_almanac_helper_sptr_type_hash_code) { // ### Galileo Almanac ### - std::shared_ptr galileo_almanac_helper; - galileo_almanac_helper = boost::any_cast>(pmt::any_ref(msg)); - + const std::shared_ptr galileo_almanac_helper = boost::any_cast>(pmt::any_ref(msg)); Galileo_Almanac sv1 = galileo_almanac_helper->get_almanac(1); Galileo_Almanac sv2 = galileo_almanac_helper->get_almanac(2); Galileo_Almanac sv3 = galileo_almanac_helper->get_almanac(3); @@ -1380,11 +1390,10 @@ void rtklib_pvt_gs::msg_handler_telemetry(const pmt::pmt_t& msg) } DLOG(INFO) << "New Galileo Almanac data have arrived "; } - else if (pmt::any_ref(msg).type() == typeid(std::shared_ptr)) + else if (msg_type_hash_code == d_galileo_almanac_sptr_type_hash_code) { // ### Galileo Almanac ### - std::shared_ptr galileo_alm; - galileo_alm = boost::any_cast>(pmt::any_ref(msg)); + const std::shared_ptr galileo_alm = boost::any_cast>(pmt::any_ref(msg)); // update/insert new almanac record to the global almanac map d_internal_pvt_solver->galileo_almanac_map[galileo_alm->i_satellite_PRN] = *galileo_alm; if (d_enable_rx_clock_correction == true) @@ -1393,12 +1402,11 @@ void rtklib_pvt_gs::msg_handler_telemetry(const pmt::pmt_t& msg) } } - // **************** GLONASS GNAV Telemetry ************************** - else if (pmt::any_ref(msg).type() == typeid(std::shared_ptr)) + // **************** GLONASS GNAV Telemetry ************************* + else if (msg_type_hash_code == d_glonass_gnav_ephemeris_sptr_type_hash_code) { // ### GLONASS GNAV EPHEMERIS ### - std::shared_ptr glonass_gnav_eph; - glonass_gnav_eph = boost::any_cast>(pmt::any_ref(msg)); + const std::shared_ptr glonass_gnav_eph = boost::any_cast>(pmt::any_ref(msg)); // TODO Add GLONASS with gps week number and tow, // insert new ephemeris record DLOG(INFO) << "GLONASS GNAV New Ephemeris record inserted in global map with TOW =" << glonass_gnav_eph->d_TOW @@ -1478,11 +1486,10 @@ void rtklib_pvt_gs::msg_handler_telemetry(const pmt::pmt_t& msg) d_user_pvt_solver->glonass_gnav_ephemeris_map[glonass_gnav_eph->i_satellite_PRN] = *glonass_gnav_eph; } } - else if (pmt::any_ref(msg).type() == typeid(std::shared_ptr)) + else if (msg_type_hash_code == d_glonass_gnav_utc_model_sptr_type_hash_code) { // ### GLONASS GNAV UTC MODEL ### - std::shared_ptr glonass_gnav_utc_model; - glonass_gnav_utc_model = boost::any_cast>(pmt::any_ref(msg)); + const std::shared_ptr glonass_gnav_utc_model = boost::any_cast>(pmt::any_ref(msg)); d_internal_pvt_solver->glonass_gnav_utc_model = *glonass_gnav_utc_model; if (d_enable_rx_clock_correction == true) { @@ -1490,11 +1497,10 @@ void rtklib_pvt_gs::msg_handler_telemetry(const pmt::pmt_t& msg) } DLOG(INFO) << "New GLONASS GNAV UTC record has arrived "; } - else if (pmt::any_ref(msg).type() == typeid(std::shared_ptr)) + else if (msg_type_hash_code == d_glonass_gnav_almanac_sptr_type_hash_code) { // ### GLONASS GNAV Almanac ### - std::shared_ptr glonass_gnav_almanac; - glonass_gnav_almanac = boost::any_cast>(pmt::any_ref(msg)); + const std::shared_ptr glonass_gnav_almanac = boost::any_cast>(pmt::any_ref(msg)); d_internal_pvt_solver->glonass_gnav_almanac = *glonass_gnav_almanac; if (d_enable_rx_clock_correction == true) { @@ -1504,12 +1510,11 @@ void rtklib_pvt_gs::msg_handler_telemetry(const pmt::pmt_t& msg) << ", GLONASS GNAV Slot Number =" << glonass_gnav_almanac->d_n_A; } - // ************* BeiDou telemetry ***************** - else if (pmt::any_ref(msg).type() == typeid(std::shared_ptr)) + // *********************** BeiDou telemetry ************************ + else if (msg_type_hash_code == d_beidou_dnav_ephemeris_sptr_type_hash_code) { // ### Beidou EPHEMERIS ### - std::shared_ptr bds_dnav_eph; - bds_dnav_eph = boost::any_cast>(pmt::any_ref(msg)); + const std::shared_ptr bds_dnav_eph = boost::any_cast>(pmt::any_ref(msg)); DLOG(INFO) << "Ephemeris record has arrived from SAT ID " << bds_dnav_eph->i_satellite_PRN << " (Block " << bds_dnav_eph->satelliteBlock[bds_dnav_eph->i_satellite_PRN] << ")" @@ -1552,11 +1557,10 @@ void rtklib_pvt_gs::msg_handler_telemetry(const pmt::pmt_t& msg) d_user_pvt_solver->beidou_dnav_ephemeris_map[bds_dnav_eph->i_satellite_PRN] = *bds_dnav_eph; } } - else if (pmt::any_ref(msg).type() == typeid(std::shared_ptr)) + else if (msg_type_hash_code == d_beidou_dnav_iono_sptr_type_hash_code) { // ### BeiDou IONO ### - std::shared_ptr bds_dnav_iono; - bds_dnav_iono = boost::any_cast>(pmt::any_ref(msg)); + const std::shared_ptr bds_dnav_iono = boost::any_cast>(pmt::any_ref(msg)); d_internal_pvt_solver->beidou_dnav_iono = *bds_dnav_iono; if (d_enable_rx_clock_correction == true) { @@ -1564,11 +1568,10 @@ void rtklib_pvt_gs::msg_handler_telemetry(const pmt::pmt_t& msg) } DLOG(INFO) << "New BeiDou DNAV IONO record has arrived "; } - else if (pmt::any_ref(msg).type() == typeid(std::shared_ptr)) + else if (msg_type_hash_code == d_beidou_dnav_utc_model_sptr_type_hash_code) { // ### BeiDou UTC MODEL ### - std::shared_ptr bds_dnav_utc_model; - bds_dnav_utc_model = boost::any_cast>(pmt::any_ref(msg)); + const std::shared_ptr bds_dnav_utc_model = boost::any_cast>(pmt::any_ref(msg)); d_internal_pvt_solver->beidou_dnav_utc_model = *bds_dnav_utc_model; if (d_enable_rx_clock_correction == true) { @@ -1576,11 +1579,10 @@ void rtklib_pvt_gs::msg_handler_telemetry(const pmt::pmt_t& msg) } DLOG(INFO) << "New BeiDou DNAV UTC record has arrived "; } - else if (pmt::any_ref(msg).type() == typeid(std::shared_ptr)) + else if (msg_type_hash_code == d_beidou_dnav_almanac_sptr_type_hash_code) { // ### BeiDou ALMANAC ### - std::shared_ptr bds_dnav_almanac; - bds_dnav_almanac = boost::any_cast>(pmt::any_ref(msg)); + const std::shared_ptr bds_dnav_almanac = boost::any_cast>(pmt::any_ref(msg)); d_internal_pvt_solver->beidou_dnav_almanac_map[bds_dnav_almanac->i_satellite_PRN] = *bds_dnav_almanac; if (d_enable_rx_clock_correction == true) { @@ -1917,7 +1919,7 @@ void rtklib_pvt_gs::initialize_and_apply_carrier_phase_offset() default: break; } - double wrap_carrier_phase_rad = fmod(observables_iter->second.Carrier_phase_rads, TWO_PI); + const double wrap_carrier_phase_rad = fmod(observables_iter->second.Carrier_phase_rads, TWO_PI); d_initial_carrier_phase_offset_estimation_rads.at(observables_iter->second.Channel_ID) = TWO_PI * round(observables_iter->second.Pseudorange_m / wavelength_m) - observables_iter->second.Carrier_phase_rads + wrap_carrier_phase_rad; d_channel_initialized.at(observables_iter->second.Channel_ID) = true; DLOG(INFO) << "initialized carrier phase at channel " << observables_iter->second.Channel_ID; @@ -1948,17 +1950,17 @@ int rtklib_pvt_gs::work(int noutput_items, gr_vector_const_void_star& input_item { if (in[i][epoch].Flag_valid_pseudorange) { - auto tmp_eph_iter_gps = d_internal_pvt_solver->gps_ephemeris_map.find(in[i][epoch].PRN); - auto tmp_eph_iter_gal = d_internal_pvt_solver->galileo_ephemeris_map.find(in[i][epoch].PRN); - auto tmp_eph_iter_cnav = d_internal_pvt_solver->gps_cnav_ephemeris_map.find(in[i][epoch].PRN); - auto tmp_eph_iter_glo_gnav = d_internal_pvt_solver->glonass_gnav_ephemeris_map.find(in[i][epoch].PRN); - auto tmp_eph_iter_bds_dnav = d_internal_pvt_solver->beidou_dnav_ephemeris_map.find(in[i][epoch].PRN); + const auto tmp_eph_iter_gps = d_internal_pvt_solver->gps_ephemeris_map.find(in[i][epoch].PRN); + const auto tmp_eph_iter_gal = d_internal_pvt_solver->galileo_ephemeris_map.find(in[i][epoch].PRN); + const auto tmp_eph_iter_cnav = d_internal_pvt_solver->gps_cnav_ephemeris_map.find(in[i][epoch].PRN); + const auto tmp_eph_iter_glo_gnav = d_internal_pvt_solver->glonass_gnav_ephemeris_map.find(in[i][epoch].PRN); + const auto tmp_eph_iter_bds_dnav = d_internal_pvt_solver->beidou_dnav_ephemeris_map.find(in[i][epoch].PRN); bool store_valid_observable = false; if (tmp_eph_iter_gps != d_internal_pvt_solver->gps_ephemeris_map.cend()) { - uint32_t prn_aux = tmp_eph_iter_gps->second.i_satellite_PRN; + const uint32_t prn_aux = tmp_eph_iter_gps->second.i_satellite_PRN; if ((prn_aux == in[i][epoch].PRN) and (std::string(in[i][epoch].Signal) == "1C")) { store_valid_observable = true; @@ -1966,7 +1968,7 @@ int rtklib_pvt_gs::work(int noutput_items, gr_vector_const_void_star& input_item } if (tmp_eph_iter_gal != d_internal_pvt_solver->galileo_ephemeris_map.cend()) { - uint32_t prn_aux = tmp_eph_iter_gal->second.i_satellite_PRN; + const uint32_t prn_aux = tmp_eph_iter_gal->second.i_satellite_PRN; if ((prn_aux == in[i][epoch].PRN) and ((std::string(in[i][epoch].Signal) == "1B") or (std::string(in[i][epoch].Signal) == "5X"))) { store_valid_observable = true; @@ -1974,7 +1976,7 @@ int rtklib_pvt_gs::work(int noutput_items, gr_vector_const_void_star& input_item } if (tmp_eph_iter_cnav != d_internal_pvt_solver->gps_cnav_ephemeris_map.cend()) { - uint32_t prn_aux = tmp_eph_iter_cnav->second.i_satellite_PRN; + const uint32_t prn_aux = tmp_eph_iter_cnav->second.i_satellite_PRN; if ((prn_aux == in[i][epoch].PRN) and ((std::string(in[i][epoch].Signal) == "2S") or (std::string(in[i][epoch].Signal) == "L5"))) { store_valid_observable = true; @@ -1982,7 +1984,7 @@ int rtklib_pvt_gs::work(int noutput_items, gr_vector_const_void_star& input_item } if (tmp_eph_iter_glo_gnav != d_internal_pvt_solver->glonass_gnav_ephemeris_map.cend()) { - uint32_t prn_aux = tmp_eph_iter_glo_gnav->second.i_satellite_PRN; + const uint32_t prn_aux = tmp_eph_iter_glo_gnav->second.i_satellite_PRN; if ((prn_aux == in[i][epoch].PRN) and ((std::string(in[i][epoch].Signal) == "1G") or (std::string(in[i][epoch].Signal) == "2G"))) { store_valid_observable = true; @@ -1990,7 +1992,7 @@ int rtklib_pvt_gs::work(int noutput_items, gr_vector_const_void_star& input_item } if (tmp_eph_iter_bds_dnav != d_internal_pvt_solver->beidou_dnav_ephemeris_map.cend()) { - uint32_t prn_aux = tmp_eph_iter_bds_dnav->second.i_satellite_PRN; + const uint32_t prn_aux = tmp_eph_iter_bds_dnav->second.i_satellite_PRN; if ((prn_aux == in[i][epoch].PRN) and ((std::string(in[i][epoch].Signal) == "B1") or (std::string(in[i][epoch].Signal) == "B3"))) { store_valid_observable = true; @@ -2138,7 +2140,7 @@ int rtklib_pvt_gs::work(int noutput_items, gr_vector_const_void_star& input_item // required to report accumulated phase cycles comparable to pseudoranges initialize_and_apply_carrier_phase_offset(); - double Rx_clock_offset_s = d_user_pvt_solver->get_time_offset_s(); + const double Rx_clock_offset_s = d_user_pvt_solver->get_time_offset_s(); if (d_enable_rx_clock_correction == true and fabs(Rx_clock_offset_s) > 0.000001) // 1us !! { LOG(INFO) << "Warning: Rx clock offset at interpolated RX time: " << Rx_clock_offset_s * 1000.0 << "[ms]" @@ -3207,7 +3209,7 @@ int rtklib_pvt_gs::work(int noutput_items, gr_vector_const_void_star& input_item int gps_channel = 0; for (gnss_observables_iter = d_gnss_observables_map.cbegin(); gnss_observables_iter != d_gnss_observables_map.cend(); gnss_observables_iter++) { - std::string system(&gnss_observables_iter->second.System, 1); + const std::string system(&gnss_observables_iter->second.System, 1); if (gps_channel == 0) { if (system == "G") @@ -3305,7 +3307,7 @@ int rtklib_pvt_gs::work(int noutput_items, gr_vector_const_void_star& input_item int glo_channel = 0; for (gnss_observables_iter = d_gnss_observables_map.cbegin(); gnss_observables_iter != d_gnss_observables_map.cend(); gnss_observables_iter++) { - std::string system(&gnss_observables_iter->second.System, 1); + const std::string system(&gnss_observables_iter->second.System, 1); if (gps_channel == 0) { if (system == "G") @@ -3365,7 +3367,7 @@ int rtklib_pvt_gs::work(int noutput_items, gr_vector_const_void_star& input_item int glo_channel = 0; for (gnss_observables_iter = d_gnss_observables_map.cbegin(); gnss_observables_iter != d_gnss_observables_map.cend(); gnss_observables_iter++) { - std::string system(&gnss_observables_iter->second.System, 1); + const std::string system(&gnss_observables_iter->second.System, 1); if (gal_channel == 0) { if (system == "E") @@ -3424,7 +3426,7 @@ int rtklib_pvt_gs::work(int noutput_items, gr_vector_const_void_star& input_item int glo_channel = 0; for (gnss_observables_iter = d_gnss_observables_map.cbegin(); gnss_observables_iter != d_gnss_observables_map.cend(); gnss_observables_iter++) { - std::string system(&gnss_observables_iter->second.System, 1); + const std::string system(&gnss_observables_iter->second.System, 1); if (gps_channel == 0) { if (system == "G") @@ -3483,7 +3485,7 @@ int rtklib_pvt_gs::work(int noutput_items, gr_vector_const_void_star& input_item int glo_channel = 0; for (gnss_observables_iter = d_gnss_observables_map.cbegin(); gnss_observables_iter != d_gnss_observables_map.cend(); gnss_observables_iter++) { - std::string system(&gnss_observables_iter->second.System, 1); + const std::string system(&gnss_observables_iter->second.System, 1); if (gal_channel == 0) { if (system == "E") @@ -3542,7 +3544,7 @@ int rtklib_pvt_gs::work(int noutput_items, gr_vector_const_void_star& input_item int gps_channel = 0; for (gnss_observables_iter = d_gnss_observables_map.cbegin(); gnss_observables_iter != d_gnss_observables_map.cend(); gnss_observables_iter++) { - std::string system(&gnss_observables_iter->second.System, 1); + const std::string system(&gnss_observables_iter->second.System, 1); if (gal_channel == 0) { if (system == "E") @@ -3687,7 +3689,7 @@ int rtklib_pvt_gs::work(int noutput_items, gr_vector_const_void_star& input_item int gal_channel = 0; for (gnss_observables_iter = d_gnss_observables_map.cbegin(); gnss_observables_iter != d_gnss_observables_map.cend(); gnss_observables_iter++) { - std::string system(&gnss_observables_iter->second.System, 1); + const std::string system(&gnss_observables_iter->second.System, 1); if (gps_channel == 0) { if (system == "G") @@ -3739,7 +3741,7 @@ int rtklib_pvt_gs::work(int noutput_items, gr_vector_const_void_star& input_item int gal_channel = 0; for (gnss_observables_iter = d_gnss_observables_map.cbegin(); gnss_observables_iter != d_gnss_observables_map.cend(); gnss_observables_iter++) { - std::string system(&gnss_observables_iter->second.System, 1); + const std::string system(&gnss_observables_iter->second.System, 1); if (gal_channel == 0) { if (system == "E") @@ -3823,7 +3825,7 @@ int rtklib_pvt_gs::work(int noutput_items, gr_vector_const_void_star& input_item int glo_channel = 0; for (gnss_observables_iter = d_gnss_observables_map.cbegin(); gnss_observables_iter != d_gnss_observables_map.cend(); gnss_observables_iter++) { - std::string system(&gnss_observables_iter->second.System, 1); + const std::string system(&gnss_observables_iter->second.System, 1); if (gps_channel == 0) { if (system == "G") @@ -3883,7 +3885,7 @@ int rtklib_pvt_gs::work(int noutput_items, gr_vector_const_void_star& input_item auto glonass_gnav_eph_iter = d_user_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); for (gnss_observables_iter = d_gnss_observables_map.cbegin(); gnss_observables_iter != d_gnss_observables_map.cend(); gnss_observables_iter++) { - std::string system(&gnss_observables_iter->second.System, 1); + const std::string system(&gnss_observables_iter->second.System, 1); if (gal_channel == 0) { if (system == "E") @@ -3943,7 +3945,7 @@ int rtklib_pvt_gs::work(int noutput_items, gr_vector_const_void_star& input_item int glo_channel = 0; for (gnss_observables_iter = d_gnss_observables_map.cbegin(); gnss_observables_iter != d_gnss_observables_map.cend(); gnss_observables_iter++) { - std::string system(&gnss_observables_iter->second.System, 1); + const std::string system(&gnss_observables_iter->second.System, 1); if (gps_channel == 0) { if (system == "G") @@ -4004,7 +4006,7 @@ int rtklib_pvt_gs::work(int noutput_items, gr_vector_const_void_star& input_item auto glonass_gnav_eph_iter = d_user_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); for (gnss_observables_iter = d_gnss_observables_map.cbegin(); gnss_observables_iter != d_gnss_observables_map.cend(); gnss_observables_iter++) { - std::string system(&gnss_observables_iter->second.System, 1); + const std::string system(&gnss_observables_iter->second.System, 1); if (gal_channel == 0) { if (system == "E") @@ -4064,7 +4066,7 @@ int rtklib_pvt_gs::work(int noutput_items, gr_vector_const_void_star& input_item int gal_channel = 0; for (gnss_observables_iter = d_gnss_observables_map.cbegin(); gnss_observables_iter != d_gnss_observables_map.cend(); gnss_observables_iter++) { - std::string system(&gnss_observables_iter->second.System, 1); + const std::string system(&gnss_observables_iter->second.System, 1); if (gps_channel == 0) { if (system == "G") @@ -4177,7 +4179,7 @@ int rtklib_pvt_gs::work(int noutput_items, gr_vector_const_void_star& input_item // PVT MONITOR if (d_user_pvt_solver->is_valid_position()) { - std::shared_ptr monitor_pvt = std::make_shared(d_user_pvt_solver->get_monitor_pvt()); + const std::shared_ptr monitor_pvt = std::make_shared(d_user_pvt_solver->get_monitor_pvt()); // publish new position to the gnss_flowgraph channel status monitor if (current_RX_time_ms % d_report_rate_ms == 0) diff --git a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.h b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.h index 99c00b36c..64fc532fa 100644 --- a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.h +++ b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.h @@ -28,6 +28,7 @@ #include // for gr_vector_const_void_star #include // for pmt_t #include // for system_clock +#include // for size_t #include // for int32_t #include // for time_t #include // for map @@ -202,6 +203,26 @@ private: boost::posix_time::time_duration d_utc_diff_time; + size_t d_gps_ephemeris_sptr_type_hash_code; + size_t d_gps_iono_sptr_type_hash_code; + size_t d_gps_utc_model_sptr_type_hash_code; + size_t d_gps_cnav_ephemeris_sptr_type_hash_code; + size_t d_gps_cnav_iono_sptr_type_hash_code; + size_t d_gps_cnav_utc_model_sptr_type_hash_code; + size_t d_gps_almanac_sptr_type_hash_code; + size_t d_galileo_ephemeris_sptr_type_hash_code; + size_t d_galileo_iono_sptr_type_hash_code; + size_t d_galileo_utc_model_sptr_type_hash_code; + size_t d_galileo_almanac_helper_sptr_type_hash_code; + size_t d_galileo_almanac_sptr_type_hash_code; + size_t d_glonass_gnav_ephemeris_sptr_type_hash_code; + size_t d_glonass_gnav_utc_model_sptr_type_hash_code; + size_t d_glonass_gnav_almanac_sptr_type_hash_code; + size_t d_beidou_dnav_ephemeris_sptr_type_hash_code; + size_t d_beidou_dnav_iono_sptr_type_hash_code; + size_t d_beidou_dnav_utc_model_sptr_type_hash_code; + size_t d_beidou_dnav_almanac_sptr_type_hash_code; + double d_rinex_version; double d_rx_time; diff --git a/src/algorithms/PVT/libs/geojson_printer.cc b/src/algorithms/PVT/libs/geojson_printer.cc index 95b2becca..e8453e4fc 100644 --- a/src/algorithms/PVT/libs/geojson_printer.cc +++ b/src/algorithms/PVT/libs/geojson_printer.cc @@ -101,8 +101,8 @@ GeoJSON_Printer::~GeoJSON_Printer() bool GeoJSON_Printer::set_headers(const std::string& filename, bool time_tag_name) { - boost::posix_time::ptime pt = boost::posix_time::second_clock::local_time(); - tm timeinfo = boost::posix_time::to_tm(pt); + const boost::posix_time::ptime pt = boost::posix_time::second_clock::local_time(); + const tm timeinfo = boost::posix_time::to_tm(pt); if (time_tag_name) { diff --git a/src/algorithms/PVT/libs/gpx_printer.cc b/src/algorithms/PVT/libs/gpx_printer.cc index 19e1895d2..c530c3965 100644 --- a/src/algorithms/PVT/libs/gpx_printer.cc +++ b/src/algorithms/PVT/libs/gpx_printer.cc @@ -89,8 +89,8 @@ Gpx_Printer::Gpx_Printer(const std::string& base_path) bool Gpx_Printer::set_headers(const std::string& filename, bool time_tag_name) { - boost::posix_time::ptime pt = boost::posix_time::second_clock::local_time(); - tm timeinfo = boost::posix_time::to_tm(pt); + const boost::posix_time::ptime pt = boost::posix_time::second_clock::local_time(); + const tm timeinfo = boost::posix_time::to_tm(pt); if (time_tag_name) { @@ -146,14 +146,14 @@ bool Gpx_Printer::set_headers(const std::string& filename, bool time_tag_name) gpx_file << std::setprecision(14); gpx_file << R"()" << '\n' << R"(" << '\n' - << indent << "" << '\n' - << indent << indent << "Position fixes computed by GNSS-SDR v" << GNSS_SDR_VERSION << "" << '\n' - << indent << indent << "GNSS-SDR position log generated at " << pt << " (local time)" << '\n' + << indent << "xsi:schemaLocation=\"http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd http://www.garmin.com/xmlschemas/GpxExtensions/v3 http://www.garmin.com/xmlschemas/GpxExtensionsv3.xsd http://www.garmin.com/xmlschemas/TrackPointExtension/v2 http://www.garmin.com/xmlschemas/TrackPointExtensionv2.xsd\"\n" + << indent << "xmlns=\"http://www.topografix.com/GPX/1/1\"\n" + << indent << "xmlns:gpxx=\"http://www.garmin.com/xmlschemas/GpxExtensions/v3\"\n" + << indent << "xmlns:gpxtpx=\"http://www.garmin.com/xmlschemas/TrackPointExtension/v2\"\n" + << indent << "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" + << indent << "\n" + << indent << indent << "Position fixes computed by GNSS-SDR v" << GNSS_SDR_VERSION << "\n" + << indent << indent << "GNSS-SDR position log generated at " << pt << " (local time)\n" << indent << indent << "\n"; return true; } @@ -170,12 +170,12 @@ bool Gpx_Printer::print_position(const Pvt_Solution* position, bool print_averag positions_printed = true; - double speed_over_ground = position->get_speed_over_ground(); // expressed in m/s - double course_over_ground = position->get_course_over_ground(); // expressed in deg + const double speed_over_ground = position->get_speed_over_ground(); // expressed in m/s + const double course_over_ground = position->get_course_over_ground(); // expressed in deg - double hdop = position->get_hdop(); - double vdop = position->get_vdop(); - double pdop = position->get_pdop(); + const double hdop = position->get_hdop(); + const double vdop = position->get_vdop(); + const double pdop = position->get_pdop(); std::string utc_time = to_iso_extended_string(position->get_position_UTC_time()); if (utc_time.length() < 23) { @@ -216,8 +216,8 @@ bool Gpx_Printer::close_file() { if (gpx_file.is_open()) { - gpx_file << indent << indent << "" << '\n' - << indent << "" << '\n' + gpx_file << indent << indent << "\n" + << indent << "\n" << ""; gpx_file.close(); return true; diff --git a/src/algorithms/PVT/libs/kml_printer.cc b/src/algorithms/PVT/libs/kml_printer.cc index e610436a4..4e4b7362c 100644 --- a/src/algorithms/PVT/libs/kml_printer.cc +++ b/src/algorithms/PVT/libs/kml_printer.cc @@ -109,8 +109,8 @@ Kml_Printer::Kml_Printer(const std::string& base_path) bool Kml_Printer::set_headers(const std::string& filename, bool time_tag_name) { - boost::posix_time::ptime pt = boost::posix_time::second_clock::local_time(); - tm timeinfo = boost::posix_time::to_tm(pt); + const boost::posix_time::ptime pt = boost::posix_time::second_clock::local_time(); + const tm timeinfo = boost::posix_time::to_tm(pt); if (time_tag_name) { @@ -171,57 +171,57 @@ bool Kml_Printer::set_headers(const std::string& filename, bool time_tag_name) kml_file << R"()" << '\n' << R"()" << '\n' - << indent << "" << '\n' - << indent << indent << "GNSS Track" << '\n' - << indent << indent << "" << '\n' - << indent << indent << indent << indent << "GNSS-SDR Receiver position log file created at " << pt << "" << '\n' - << indent << indent << indent << indent << "https://gnss-sdr.org/" << '\n' - << indent << indent << indent << "" << '\n' - << indent << indent << "]]>" << '\n' - << indent << indent << "" << '\n' - << indent << indent << "" << '\n' - << indent << indent << "" << '\n' - << indent << indent << "" << '\n' - << indent << indent << "" << '\n' - << indent << indent << indent << "" << '\n' - << indent << indent << indent << indent << "normal" << '\n' - << indent << indent << indent << indent << "#track_n" << '\n' - << indent << indent << indent << "" << '\n' - << indent << indent << indent << "" << '\n' - << indent << indent << indent << indent << "highlight" << '\n' - << indent << indent << indent << indent << "#track_h" << '\n' - << indent << indent << indent << "" << '\n' - << indent << indent << "" << '\n' - << indent << indent << "" << '\n' - << indent << indent << "" << '\n' + << indent << "\n" + << indent << indent << "GNSS Track\n" + << indent << indent << "\n" + << indent << indent << indent << indent << "GNSS-SDR Receiver position log file created at " << pt << "\n" + << indent << indent << indent << indent << "https://gnss-sdr.org/\n" + << indent << indent << indent << "\n" + << indent << indent << "]]>\n" + << indent << indent << "\n" + << indent << indent << "\n" + << indent << indent << "\n" + << indent << indent << "\n" + << indent << indent << "\n" + << indent << indent << indent << "\n" + << indent << indent << indent << indent << "normal\n" + << indent << indent << indent << indent << "#track_n\n" + << indent << indent << indent << "\n" + << indent << indent << indent << "\n" + << indent << indent << indent << indent << "highlight\n" + << indent << indent << indent << indent << "#track_h\n" + << indent << indent << indent << "\n" + << indent << indent << "\n" + << indent << indent << "\n" + << indent << indent << "\n" << indent << indent << indent << "Points\n"; return true; @@ -239,12 +239,12 @@ bool Kml_Printer::print_position(const Pvt_Solution* position, bool print_averag positions_printed = true; - double speed_over_ground = position->get_speed_over_ground(); // expressed in m/s - double course_over_ground = position->get_course_over_ground(); // expressed in deg + const double speed_over_ground = position->get_speed_over_ground(); // expressed in m/s + const double course_over_ground = position->get_course_over_ground(); // expressed in deg - double hdop = position->get_hdop(); - double vdop = position->get_vdop(); - double pdop = position->get_pdop(); + const double hdop = position->get_hdop(); + const double vdop = position->get_vdop(); + const double pdop = position->get_pdop(); std::string utc_time = to_iso_extended_string(position->get_position_UTC_time()); if (utc_time.length() < 23) { @@ -269,30 +269,30 @@ bool Kml_Printer::print_position(const Pvt_Solution* position, bool print_averag if (kml_file.is_open() && tmp_file.is_open()) { point_id++; - kml_file << indent << indent << indent << "" << '\n' - << indent << indent << indent << indent << "" << point_id << "" << '\n' - << indent << indent << indent << indent << "" << '\n' - << indent << indent << indent << indent << "" << '\n' - << indent << indent << indent << indent << indent << indent << "Time:" << utc_time << "" << '\n' - << indent << indent << indent << indent << indent << indent << "Longitude:" << longitude << "deg" << '\n' - << indent << indent << indent << indent << indent << indent << "Latitude:" << latitude << "deg" << '\n' - << indent << indent << indent << indent << indent << indent << "Altitude:" << height << "m" << '\n' - << indent << indent << indent << indent << indent << indent << "Speed:" << speed_over_ground << "m/s" << '\n' - << indent << indent << indent << indent << indent << indent << "Course:" << course_over_ground << "deg" << '\n' - << indent << indent << indent << indent << indent << indent << "HDOP:" << hdop << "" << '\n' - << indent << indent << indent << indent << indent << indent << "VDOP:" << vdop << "" << '\n' - << indent << indent << indent << indent << indent << indent << "PDOP:" << pdop << "" << '\n' - << indent << indent << indent << indent << indent << "" << '\n' - << indent << indent << indent << indent << "]]>" << '\n' - << indent << indent << indent << indent << "" << '\n' - << indent << indent << indent << indent << indent << "" << utc_time << "" << '\n' - << indent << indent << indent << indent << "" << '\n' - << indent << indent << indent << indent << "#track" << '\n' - << indent << indent << indent << indent << "" << '\n' - << indent << indent << indent << indent << indent << "absolute" << '\n' - << indent << indent << indent << indent << indent << "" << longitude << "," << latitude << "," << height << "" << '\n' - << indent << indent << indent << indent << "" << '\n' + kml_file << indent << indent << indent << "\n" + << indent << indent << indent << indent << "" << point_id << "\n" + << indent << indent << indent << indent << "\n" + << indent << indent << indent << indent << "\n" + << indent << indent << indent << indent << indent << indent << "Time:" << utc_time << "\n" + << indent << indent << indent << indent << indent << indent << "Longitude:" << longitude << "deg\n" + << indent << indent << indent << indent << indent << indent << "Latitude:" << latitude << "deg\n" + << indent << indent << indent << indent << indent << indent << "Altitude:" << height << "m\n" + << indent << indent << indent << indent << indent << indent << "Speed:" << speed_over_ground << "m/s\n" + << indent << indent << indent << indent << indent << indent << "Course:" << course_over_ground << "deg\n" + << indent << indent << indent << indent << indent << indent << "HDOP:" << hdop << "\n" + << indent << indent << indent << indent << indent << indent << "VDOP:" << vdop << "\n" + << indent << indent << indent << indent << indent << indent << "PDOP:" << pdop << "\n" + << indent << indent << indent << indent << indent << "\n" + << indent << indent << indent << indent << "]]>\n" + << indent << indent << indent << indent << "\n" + << indent << indent << indent << indent << indent << "" << utc_time << "\n" + << indent << indent << indent << indent << "\n" + << indent << indent << indent << indent << "#track\n" + << indent << indent << indent << indent << "\n" + << indent << indent << indent << indent << indent << "absolute\n" + << indent << indent << indent << indent << indent << "" << longitude << "," << latitude << "," << height << "\n" + << indent << indent << indent << indent << "\n" << indent << indent << indent << "\n"; tmp_file << indent << indent << indent << indent << indent @@ -311,23 +311,23 @@ bool Kml_Printer::close_file() tmp_file.close(); kml_file << indent << indent << "" - << indent << indent << "" << '\n' - << indent << indent << indent << "Path" << '\n' - << indent << indent << indent << "#yellowLineGreenPoly" << '\n' - << indent << indent << indent << "" << '\n' - << indent << indent << indent << indent << "0" << '\n' - << indent << indent << indent << indent << "1" << '\n' - << indent << indent << indent << indent << "absolute" << '\n' + << indent << indent << "\n" + << indent << indent << indent << "Path\n" + << indent << indent << indent << "#yellowLineGreenPoly\n" + << indent << indent << indent << "\n" + << indent << indent << indent << indent << "0\n" + << indent << indent << indent << indent << "1\n" + << indent << indent << indent << indent << "absolute\n" << indent << indent << indent << indent << "\n"; // Copy the contents of tmp_file into kml_file std::ifstream src(tmp_file_str, std::ios::binary); kml_file << src.rdbuf(); - kml_file << indent << indent << indent << indent << "" << '\n' - << indent << indent << indent << "" << '\n' - << indent << indent << "" << '\n' - << indent << "" << '\n' + kml_file << indent << indent << indent << indent << "\n" + << indent << indent << indent << "\n" + << indent << indent << "\n" + << indent << "\n" << ""; kml_file.close(); diff --git a/src/algorithms/PVT/libs/nmea_printer.cc b/src/algorithms/PVT/libs/nmea_printer.cc index 8bd8d0e91..29a853bed 100644 --- a/src/algorithms/PVT/libs/nmea_printer.cc +++ b/src/algorithms/PVT/libs/nmea_printer.cc @@ -126,7 +126,7 @@ Nmea_Printer::Nmea_Printer(const std::string& filename, bool flag_nmea_output_fi Nmea_Printer::~Nmea_Printer() { DLOG(INFO) << "NMEA printer destructor called."; - auto pos = nmea_file_descriptor.tellp(); + const auto pos = nmea_file_descriptor.tellp(); try { if (nmea_file_descriptor.is_open()) @@ -170,11 +170,11 @@ int Nmea_Printer::init_serial(const std::string& serial_device) // clang-format off struct termios options{}; // clang-format on - int64_t BAUD; - int64_t DATABITS; - int64_t STOPBITS; - int64_t PARITYON; - int64_t PARITY; + const int64_t BAUD = B9600; // BAUD = B38400; + const int64_t DATABITS = CS8; + const int64_t STOPBITS = 0; + const int64_t PARITYON = 0; + const int64_t PARITY = 0; fd = open(serial_device.c_str(), O_RDWR | O_NOCTTY | O_NDELAY | O_CLOEXEC); if (fd == -1) @@ -188,13 +188,6 @@ int Nmea_Printer::init_serial(const std::string& serial_device) } tcgetattr(fd, &options); // read serial port options - BAUD = B9600; - // BAUD = B38400; - DATABITS = CS8; - STOPBITS = 0; - PARITYON = 0; - PARITY = 0; - options.c_cflag = BAUD | DATABITS | STOPBITS | PARITYON | PARITY | CLOCAL | CREAD; // enable receiver, set 8 bit data, ignore control lines // options.c_cflag |= (CLOCAL | CREAD | CS8); @@ -217,11 +210,6 @@ void Nmea_Printer::close_serial() bool Nmea_Printer::Print_Nmea_Line(const Rtklib_Solver* pvt_data, bool print_average_values) { - std::string GPRMC; - std::string GPGGA; - std::string GPGSA; - std::string GPGSV; - // set the new PVT data d_PVT_data = pvt_data; print_avg_pos = print_average_values; @@ -229,13 +217,13 @@ bool Nmea_Printer::Print_Nmea_Line(const Rtklib_Solver* pvt_data, bool print_ave // generate the NMEA sentences // GPRMC - GPRMC = get_GPRMC(); + const std::string GPRMC = get_GPRMC(); // GPGGA (Global Positioning System Fixed Data) - GPGGA = get_GPGGA(); + const std::string GPGGA = get_GPGGA(); // GPGSA - GPGSA = get_GPGSA(); + const std::string GPGSA = get_GPGSA(); // GPGSV - GPGSV = get_GPGSV(); + const std::string GPGSV = get_GPGSV(); // write to log file if (d_flag_nmea_output_file) @@ -311,7 +299,7 @@ std::string Nmea_Printer::latitude_to_hm(double lat) north = true; } - int deg = static_cast(lat); + const int deg = static_cast(lat); double mins = lat - static_cast(deg); mins *= 60.0; std::ostringstream out_string; @@ -348,7 +336,7 @@ std::string Nmea_Printer::longitude_to_hm(double longitude) { east = true; } - int deg = static_cast(longitude); + const int deg = static_cast(longitude); double mins = longitude - static_cast(deg); mins *= 60.0; std::ostringstream out_string; @@ -378,11 +366,11 @@ std::string Nmea_Printer::get_UTC_NMEA_time(boost::posix_time::ptime d_position_ // UTC Time: hhmmss.sss std::stringstream sentence_str; - boost::posix_time::time_duration td = d_position_UTC_time.time_of_day(); - int utc_hours = td.hours(); - int utc_mins = td.minutes(); - int utc_seconds = td.seconds(); - auto utc_milliseconds = static_cast(td.total_milliseconds() - td.total_seconds() * 1000); + const boost::posix_time::time_duration td = d_position_UTC_time.time_of_day(); + const int utc_hours = td.hours(); + const int utc_mins = td.minutes(); + const int utc_seconds = td.seconds(); + const auto utc_milliseconds = static_cast(td.total_milliseconds() - td.total_seconds() * 1000); if (utc_hours < 10) { diff --git a/src/algorithms/PVT/libs/rinex_printer.cc b/src/algorithms/PVT/libs/rinex_printer.cc index ea77c7fdb..e5554116a 100644 --- a/src/algorithms/PVT/libs/rinex_printer.cc +++ b/src/algorithms/PVT/libs/rinex_printer.cc @@ -236,20 +236,14 @@ Rinex_Printer::~Rinex_Printer() { DLOG(INFO) << "RINEX printer destructor called."; // close RINEX files - int64_t posn; - int64_t poso; - int64_t poss; - int64_t posng; - int64_t posmn; - int64_t posnr; - int64_t posnc; - posn = navFile.tellp(); - poso = obsFile.tellp(); - poss = sbsFile.tellp(); - posng = navGalFile.tellp(); - posmn = navMixFile.tellp(); - posnr = navGloFile.tellp(); - posnc = navBdsFile.tellp(); + const auto posn = navFile.tellp(); + const auto poso = obsFile.tellp(); + const auto poss = sbsFile.tellp(); + const auto posng = navGalFile.tellp(); + const auto posmn = navMixFile.tellp(); + const auto posnr = navGloFile.tellp(); + const auto posnc = navBdsFile.tellp(); + try { Rinex_Printer::navFile.close(); @@ -263,8 +257,8 @@ Rinex_Printer::~Rinex_Printer() { std::cerr << e.what() << '\n'; } - // If nothing written, erase the files. + // If nothing written, erase the files. if (posn == 0) { errorlib::error_code ec; @@ -339,7 +333,7 @@ void Rinex_Printer::lengthCheck(const std::string& line) std::string Rinex_Printer::createFilename(const std::string& type, const std::string& base_name) { const std::string stationName = "GSDR"; // 4-character station name designator - boost::gregorian::date today = boost::gregorian::day_clock::local_day(); + const boost::gregorian::date today = boost::gregorian::day_clock::local_day(); const int32_t dayOfTheYear = today.day_of_year(); std::stringstream strm0; if (dayOfTheYear < 100) @@ -351,7 +345,7 @@ std::string Rinex_Printer::createFilename(const std::string& type, const std::st strm0 << "0"; // three digits for day of the year } strm0 << dayOfTheYear; - std::string dayOfTheYearTag = strm0.str(); + const std::string dayOfTheYearTag = strm0.str(); std::map fileType; fileType.insert(std::pair("RINEX_FILE_TYPE_OBS", "O")); // O - Observation file. @@ -366,9 +360,9 @@ std::string Rinex_Printer::createFilename(const std::string& type, const std::st fileType.insert(std::pair("RINEX_FILE_TYPE_SUMMARY", "S")); // S - Summary file (used e.g., by IGS, not a standard!). fileType.insert(std::pair("RINEX_FILE_TYPE_BDS_NAV", "F")); // G - GLONASS navigation file. - boost::posix_time::ptime pt = boost::posix_time::second_clock::local_time(); - tm pt_tm = boost::posix_time::to_tm(pt); - int32_t local_hour = pt_tm.tm_hour; + const boost::posix_time::ptime pt = boost::posix_time::second_clock::local_time(); + const tm pt_tm = boost::posix_time::to_tm(pt); + const int32_t local_hour = pt_tm.tm_hour; std::stringstream strm; strm << local_hour; @@ -398,9 +392,9 @@ std::string Rinex_Printer::createFilename(const std::string& type, const std::st Hmap.insert(std::pair("22", "w")); Hmap.insert(std::pair("23", "x")); - std::string hourTag = Hmap[strm.str()]; + const std::string hourTag = Hmap[strm.str()]; - int32_t local_minute = pt_tm.tm_min; + const int32_t local_minute = pt_tm.tm_min; std::stringstream strm2; if (local_minute < 10) { @@ -408,14 +402,14 @@ std::string Rinex_Printer::createFilename(const std::string& type, const std::st } strm2 << local_minute; - std::string minTag = strm2.str(); + const std::string minTag = strm2.str(); - int32_t local_year = pt_tm.tm_year - 100; // 2012 is 112 + const int32_t local_year = pt_tm.tm_year - 100; // 2012 is 112 std::stringstream strm3; strm3 << local_year; std::string yearTag = strm3.str(); - std::string typeOfFile = fileType[type]; + const std::string typeOfFile = fileType[type]; std::string filename; if (base_name == "-") { @@ -436,7 +430,7 @@ std::string Rinex_Printer::getLocalTime() line += std::string(12, ' '); std::string username; std::array c_username{}; - int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); + const int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); if (nGet == 0) { username = c_username.data(); @@ -446,14 +440,14 @@ std::string Rinex_Printer::getLocalTime() username = "UNKNOWN USER"; } line += Rinex_Printer::leftJustify(username, 20); - boost::gregorian::date today = boost::gregorian::day_clock::local_day(); + const boost::gregorian::date today = boost::gregorian::day_clock::local_day(); - boost::local_time::time_zone_ptr zone(new boost::local_time::posix_time_zone("UTC")); - boost::local_time::local_date_time pt = boost::local_time::local_sec_clock::local_time(zone); - tm pt_tm = boost::local_time::to_tm(pt); + const boost::local_time::time_zone_ptr zone(new boost::local_time::posix_time_zone("UTC")); + const boost::local_time::local_date_time pt = boost::local_time::local_sec_clock::local_time(zone); + const tm pt_tm = boost::local_time::to_tm(pt); std::stringstream strmHour; - int32_t utc_hour = pt_tm.tm_hour; + const int32_t utc_hour = pt_tm.tm_hour; if (utc_hour < 10) { strmHour << "0"; // two digits for hours @@ -461,7 +455,7 @@ std::string Rinex_Printer::getLocalTime() strmHour << utc_hour; std::stringstream strmMin; - int32_t utc_minute = pt_tm.tm_min; + const int32_t utc_minute = pt_tm.tm_min; if (utc_minute < 10) { strmMin << "0"; // two digits for minutes @@ -470,7 +464,7 @@ std::string Rinex_Printer::getLocalTime() if (version == 2) { - int32_t day = pt_tm.tm_mday; + const int32_t day = pt_tm.tm_mday; line += Rinex_Printer::rightJustify(std::to_string(day), 2); line += std::string("-"); @@ -506,7 +500,7 @@ std::string Rinex_Printer::getLocalTime() line += strmMin.str(); std::stringstream strm2; - int32_t utc_seconds = pt_tm.tm_sec; + const int32_t utc_seconds = pt_tm.tm_sec; if (utc_seconds < 10) { strm2 << "0"; // two digits for seconds @@ -599,11 +593,11 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Glonass_Gnav_Utc_M if (version == 2) { // Set reference time and its clock corrections - boost::posix_time::ptime p_utc_ref_time = glonass_gnav_eph.glot_to_utc(glonass_gnav_eph.d_t_b, 0.0); - std::string timestring = boost::posix_time::to_iso_string(p_utc_ref_time); - std::string year(timestring, 0, 4); - std::string month(timestring, 4, 2); - std::string day(timestring, 6, 2); + const boost::posix_time::ptime p_utc_ref_time = glonass_gnav_eph.glot_to_utc(glonass_gnav_eph.d_t_b, 0.0); + const std::string timestring = boost::posix_time::to_iso_string(p_utc_ref_time); + const std::string year(timestring, 0, 4); + const std::string month(timestring, 4, 2); + const std::string day(timestring, 6, 2); line.clear(); line += Rinex_Printer::rightJustify(year, 6); @@ -971,7 +965,7 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Galileo_Iono& gali line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai0_5, 10, 2), 12); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai1_5, 10, 2), 12); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai2_5, 10, 2), 12); - double zero = 0.0; + const double zero = 0.0; line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(zero, 10, 2), 12); line += std::string(7, ' '); line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); @@ -1078,7 +1072,7 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Galileo_Iono& iono line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.ai0_5, 10, 2), 12); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.ai1_5, 10, 2), 12); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.ai2_5, 10, 2), 12); - double zero = 0.0; + const double zero = 0.0; line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(zero, 10, 2), 12); line += std::string(7, ' '); line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); @@ -1300,7 +1294,7 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_CNAV_Iono& ion line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai0_5, 10, 2), 12); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai1_5, 10, 2), 12); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai2_5, 10, 2), 12); - double zero = 0.0; + const double zero = 0.0; line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(zero, 10, 2), 12); line += std::string(7, ' '); line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); @@ -1679,7 +1673,7 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_Iono& gps_iono line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai0_5, 10, 2), 12); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai1_5, 10, 2), 12); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai2_5, 10, 2), 12); - double zero = 0.0; + const double zero = 0.0; line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(zero, 10, 2), 12); line += std::string(7, ' '); line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); @@ -2354,7 +2348,7 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Galileo_Iono& gali line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai0_5, 10, 2), 12); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai1_5, 10, 2), 12); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai2_5, 10, 2), 12); - double zero = 0.0; + const double zero = 0.0; line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(zero, 10, 2), 12); line += std::string(7, ' '); line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); @@ -2463,9 +2457,9 @@ void Rinex_Printer::rinex_sbs_header(std::fstream& out) } line += Rinex_Printer::leftJustify(username, 20); // Date of file creation (dd-mmm-yy hhmm) - boost::local_time::time_zone_ptr zone(new boost::local_time::posix_time_zone("UTC")); - boost::local_time::local_date_time pt = boost::local_time::local_sec_clock::local_time(zone); - tm pt_tm = boost::local_time::to_tm(pt); + const boost::local_time::time_zone_ptr zone(new boost::local_time::posix_time_zone("UTC")); + const boost::local_time::local_date_time pt = boost::local_time::local_sec_clock::local_time(zone); + const tm pt_tm = boost::local_time::to_tm(pt); std::stringstream strYear; int32_t utc_year = pt.date().year(); utc_year -= 2000; // two digits for year @@ -2559,7 +2553,7 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Glonass_Gnav_Utc_ std::vector data; std::string line_aux; - int64_t pos = out.tellp(); + const int64_t pos = out.tellp(); out.seekp(0); data.clear(); @@ -2631,7 +2625,7 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Galileo_Iono& gal std::vector data; std::string line_aux; - int64_t pos = out.tellp(); + const int64_t pos = out.tellp(); out.seekp(0); data.clear(); @@ -2653,7 +2647,7 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Galileo_Iono& gal line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai0_5, 10, 2), 12); line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai1_5, 10, 2), 12); line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai2_5, 10, 2), 12); - double zero = 0.0; + const double zero = 0.0; line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(zero, 10, 2), 12); line_aux += std::string(7, ' '); line_aux += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); @@ -2905,7 +2899,7 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_CNAV_Utc_Mode std::vector data; std::string line_aux; - int64_t pos = out.tellp(); + const int64_t pos = out.tellp(); out.seekp(0); data.clear(); @@ -3000,7 +2994,7 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_CNAV_Utc_Mode std::vector data; std::string line_aux; - int64_t pos = out.tellp(); + const int64_t pos = out.tellp(); out.seekp(0); data.clear(); @@ -3021,7 +3015,7 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_CNAV_Utc_Mode line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai0_5, 10, 2), 12); line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai1_5, 10, 2), 12); line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai2_5, 10, 2), 12); - double zero = 0.0; + const double zero = 0.0; line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(zero, 10, 2), 12); line_aux += std::string(7, ' '); line_aux += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); @@ -3129,7 +3123,7 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_Iono& gps_ion std::vector data; std::string line_aux; - int64_t pos = out.tellp(); + const int64_t pos = out.tellp(); out.seekp(0); data.clear(); @@ -3163,7 +3157,7 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_Iono& gps_ion line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai0_5, 10, 2), 12); line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai1_5, 10, 2), 12); line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai2_5, 10, 2), 12); - double zero = 0.0; + const double zero = 0.0; line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(zero, 10, 2), 12); line_aux += std::string(7, ' '); line_aux += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); @@ -3276,7 +3270,7 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_Iono& gps_ion std::vector data; std::string line_aux; - int64_t pos = out.tellp(); + const int64_t pos = out.tellp(); out.seekp(0); data.clear(); @@ -3398,7 +3392,7 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_CNAV_Iono& gp std::vector data; std::string line_aux; - int64_t pos = out.tellp(); + const int64_t pos = out.tellp(); out.seekp(0); data.clear(); @@ -3510,7 +3504,7 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Galileo_Iono& gal std::vector data; std::string line_aux; - int64_t pos = out.tellp(); + const int64_t pos = out.tellp(); out.seekp(0); data.clear(); @@ -3532,7 +3526,7 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Galileo_Iono& gal line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai0_5, 10, 2), 12); line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai1_5, 10, 2), 12); line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai2_5, 10, 2), 12); - double zero = 0.0; + const double zero = 0.0; line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(zero, 10, 2), 12); line_aux += std::string(7, ' '); line_aux += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); @@ -3605,7 +3599,7 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Beidou_Dnav_Utc_M std::vector data; std::string line_aux; - int64_t pos = out.tellp(); + const int64_t pos = out.tellp(); out.seekp(0); data.clear(); @@ -3703,18 +3697,18 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::mapsecond, gps_ephemeris_iter->second.d_Toc); - std::string timestring = boost::posix_time::to_iso_string(p_utc_time); - std::string month(timestring, 4, 2); - std::string day(timestring, 6, 2); - std::string hour(timestring, 9, 2); - std::string minutes(timestring, 11, 2); - std::string seconds(timestring, 13, 2); + const boost::posix_time::ptime p_utc_time = Rinex_Printer::compute_GPS_time(gps_ephemeris_iter->second, gps_ephemeris_iter->second.d_Toc); + const std::string timestring = boost::posix_time::to_iso_string(p_utc_time); + const std::string month(timestring, 4, 2); + const std::string day(timestring, 6, 2); + const std::string hour(timestring, 9, 2); + const std::string minutes(timestring, 11, 2); + const std::string seconds(timestring, 13, 2); if (version == 2) { line += Rinex_Printer::rightJustify(std::to_string(gps_ephemeris_iter->second.i_satellite_PRN), 2); line += std::string(1, ' '); - std::string year(timestring, 2, 2); + const std::string year(timestring, 2, 2); line += year; line += std::string(1, ' '); if (boost::lexical_cast(month) < 10) @@ -3789,7 +3783,7 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::mapsecond.i_satellite_PRN); - std::string year(timestring, 0, 4); + const std::string year(timestring, 0, 4); line += std::string(1, ' '); line += year; line += std::string(1, ' '); @@ -4086,20 +4080,20 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::mapsecond, gps_ephemeris_iter->second.d_Toc); - std::string timestring = boost::posix_time::to_iso_string(p_utc_time); - std::string month(timestring, 4, 2); - std::string day(timestring, 6, 2); - std::string hour(timestring, 9, 2); - std::string minutes(timestring, 11, 2); - std::string seconds(timestring, 13, 2); + const boost::posix_time::ptime p_utc_time = Rinex_Printer::compute_GPS_time(gps_ephemeris_iter->second, gps_ephemeris_iter->second.d_Toc); + const std::string timestring = boost::posix_time::to_iso_string(p_utc_time); + const std::string month(timestring, 4, 2); + const std::string day(timestring, 6, 2); + const std::string hour(timestring, 9, 2); + const std::string minutes(timestring, 11, 2); + const std::string seconds(timestring, 13, 2); line += satelliteSystem["GPS"]; if (gps_ephemeris_iter->second.i_satellite_PRN < 10) { line += std::string("0"); } line += std::to_string(gps_ephemeris_iter->second.i_satellite_PRN); - std::string year(timestring, 0, 4); + const std::string year(timestring, 0, 4); line += std::string(1, ' '); line += year; line += std::string(1, ' '); @@ -4253,13 +4247,13 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::mapsecond, galileo_ephemeris_iter->second.t0e_1); - std::string timestring = boost::posix_time::to_iso_string(p_utc_time); - std::string month(timestring, 4, 2); - std::string day(timestring, 6, 2); - std::string hour(timestring, 9, 2); - std::string minutes(timestring, 11, 2); - std::string seconds(timestring, 13, 2); + const boost::posix_time::ptime p_utc_time = Rinex_Printer::compute_Galileo_time(galileo_ephemeris_iter->second, galileo_ephemeris_iter->second.t0e_1); + const std::string timestring = boost::posix_time::to_iso_string(p_utc_time); + const std::string month(timestring, 4, 2); + const std::string day(timestring, 6, 2); + const std::string hour(timestring, 9, 2); + const std::string minutes(timestring, 11, 2); + const std::string seconds(timestring, 13, 2); line += satelliteSystem["Galileo"]; if (galileo_ephemeris_iter->second.i_satellite_PRN < 10) @@ -4267,7 +4261,7 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::mapsecond.i_satellite_PRN); - std::string year(timestring, 0, 4); + const std::string year(timestring, 0, 4); line += std::string(1, ' '); line += year; line += std::string(1, ' '); @@ -4357,7 +4351,7 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::mapsecond.glot_to_utc(glonass_gnav_ephemeris_iter->second.d_t_b, 0.0); - std::string timestring = boost::posix_time::to_iso_string(p_utc_time); - std::string month(timestring, 4, 2); - std::string day(timestring, 6, 2); - std::string hour(timestring, 9, 2); - std::string minutes(timestring, 11, 2); - std::string seconds(timestring, 13, 2); + const boost::posix_time::ptime p_utc_time = glonass_gnav_ephemeris_iter->second.glot_to_utc(glonass_gnav_ephemeris_iter->second.d_t_b, 0.0); + const std::string timestring = boost::posix_time::to_iso_string(p_utc_time); + const std::string month(timestring, 4, 2); + const std::string day(timestring, 6, 2); + const std::string hour(timestring, 9, 2); + const std::string minutes(timestring, 11, 2); + const std::string seconds(timestring, 13, 2); if (version == 2) { line += Rinex_Printer::rightJustify(std::to_string(glonass_gnav_ephemeris_iter->second.i_satellite_PRN), 2); line += std::string(1, ' '); - std::string year(timestring, 2, 2); + const std::string year(timestring, 2, 2); line += year; line += std::string(1, ' '); if (boost::lexical_cast(month) < 10) @@ -4548,7 +4542,7 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::mapsecond.i_satellite_PRN); - std::string year(timestring, 0, 4); + const std::string year(timestring, 0, 4); line += std::string(1, ' '); line += year; line += std::string(1, ' '); @@ -4703,13 +4697,13 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::mapsecond, bds_ephemeris_iter->second.d_Toc); - std::string timestring = boost::posix_time::to_iso_string(p_utc_time); - std::string month(timestring, 4, 2); - std::string day(timestring, 6, 2); - std::string hour(timestring, 9, 2); - std::string minutes(timestring, 11, 2); - std::string seconds(timestring, 13, 2); + const boost::posix_time::ptime p_utc_time = Rinex_Printer::compute_BDS_time(bds_ephemeris_iter->second, bds_ephemeris_iter->second.d_Toc); + const std::string timestring = boost::posix_time::to_iso_string(p_utc_time); + const std::string month(timestring, 4, 2); + const std::string day(timestring, 6, 2); + const std::string hour(timestring, 9, 2); + const std::string minutes(timestring, 11, 2); + const std::string seconds(timestring, 13, 2); line += satelliteSystem["Beidou"]; if (bds_ephemeris_iter->second.i_satellite_PRN < 10) @@ -4717,7 +4711,7 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::mapsecond.i_satellite_PRN); - std::string year(timestring, 0, 4); + const std::string year(timestring, 0, 4); line += std::string(1, ' '); line += year; line += std::string(1, ' '); @@ -5091,15 +5085,15 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Glonass_Gnav_Ephem } // -------- TIME OF FIRST OBS - boost::posix_time::ptime p_utc_time = Rinex_Printer::compute_UTC_time(eph, d_TOW_first_observation); - std::string timestring = boost::posix_time::to_iso_string(p_utc_time); - std::string year(timestring, 0, 4); - std::string month(timestring, 4, 2); - std::string day(timestring, 6, 2); - std::string hour(timestring, 9, 2); - std::string minutes(timestring, 11, 2); + const boost::posix_time::ptime p_utc_time = Rinex_Printer::compute_UTC_time(eph, d_TOW_first_observation); + const std::string timestring = boost::posix_time::to_iso_string(p_utc_time); + const std::string year(timestring, 0, 4); + const std::string month(timestring, 4, 2); + const std::string day(timestring, 6, 2); + const std::string hour(timestring, 9, 2); + const std::string minutes(timestring, 11, 2); double intpart = 0; - double seconds = p_utc_time.time_of_day().seconds() + modf(d_TOW_first_observation, &intpart); + const double seconds = p_utc_time.time_of_day().seconds() + modf(d_TOW_first_observation, &intpart); line.clear(); line += Rinex_Printer::rightJustify(year, 6); line += Rinex_Printer::rightJustify(month, 6); @@ -5448,15 +5442,15 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps // -------- TIME OF FIRST OBS line.clear(); - boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(gps_eph, d_TOW_first_observation); - std::string timestring = boost::posix_time::to_iso_string(p_gps_time); - std::string year(timestring, 0, 4); - std::string month(timestring, 4, 2); - std::string day(timestring, 6, 2); - std::string hour(timestring, 9, 2); - std::string minutes(timestring, 11, 2); - double gps_t = d_TOW_first_observation; - double seconds = fmod(gps_t, 60); + const boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(gps_eph, d_TOW_first_observation); + const std::string timestring = boost::posix_time::to_iso_string(p_gps_time); + const std::string year(timestring, 0, 4); + const std::string month(timestring, 4, 2); + const std::string day(timestring, 6, 2); + const std::string hour(timestring, 9, 2); + const std::string minutes(timestring, 11, 2); + const double gps_t = d_TOW_first_observation; + const double seconds = fmod(gps_t, 60); line += Rinex_Printer::rightJustify(year, 6); line += Rinex_Printer::rightJustify(month, 6); line += Rinex_Printer::rightJustify(day, 6); @@ -5772,15 +5766,15 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris // -------- TIME OF FIRST OBS line.clear(); - boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(gps_cnav_eph, d_TOW_first_observation); - std::string timestring = boost::posix_time::to_iso_string(p_gps_time); - std::string year(timestring, 0, 4); - std::string month(timestring, 4, 2); - std::string day(timestring, 6, 2); - std::string hour(timestring, 9, 2); - std::string minutes(timestring, 11, 2); - double gps_t = d_TOW_first_observation; - double seconds = fmod(gps_t, 60); + const boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(gps_cnav_eph, d_TOW_first_observation); + const std::string timestring = boost::posix_time::to_iso_string(p_gps_time); + const std::string year(timestring, 0, 4); + const std::string month(timestring, 4, 2); + const std::string day(timestring, 6, 2); + const std::string hour(timestring, 9, 2); + const std::string minutes(timestring, 11, 2); + const double gps_t = d_TOW_first_observation; + const double seconds = fmod(gps_t, 60); line += Rinex_Printer::rightJustify(year, 6); line += Rinex_Printer::rightJustify(month, 6); line += Rinex_Printer::rightJustify(day, 6); @@ -6135,15 +6129,15 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& // -------- TIME OF FIRST OBS line.clear(); - boost::posix_time::ptime p_galileo_time = Rinex_Printer::compute_Galileo_time(galileo_eph, d_TOW_first_observation); - std::string timestring = boost::posix_time::to_iso_string(p_galileo_time); - std::string year(timestring, 0, 4); - std::string month(timestring, 4, 2); - std::string day(timestring, 6, 2); - std::string hour(timestring, 9, 2); - std::string minutes(timestring, 11, 2); - double galileo_t = d_TOW_first_observation; - double seconds = fmod(galileo_t, 60); + const boost::posix_time::ptime p_galileo_time = Rinex_Printer::compute_Galileo_time(galileo_eph, d_TOW_first_observation); + const std::string timestring = boost::posix_time::to_iso_string(p_galileo_time); + const std::string year(timestring, 0, 4); + const std::string month(timestring, 4, 2); + const std::string day(timestring, 6, 2); + const std::string hour(timestring, 9, 2); + const std::string minutes(timestring, 11, 2); + const double galileo_t = d_TOW_first_observation; + const double seconds = fmod(galileo_t, 60); line += Rinex_Printer::rightJustify(year, 6); line += Rinex_Printer::rightJustify(month, 6); line += Rinex_Printer::rightJustify(day, 6); @@ -6397,15 +6391,15 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph // -------- TIME OF FIRST OBS line.clear(); - boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(eph, d_TOW_first_observation); - std::string timestring = boost::posix_time::to_iso_string(p_gps_time); - std::string year(timestring, 0, 4); - std::string month(timestring, 4, 2); - std::string day(timestring, 6, 2); - std::string hour(timestring, 9, 2); - std::string minutes(timestring, 11, 2); - double gps_t = d_TOW_first_observation; - double seconds = fmod(gps_t, 60); + const boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(eph, d_TOW_first_observation); + const std::string timestring = boost::posix_time::to_iso_string(p_gps_time); + const std::string year(timestring, 0, 4); + const std::string month(timestring, 4, 2); + const std::string day(timestring, 6, 2); + const std::string hour(timestring, 9, 2); + const std::string minutes(timestring, 11, 2); + const double gps_t = d_TOW_first_observation; + const double seconds = fmod(gps_t, 60); line += Rinex_Printer::rightJustify(year, 6); line += Rinex_Printer::rightJustify(month, 6); line += Rinex_Printer::rightJustify(day, 6); @@ -6645,15 +6639,15 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris // -------- TIME OF FIRST OBS line.clear(); - boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(eph, d_TOW_first_observation); - std::string timestring = boost::posix_time::to_iso_string(p_gps_time); - std::string year(timestring, 0, 4); - std::string month(timestring, 4, 2); - std::string day(timestring, 6, 2); - std::string hour(timestring, 9, 2); - std::string minutes(timestring, 11, 2); - double gps_t = d_TOW_first_observation; - double seconds = fmod(gps_t, 60); + const boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(eph, d_TOW_first_observation); + const std::string timestring = boost::posix_time::to_iso_string(p_gps_time); + const std::string year(timestring, 0, 4); + const std::string month(timestring, 4, 2); + const std::string day(timestring, 6, 2); + const std::string hour(timestring, 9, 2); + const std::string minutes(timestring, 11, 2); + const double gps_t = d_TOW_first_observation; + const double seconds = fmod(gps_t, 60); line += Rinex_Printer::rightJustify(year, 6); line += Rinex_Printer::rightJustify(month, 6); line += Rinex_Printer::rightJustify(day, 6); @@ -6920,15 +6914,15 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph // -------- TIME OF FIRST OBS line.clear(); - boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(eph, d_TOW_first_observation); - std::string timestring = boost::posix_time::to_iso_string(p_gps_time); - std::string year(timestring, 0, 4); - std::string month(timestring, 4, 2); - std::string day(timestring, 6, 2); - std::string hour(timestring, 9, 2); - std::string minutes(timestring, 11, 2); - double gps_t = d_TOW_first_observation; - double seconds = fmod(gps_t, 60); + const boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(eph, d_TOW_first_observation); + const std::string timestring = boost::posix_time::to_iso_string(p_gps_time); + const std::string year(timestring, 0, 4); + const std::string month(timestring, 4, 2); + const std::string day(timestring, 6, 2); + const std::string hour(timestring, 9, 2); + const std::string minutes(timestring, 11, 2); + const double gps_t = d_TOW_first_observation; + const double seconds = fmod(gps_t, 60); line += Rinex_Printer::rightJustify(year, 6); line += Rinex_Printer::rightJustify(month, 6); line += Rinex_Printer::rightJustify(day, 6); @@ -7273,15 +7267,15 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps // -------- TIME OF FIRST OBS line.clear(); - boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(gps_eph, d_TOW_first_observation); - std::string timestring = boost::posix_time::to_iso_string(p_gps_time); - std::string year(timestring, 0, 4); - std::string month(timestring, 4, 2); - std::string day(timestring, 6, 2); - std::string hour(timestring, 9, 2); - std::string minutes(timestring, 11, 2); - double gps_t = d_TOW_first_observation; - double seconds = fmod(gps_t, 60); + const boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(gps_eph, d_TOW_first_observation); + const std::string timestring = boost::posix_time::to_iso_string(p_gps_time); + const std::string year(timestring, 0, 4); + const std::string month(timestring, 4, 2); + const std::string day(timestring, 6, 2); + const std::string hour(timestring, 9, 2); + const std::string minutes(timestring, 11, 2); + const double gps_t = d_TOW_first_observation; + const double seconds = fmod(gps_t, 60); line += Rinex_Printer::rightJustify(year, 6); line += Rinex_Printer::rightJustify(month, 6); line += Rinex_Printer::rightJustify(day, 6); @@ -7594,15 +7588,15 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris // -------- TIME OF FIRST OBS line.clear(); - boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(eph_cnav, d_TOW_first_observation); - std::string timestring = boost::posix_time::to_iso_string(p_gps_time); - std::string year(timestring, 0, 4); - std::string month(timestring, 4, 2); - std::string day(timestring, 6, 2); - std::string hour(timestring, 9, 2); - std::string minutes(timestring, 11, 2); - double gps_t = d_TOW_first_observation; - double seconds = fmod(gps_t, 60); + const boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(eph_cnav, d_TOW_first_observation); + const std::string timestring = boost::posix_time::to_iso_string(p_gps_time); + const std::string year(timestring, 0, 4); + const std::string month(timestring, 4, 2); + const std::string day(timestring, 6, 2); + const std::string hour(timestring, 9, 2); + const std::string minutes(timestring, 11, 2); + const double gps_t = d_TOW_first_observation; + const double seconds = fmod(gps_t, 60); line += Rinex_Printer::rightJustify(year, 6); line += Rinex_Printer::rightJustify(month, 6); line += Rinex_Printer::rightJustify(day, 6); @@ -7856,15 +7850,15 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& // -------- TIME OF FIRST OBS line.clear(); - boost::posix_time::ptime p_galileo_time = Rinex_Printer::compute_Galileo_time(eph, d_TOW_first_observation); - std::string timestring = boost::posix_time::to_iso_string(p_galileo_time); - std::string year(timestring, 0, 4); - std::string month(timestring, 4, 2); - std::string day(timestring, 6, 2); - std::string hour(timestring, 9, 2); - std::string minutes(timestring, 11, 2); - double galileo_t = d_TOW_first_observation; - double seconds = fmod(galileo_t, 60); + const boost::posix_time::ptime p_galileo_time = Rinex_Printer::compute_Galileo_time(eph, d_TOW_first_observation); + const std::string timestring = boost::posix_time::to_iso_string(p_galileo_time); + const std::string year(timestring, 0, 4); + const std::string month(timestring, 4, 2); + const std::string day(timestring, 6, 2); + const std::string hour(timestring, 9, 2); + const std::string minutes(timestring, 11, 2); + const double galileo_t = d_TOW_first_observation; + const double seconds = fmod(galileo_t, 60); line += Rinex_Printer::rightJustify(year, 6); line += Rinex_Printer::rightJustify(month, 6); line += Rinex_Printer::rightJustify(day, 6); @@ -8151,15 +8145,15 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps // -------- TIME OF FIRST OBS line.clear(); - boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(gps_eph, d_TOW_first_observation); - std::string timestring = boost::posix_time::to_iso_string(p_gps_time); - std::string year(timestring, 0, 4); - std::string month(timestring, 4, 2); - std::string day(timestring, 6, 2); - std::string hour(timestring, 9, 2); - std::string minutes(timestring, 11, 2); - double gps_t = d_TOW_first_observation; - double seconds = fmod(gps_t, 60); + const boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(gps_eph, d_TOW_first_observation); + const std::string timestring = boost::posix_time::to_iso_string(p_gps_time); + const std::string year(timestring, 0, 4); + const std::string month(timestring, 4, 2); + const std::string day(timestring, 6, 2); + const std::string hour(timestring, 9, 2); + const std::string minutes(timestring, 11, 2); + const double gps_t = d_TOW_first_observation; + const double seconds = fmod(gps_t, 60); line += Rinex_Printer::rightJustify(year, 6); line += Rinex_Printer::rightJustify(month, 6); line += Rinex_Printer::rightJustify(day, 6); @@ -8381,15 +8375,15 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Beidou_Dnav_Epheme // -------- TIME OF FIRST OBS line.clear(); - boost::posix_time::ptime p_bds_time = Rinex_Printer::compute_BDS_time(eph, d_TOW_first_observation); - std::string timestring = boost::posix_time::to_iso_string(p_bds_time); - std::string year(timestring, 0, 4); - std::string month(timestring, 4, 2); - std::string day(timestring, 6, 2); - std::string hour(timestring, 9, 2); - std::string minutes(timestring, 11, 2); + const boost::posix_time::ptime p_bds_time = Rinex_Printer::compute_BDS_time(eph, d_TOW_first_observation); + const std::string timestring = boost::posix_time::to_iso_string(p_bds_time); + const std::string year(timestring, 0, 4); + const std::string month(timestring, 4, 2); + const std::string day(timestring, 6, 2); + const std::string hour(timestring, 9, 2); + const std::string minutes(timestring, 11, 2); double beidou_t = d_TOW_first_observation; - double seconds = fmod(beidou_t, 60); + const double seconds = fmod(beidou_t, 60); line += Rinex_Printer::rightJustify(year, 6); line += Rinex_Printer::rightJustify(month, 6); line += Rinex_Printer::rightJustify(day, 6); @@ -8692,21 +8686,21 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Glonass_Gnav_Ephemeri { } - boost::posix_time::ptime p_glonass_time = Rinex_Printer::compute_UTC_time(eph, obs_time); - std::string timestring = boost::posix_time::to_iso_string(p_glonass_time); + const boost::posix_time::ptime p_glonass_time = Rinex_Printer::compute_UTC_time(eph, obs_time); + const std::string timestring = boost::posix_time::to_iso_string(p_glonass_time); // double utc_t = nav_msg.utc_time(nav_msg.sv_clock_correction(obs_time)); - // double gps_t = eph.sv_clock_correction(obs_time); + // const double gps_t = eph.sv_clock_correction(obs_time); - std::string month(timestring, 4, 2); - std::string day(timestring, 6, 2); - std::string hour(timestring, 9, 2); - std::string minutes(timestring, 11, 2); - double utc_sec = modf(obs_time, &int_sec) + p_glonass_time.time_of_day().seconds(); + const std::string month(timestring, 4, 2); + const std::string day(timestring, 6, 2); + const std::string hour(timestring, 9, 2); + const std::string minutes(timestring, 11, 2); + const double utc_sec = modf(obs_time, &int_sec) + p_glonass_time.time_of_day().seconds(); if (version == 2) { line.clear(); - std::string year(timestring, 2, 2); + const std::string year(timestring, 2, 2); line += std::string(1, ' '); line += year; line += std::string(1, ' '); @@ -8792,7 +8786,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Glonass_Gnav_Ephemeri // } // Signal Strength Indicator (SSI) - int32_t ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); + const int32_t ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // GLONASS L1 CA PHASE lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Carrier_phase_rads / TWO_PI, 3), 14); @@ -8828,7 +8822,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Glonass_Gnav_Ephemeri if (version == 3) { - std::string year(timestring, 0, 4); + const std::string year(timestring, 0, 4); line += std::string(1, '>'); line += std::string(1, ' '); line += year; @@ -8897,7 +8891,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Glonass_Gnav_Ephemeri // } // Signal Strength Indicator (SSI) - int32_t ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); + const int32_t ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // GLONASS L1 CA PHASE @@ -8946,21 +8940,21 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep std::string line; // -------- EPOCH record - boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(gps_eph, gps_obs_time); - std::string timestring = boost::posix_time::to_iso_string(p_gps_time); + const boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(gps_eph, gps_obs_time); + const std::string timestring = boost::posix_time::to_iso_string(p_gps_time); // double utc_t = nav_msg.utc_time(nav_msg.sv_clock_correction(obs_time)); - // double gps_t = eph.sv_clock_correction(obs_time); - double gps_t = gps_obs_time; + // const double gps_t = eph.sv_clock_correction(obs_time); + const double gps_t = gps_obs_time; - std::string month(timestring, 4, 2); - std::string day(timestring, 6, 2); - std::string hour(timestring, 9, 2); - std::string minutes(timestring, 11, 2); + const std::string month(timestring, 4, 2); + const std::string day(timestring, 6, 2); + const std::string hour(timestring, 9, 2); + const std::string minutes(timestring, 11, 2); if (version == 2) { line.clear(); - std::string year(timestring, 2, 2); + const std::string year(timestring, 2, 2); line += std::string(1, ' '); line += year; line += std::string(1, ' '); @@ -8988,7 +8982,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep line += std::string(1, ' '); line += minutes; line += std::string(1, ' '); - double second_ = fmod(gps_t, 60); + const double second_ = fmod(gps_t, 60); if (second_ < 10) { line += std::string(1, ' '); @@ -9000,7 +8994,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep } if (version == 3) { - std::string year(timestring, 0, 4); + const std::string year(timestring, 0, 4); line += std::string(1, '>'); line += std::string(1, ' '); line += year; @@ -9014,7 +9008,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep line += minutes; line += std::string(1, ' '); - double seconds = fmod(gps_t, 60); + const double seconds = fmod(gps_t, 60); // Add extra 0 if seconds are < 10 if (seconds < 10) { @@ -9060,7 +9054,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep observables_iter != observablesR1C.cend(); observables_iter++) { - uint32_t prn_ = observables_iter->second.PRN; + const uint32_t prn_ = observables_iter->second.PRN; total_glo_map.insert(std::pair(prn_, observables_iter->second)); it = available_glo_prns.find(prn_); if (it == available_glo_prns.end()) @@ -9073,7 +9067,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep observables_iter != observablesR2C.cend(); observables_iter++) { - uint32_t prn_ = observables_iter->second.PRN; + const uint32_t prn_ = observables_iter->second.PRN; total_glo_map.insert(std::pair(prn_, observables_iter->second)); it = available_glo_prns.find(prn_); if (it == available_glo_prns.end()) @@ -9082,9 +9076,9 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep } } - int32_t numGloSatellitesObserved = available_glo_prns.size(); - int32_t numGpsSatellitesObserved = observablesG1C.size(); - int32_t numSatellitesObserved = numGloSatellitesObserved + numGpsSatellitesObserved; + const int32_t numGloSatellitesObserved = available_glo_prns.size(); + const int32_t numGpsSatellitesObserved = observablesG1C.size(); + const int32_t numSatellitesObserved = numGloSatellitesObserved + numGpsSatellitesObserved; line += Rinex_Printer::rightJustify(std::to_string(numSatellitesObserved), 3); if (version == 2) { @@ -9172,7 +9166,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep // } // Signal Strength Indicator (SSI) - int32_t ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); + const int32_t ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // PHASE @@ -9243,7 +9237,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep // } // Signal Strength Indicator (SSI) - int32_t ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); + const int32_t ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // GLONASS CARRIER PHASE @@ -9291,18 +9285,18 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& g std::string line; // -------- EPOCH record - boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(gps_eph, gps_obs_time); - std::string timestring = boost::posix_time::to_iso_string(p_gps_time); + const boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(gps_eph, gps_obs_time); + const std::string timestring = boost::posix_time::to_iso_string(p_gps_time); // double utc_t = nav_msg.utc_time(nav_msg.sv_clock_correction(obs_time)); - // double gps_t = eph.sv_clock_correction(obs_time); - double gps_t = gps_obs_time; + // const double gps_t = eph.sv_clock_correction(obs_time); + const double gps_t = gps_obs_time; - std::string month(timestring, 4, 2); - std::string day(timestring, 6, 2); - std::string hour(timestring, 9, 2); - std::string minutes(timestring, 11, 2); + const std::string month(timestring, 4, 2); + const std::string day(timestring, 6, 2); + const std::string hour(timestring, 9, 2); + const std::string minutes(timestring, 11, 2); - std::string year(timestring, 0, 4); + const std::string year(timestring, 0, 4); line += std::string(1, '>'); line += std::string(1, ' '); line += year; @@ -9361,7 +9355,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& g observables_iter != observablesR1C.cend(); observables_iter++) { - uint32_t prn_ = observables_iter->second.PRN; + const uint32_t prn_ = observables_iter->second.PRN; total_glo_map.insert(std::pair(prn_, observables_iter->second)); it = available_glo_prns.find(prn_); if (it == available_glo_prns.end()) @@ -9374,7 +9368,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& g observables_iter != observablesR2C.cend(); observables_iter++) { - uint32_t prn_ = observables_iter->second.PRN; + const uint32_t prn_ = observables_iter->second.PRN; total_glo_map.insert(std::pair(prn_, observables_iter->second)); it = available_glo_prns.find(prn_); if (it == available_glo_prns.end()) @@ -9383,9 +9377,9 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& g } } - int32_t numGloSatellitesObserved = available_glo_prns.size(); - int32_t numGpsSatellitesObserved = observablesG2S.size(); - int32_t numSatellitesObserved = numGloSatellitesObserved + numGpsSatellitesObserved; + const int32_t numGloSatellitesObserved = available_glo_prns.size(); + const int32_t numGpsSatellitesObserved = observablesG2S.size(); + const int32_t numSatellitesObserved = numGloSatellitesObserved + numGpsSatellitesObserved; line += Rinex_Printer::rightJustify(std::to_string(numSatellitesObserved), 3); line += std::string(80 - line.size(), ' '); @@ -9432,7 +9426,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& g // } // Signal Strength Indicator (SSI) - int32_t ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); + const int32_t ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // PHASE @@ -9501,7 +9495,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& g // } // Signal Strength Indicator (SSI) - int32_t ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); + const int32_t ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // GLONASS CARRIER PHASE @@ -9548,18 +9542,18 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ga } // avoid warning, not needed std::string line; - boost::posix_time::ptime p_galileo_time = Rinex_Printer::compute_Galileo_time(galileo_eph, galileo_obs_time); - std::string timestring = boost::posix_time::to_iso_string(p_galileo_time); + const boost::posix_time::ptime p_galileo_time = Rinex_Printer::compute_Galileo_time(galileo_eph, galileo_obs_time); + const std::string timestring = boost::posix_time::to_iso_string(p_galileo_time); // double utc_t = nav_msg.utc_time(nav_msg.sv_clock_correction(obs_time)); - // double gps_t = eph.sv_clock_correction(obs_time); - double galileo_t = galileo_obs_time; + // const double gps_t = eph.sv_clock_correction(obs_time); + const double galileo_t = galileo_obs_time; - std::string month(timestring, 4, 2); - std::string day(timestring, 6, 2); - std::string hour(timestring, 9, 2); - std::string minutes(timestring, 11, 2); + const std::string month(timestring, 4, 2); + const std::string day(timestring, 6, 2); + const std::string hour(timestring, 9, 2); + const std::string minutes(timestring, 11, 2); - std::string year(timestring, 0, 4); + const std::string year(timestring, 0, 4); line += std::string(1, '>'); line += std::string(1, ' '); line += year; @@ -9573,7 +9567,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ga line += minutes; line += std::string(1, ' '); - double seconds = fmod(galileo_t, 60); + const double seconds = fmod(galileo_t, 60); // Add extra 0 if seconds are < 10 if (seconds < 10) { @@ -9619,7 +9613,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ga observables_iter != observablesR1C.cend(); observables_iter++) { - uint32_t prn_ = observables_iter->second.PRN; + const uint32_t prn_ = observables_iter->second.PRN; total_glo_map.insert(std::pair(prn_, observables_iter->second)); it = available_glo_prns.find(prn_); if (it == available_glo_prns.end()) @@ -9631,7 +9625,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ga observables_iter != observablesR2C.cend(); observables_iter++) { - uint32_t prn_ = observables_iter->second.PRN; + const uint32_t prn_ = observables_iter->second.PRN; total_glo_map.insert(std::pair(prn_, observables_iter->second)); it = available_glo_prns.find(prn_); if (it == available_glo_prns.end()) @@ -9640,9 +9634,9 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ga } } - int32_t numGloSatellitesObserved = available_glo_prns.size(); - int32_t numGalSatellitesObserved = observablesE1B.size(); - int32_t numSatellitesObserved = numGalSatellitesObserved + numGloSatellitesObserved; + const int32_t numGloSatellitesObserved = available_glo_prns.size(); + const int32_t numGalSatellitesObserved = observablesE1B.size(); + const int32_t numSatellitesObserved = numGalSatellitesObserved + numGloSatellitesObserved; line += Rinex_Printer::rightJustify(std::to_string(numSatellitesObserved), 3); // Receiver clock offset (optional) @@ -9688,7 +9682,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ga // } // Signal Strength Indicator (SSI) - int32_t ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); + const int32_t ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // PHASE @@ -9754,7 +9748,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ga // } // Signal Strength Indicator (SSI) - int32_t ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); + const int32_t ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // GLONASS CARRIER PHASE @@ -9799,21 +9793,21 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c // RINEX observations timestamps are GPS timestamps. std::string line; - boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(eph, obs_time); - std::string timestring = boost::posix_time::to_iso_string(p_gps_time); + const boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(eph, obs_time); + const std::string timestring = boost::posix_time::to_iso_string(p_gps_time); // double utc_t = nav_msg.utc_time(nav_msg.sv_clock_correction(obs_time)); - // double gps_t = eph.sv_clock_correction(obs_time); - double gps_t = obs_time; + // const double gps_t = eph.sv_clock_correction(obs_time); + const double gps_t = obs_time; - std::string month(timestring, 4, 2); - std::string day(timestring, 6, 2); - std::string hour(timestring, 9, 2); - std::string minutes(timestring, 11, 2); + const std::string month(timestring, 4, 2); + const std::string day(timestring, 6, 2); + const std::string hour(timestring, 9, 2); + const std::string minutes(timestring, 11, 2); if (version == 2) { line.clear(); - std::string year(timestring, 2, 2); + const std::string year(timestring, 2, 2); line += std::string(1, ' '); line += year; line += std::string(1, ' '); @@ -9841,7 +9835,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c line += std::string(1, ' '); line += minutes; line += std::string(1, ' '); - double second_ = fmod(gps_t, 60); + const double second_ = fmod(gps_t, 60); if (second_ < 10) { line += std::string(1, ' '); @@ -9900,7 +9894,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c // } // Signal Strength Indicator (SSI) - int32_t ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); + const int32_t ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // GPS L1 CA PHASE lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Carrier_phase_rads / TWO_PI, 3), 14); @@ -9936,7 +9930,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c if (version == 3) { - std::string year(timestring, 0, 4); + const std::string year(timestring, 0, 4); line += std::string(1, '>'); line += std::string(1, ' '); line += year; @@ -9950,7 +9944,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c line += minutes; line += std::string(1, ' '); - double seconds = fmod(gps_t, 60); + const double seconds = fmod(gps_t, 60); // Add extra 0 if seconds are < 10 if (seconds < 10) { @@ -10006,7 +10000,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c // } // Signal Strength Indicator (SSI) - int32_t ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); + const int32_t ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // GPS L1 CA PHASE @@ -10052,18 +10046,18 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e // RINEX observations timestamps are GPS timestamps. std::string line; - boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(eph, obs_time); - std::string timestring = boost::posix_time::to_iso_string(p_gps_time); + const boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(eph, obs_time); + const std::string timestring = boost::posix_time::to_iso_string(p_gps_time); // double utc_t = nav_msg.utc_time(nav_msg.sv_clock_correction(obs_time)); - // double gps_t = eph.sv_clock_correction(obs_time); - double gps_t = obs_time; + // const double gps_t = eph.sv_clock_correction(obs_time); + const double gps_t = obs_time; - std::string month(timestring, 4, 2); - std::string day(timestring, 6, 2); - std::string hour(timestring, 9, 2); - std::string minutes(timestring, 11, 2); + const std::string month(timestring, 4, 2); + const std::string day(timestring, 6, 2); + const std::string hour(timestring, 9, 2); + const std::string minutes(timestring, 11, 2); - std::string year(timestring, 0, 4); + const std::string year(timestring, 0, 4); line += std::string(1, '>'); line += std::string(1, ' '); line += year; @@ -10077,7 +10071,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e line += minutes; line += std::string(1, ' '); - double seconds = fmod(gps_t, 60); + const double seconds = fmod(gps_t, 60); // Add extra 0 if seconds are < 10 if (seconds < 10) { @@ -10134,7 +10128,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e // } // Signal Strength Indicator (SSI) - int32_t ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); + const int32_t ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // GPS L2 PHASE @@ -10182,18 +10176,18 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c // RINEX observations timestamps are GPS timestamps. std::string line; - boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(eph, obs_time); - std::string timestring = boost::posix_time::to_iso_string(p_gps_time); + const boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(eph, obs_time); + const std::string timestring = boost::posix_time::to_iso_string(p_gps_time); // double utc_t = nav_msg.utc_time(nav_msg.sv_clock_correction(obs_time)); - // double gps_t = eph.sv_clock_correction(obs_time); - double gps_t = obs_time; + // const double gps_t = eph.sv_clock_correction(obs_time); + const double gps_t = obs_time; - std::string month(timestring, 4, 2); - std::string day(timestring, 6, 2); - std::string hour(timestring, 9, 2); - std::string minutes(timestring, 11, 2); + const std::string month(timestring, 4, 2); + const std::string day(timestring, 6, 2); + const std::string hour(timestring, 9, 2); + const std::string minutes(timestring, 11, 2); - std::string year(timestring, 0, 4); + const std::string year(timestring, 0, 4); line += std::string(1, '>'); line += std::string(1, ' '); line += year; @@ -10207,7 +10201,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c line += minutes; line += std::string(1, ' '); - double seconds = fmod(gps_t, 60); + const double seconds = fmod(gps_t, 60); // Add extra 0 if seconds are < 10 if (seconds < 10) { @@ -10289,7 +10283,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c observables_iter != observablesL1.cend(); observables_iter++) { - uint32_t prn_ = observables_iter->second.PRN; + const uint32_t prn_ = observables_iter->second.PRN; it = available_prns.find(prn_); if (it == available_prns.end()) { @@ -10301,7 +10295,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c observables_iter != observablesL2.cend(); observables_iter++) { - uint32_t prn_ = observables_iter->second.PRN; + const uint32_t prn_ = observables_iter->second.PRN; it = available_prns.find(prn_); if (it == available_prns.end()) { @@ -10313,7 +10307,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c observables_iter != observablesL5.cend(); observables_iter++) { - uint32_t prn_ = observables_iter->second.PRN; + const uint32_t prn_ = observables_iter->second.PRN; it = available_prns.find(prn_); if (it == available_prns.end()) { @@ -10321,7 +10315,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c } } - int32_t numSatellitesObserved = available_prns.size(); + const int32_t numSatellitesObserved = available_prns.size(); line += Rinex_Printer::rightJustify(std::to_string(numSatellitesObserved), 3); // Receiver clock offset (optional) // line += rightJustify(asString(clockOffset, 12), 15); @@ -10370,7 +10364,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c // } // Signal Strength Indicator (SSI) - int32_t ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); + const int32_t ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // GPS CARRIER PHASE @@ -10416,18 +10410,18 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ep // See https://gage.upc.edu/sites/default/files/gLAB/HTML/Observation_Rinex_v3.01.html std::string line; - boost::posix_time::ptime p_galileo_time = Rinex_Printer::compute_Galileo_time(eph, obs_time); - std::string timestring = boost::posix_time::to_iso_string(p_galileo_time); + const boost::posix_time::ptime p_galileo_time = Rinex_Printer::compute_Galileo_time(eph, obs_time); + const std::string timestring = boost::posix_time::to_iso_string(p_galileo_time); // double utc_t = nav_msg.utc_time(nav_msg.sv_clock_correction(obs_time)); - // double gps_t = eph.sv_clock_correction(obs_time); - double galileo_t = obs_time; + // const double gps_t = eph.sv_clock_correction(obs_time); + const double galileo_t = obs_time; - std::string month(timestring, 4, 2); - std::string day(timestring, 6, 2); - std::string hour(timestring, 9, 2); - std::string minutes(timestring, 11, 2); + const std::string month(timestring, 4, 2); + const std::string day(timestring, 6, 2); + const std::string hour(timestring, 9, 2); + const std::string minutes(timestring, 11, 2); - std::string year(timestring, 0, 4); + const std::string year(timestring, 0, 4); line += std::string(1, '>'); line += std::string(1, ' '); line += year; @@ -10441,7 +10435,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ep line += minutes; line += std::string(1, ' '); - double seconds = fmod(galileo_t, 60); + const double seconds = fmod(galileo_t, 60); // Add extra 0 if seconds are < 10 if (seconds < 10) { @@ -10492,7 +10486,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ep observables_iter != observablesE1B.cend(); observables_iter++) { - uint32_t prn_ = observables_iter->second.PRN; + const uint32_t prn_ = observables_iter->second.PRN; total_map.insert(std::pair(prn_, observables_iter->second)); it = available_prns.find(prn_); if (it == available_prns.end()) @@ -10507,7 +10501,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ep observables_iter != observablesE5A.cend(); observables_iter++) { - uint32_t prn_ = observables_iter->second.PRN; + const uint32_t prn_ = observables_iter->second.PRN; it = available_prns.find(prn_); if (it == available_prns.end()) { @@ -10532,7 +10526,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ep observables_iter != observablesE5B.cend(); observables_iter++) { - uint32_t prn_ = observables_iter->second.PRN; + const uint32_t prn_ = observables_iter->second.PRN; it = available_prns.find(prn_); if (it == available_prns.end()) { @@ -10578,7 +10572,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ep total_map.insert(std::pair(prn_, observables_iter->second)); } } - int32_t numSatellitesObserved = available_prns.size(); + const int32_t numSatellitesObserved = available_prns.size(); line += Rinex_Printer::rightJustify(std::to_string(numSatellitesObserved), 3); // Receiver clock offset (optional) // line += rightJustify(asString(clockOffset, 12), 15); @@ -10616,7 +10610,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ep // } // Signal Strength Indicator (SSI) - int32_t ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); + const int32_t ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // Galileo CARRIER PHASE @@ -10663,18 +10657,18 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep } // avoid warning, not needed std::string line; - boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(gps_eph, gps_obs_time); - std::string timestring = boost::posix_time::to_iso_string(p_gps_time); + const boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(gps_eph, gps_obs_time); + const std::string timestring = boost::posix_time::to_iso_string(p_gps_time); // double utc_t = nav_msg.utc_time(nav_msg.sv_clock_correction(obs_time)); // double gps_t = eph.sv_clock_correction(obs_time); - double gps_t = gps_obs_time; + const double gps_t = gps_obs_time; - std::string month(timestring, 4, 2); - std::string day(timestring, 6, 2); - std::string hour(timestring, 9, 2); - std::string minutes(timestring, 11, 2); + const std::string month(timestring, 4, 2); + const std::string day(timestring, 6, 2); + const std::string hour(timestring, 9, 2); + const std::string minutes(timestring, 11, 2); - std::string year(timestring, 0, 4); + const std::string year(timestring, 0, 4); line += std::string(1, '>'); line += std::string(1, ' '); line += year; @@ -10688,7 +10682,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep line += minutes; line += std::string(1, ' '); - double seconds = fmod(gps_t, 60); + const double seconds = fmod(gps_t, 60); // Add extra 0 if seconds are < 10 if (seconds < 10) { @@ -10739,7 +10733,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep observables_iter != observablesE1B.cend(); observables_iter++) { - uint32_t prn_ = observables_iter->second.PRN; + const uint32_t prn_ = observables_iter->second.PRN; total_gal_map.insert(std::pair(prn_, observables_iter->second)); it = available_gal_prns.find(prn_); if (it == available_gal_prns.end()) @@ -10752,7 +10746,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep observables_iter != observablesE5A.cend(); observables_iter++) { - uint32_t prn_ = observables_iter->second.PRN; + const uint32_t prn_ = observables_iter->second.PRN; total_gal_map.insert(std::pair(prn_, observables_iter->second)); it = available_gal_prns.find(prn_); if (it == available_gal_prns.end()) @@ -10765,7 +10759,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep observables_iter != observablesE5B.cend(); observables_iter++) { - uint32_t prn_ = observables_iter->second.PRN; + const uint32_t prn_ = observables_iter->second.PRN; total_gal_map.insert(std::pair(prn_, observables_iter->second)); it = available_gal_prns.find(prn_); if (it == available_gal_prns.end()) @@ -10774,9 +10768,9 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep } } - int32_t numGalSatellitesObserved = available_gal_prns.size(); - int32_t numGpsSatellitesObserved = observablesG1C.size(); - int32_t numSatellitesObserved = numGalSatellitesObserved + numGpsSatellitesObserved; + const int32_t numGalSatellitesObserved = available_gal_prns.size(); + const int32_t numGpsSatellitesObserved = observablesG1C.size(); + const int32_t numSatellitesObserved = numGalSatellitesObserved + numGpsSatellitesObserved; line += Rinex_Printer::rightJustify(std::to_string(numSatellitesObserved), 3); // Receiver clock offset (optional) @@ -10822,7 +10816,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep // } // Signal Strength Indicator (SSI) - int32_t ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); + const int32_t ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // PHASE @@ -10888,7 +10882,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep // } // Signal Strength Indicator (SSI) - int32_t ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); + const int32_t ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // Galileo CARRIER PHASE @@ -10935,18 +10929,18 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e } // avoid warning, not needed std::string line; - boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(eph, gps_obs_time); - std::string timestring = boost::posix_time::to_iso_string(p_gps_time); + const boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(eph, gps_obs_time); + const std::string timestring = boost::posix_time::to_iso_string(p_gps_time); // double utc_t = nav_msg.utc_time(nav_msg.sv_clock_correction(obs_time)); // double gps_t = eph.sv_clock_correction(obs_time); - double gps_t = gps_obs_time; + const double gps_t = gps_obs_time; - std::string month(timestring, 4, 2); - std::string day(timestring, 6, 2); - std::string hour(timestring, 9, 2); - std::string minutes(timestring, 11, 2); + const std::string month(timestring, 4, 2); + const std::string day(timestring, 6, 2); + const std::string hour(timestring, 9, 2); + const std::string minutes(timestring, 11, 2); - std::string year(timestring, 0, 4); + const std::string year(timestring, 0, 4); line += std::string(1, '>'); line += std::string(1, ' '); line += year; @@ -10960,7 +10954,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e line += minutes; line += std::string(1, ' '); - double seconds = fmod(gps_t, 60); + const double seconds = fmod(gps_t, 60); // Add extra 0 if seconds are < 10 if (seconds < 10) { @@ -11018,7 +11012,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e observables_iter != observablesE1B.cend(); observables_iter++) { - uint32_t prn_ = observables_iter->second.PRN; + const uint32_t prn_ = observables_iter->second.PRN; total_gal_map.insert(std::pair(prn_, observables_iter->second)); it = available_gal_prns.find(prn_); if (it == available_gal_prns.end()) @@ -11031,7 +11025,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e observables_iter != observablesE5A.cend(); observables_iter++) { - uint32_t prn_ = observables_iter->second.PRN; + const uint32_t prn_ = observables_iter->second.PRN; total_gal_map.insert(std::pair(prn_, observables_iter->second)); it = available_gal_prns.find(prn_); if (it == available_gal_prns.end()) @@ -11044,7 +11038,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e observables_iter != observablesE5B.cend(); observables_iter++) { - uint32_t prn_ = observables_iter->second.PRN; + const uint32_t prn_ = observables_iter->second.PRN; total_gal_map.insert(std::pair(prn_, observables_iter->second)); it = available_gal_prns.find(prn_); if (it == available_gal_prns.end()) @@ -11057,7 +11051,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e observables_iter != observablesG2S.cend(); observables_iter++) { - uint32_t prn_ = observables_iter->second.PRN; + const uint32_t prn_ = observables_iter->second.PRN; total_gps_map.insert(std::pair(prn_, observables_iter->second)); it = available_gps_prns.find(prn_); if (it == available_gps_prns.end()) @@ -11070,7 +11064,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e observables_iter != observablesGL5.cend(); observables_iter++) { - uint32_t prn_ = observables_iter->second.PRN; + const uint32_t prn_ = observables_iter->second.PRN; total_gps_map.insert(std::pair(prn_, observables_iter->second)); it = available_gps_prns.find(prn_); if (it == available_gps_prns.end()) @@ -11079,9 +11073,9 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e } } - int32_t numGalSatellitesObserved = available_gal_prns.size(); - int32_t numGpsSatellitesObserved = available_gps_prns.size(); - int32_t numSatellitesObserved = numGalSatellitesObserved + numGpsSatellitesObserved; + const int32_t numGalSatellitesObserved = available_gal_prns.size(); + const int32_t numGpsSatellitesObserved = available_gps_prns.size(); + const int32_t numSatellitesObserved = numGalSatellitesObserved + numGpsSatellitesObserved; line += Rinex_Printer::rightJustify(std::to_string(numSatellitesObserved), 3); // Receiver clock offset (optional) @@ -11123,7 +11117,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e // } // Signal Strength Indicator (SSI) - int32_t ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); + const int32_t ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // CARRIER PHASE @@ -11185,7 +11179,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e // } // Signal Strength Indicator (SSI) - int32_t ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); + const int32_t ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // Galileo CARRIER PHASE @@ -11232,18 +11226,18 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep } // avoid warning, not needed std::string line; - boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(gps_eph, gps_obs_time); - std::string timestring = boost::posix_time::to_iso_string(p_gps_time); + const boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(gps_eph, gps_obs_time); + const std::string timestring = boost::posix_time::to_iso_string(p_gps_time); // double utc_t = nav_msg.utc_time(nav_msg.sv_clock_correction(obs_time)); // double gps_t = eph.sv_clock_correction(obs_time); - double gps_t = gps_obs_time; + const double gps_t = gps_obs_time; - std::string month(timestring, 4, 2); - std::string day(timestring, 6, 2); - std::string hour(timestring, 9, 2); - std::string minutes(timestring, 11, 2); + const std::string month(timestring, 4, 2); + const std::string day(timestring, 6, 2); + const std::string hour(timestring, 9, 2); + const std::string minutes(timestring, 11, 2); - std::string year(timestring, 0, 4); + const std::string year(timestring, 0, 4); line += std::string(1, '>'); line += std::string(1, ' '); line += year; @@ -11257,7 +11251,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep line += minutes; line += std::string(1, ' '); - double seconds = fmod(gps_t, 60); + const double seconds = fmod(gps_t, 60); // Add extra 0 if seconds are < 10 if (seconds < 10) { @@ -11320,7 +11314,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep observables_iter != observablesE1B.cend(); observables_iter++) { - uint32_t prn_ = observables_iter->second.PRN; + const uint32_t prn_ = observables_iter->second.PRN; total_gal_map.insert(std::pair(prn_, observables_iter->second)); it = available_gal_prns.find(prn_); if (it == available_gal_prns.end()) @@ -11333,7 +11327,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep observables_iter != observablesE5A.cend(); observables_iter++) { - uint32_t prn_ = observables_iter->second.PRN; + const uint32_t prn_ = observables_iter->second.PRN; total_gal_map.insert(std::pair(prn_, observables_iter->second)); it = available_gal_prns.find(prn_); if (it == available_gal_prns.end()) @@ -11346,7 +11340,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep observables_iter != observablesE5B.cend(); observables_iter++) { - uint32_t prn_ = observables_iter->second.PRN; + const uint32_t prn_ = observables_iter->second.PRN; total_gal_map.insert(std::pair(prn_, observables_iter->second)); it = available_gal_prns.find(prn_); if (it == available_gal_prns.end()) @@ -11359,7 +11353,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep observables_iter != observablesG1C.cend(); observables_iter++) { - uint32_t prn_ = observables_iter->second.PRN; + const uint32_t prn_ = observables_iter->second.PRN; total_gps_map.insert(std::pair(prn_, observables_iter->second)); it = available_gps_prns.find(prn_); if (it == available_gps_prns.end()) @@ -11372,7 +11366,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep observables_iter != observablesG2S.cend(); observables_iter++) { - uint32_t prn_ = observables_iter->second.PRN; + const uint32_t prn_ = observables_iter->second.PRN; total_gps_map.insert(std::pair(prn_, observables_iter->second)); it = available_gps_prns.find(prn_); if (it == available_gps_prns.end()) @@ -11385,7 +11379,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep observables_iter != observablesGL5.cend(); observables_iter++) { - uint32_t prn_ = observables_iter->second.PRN; + const uint32_t prn_ = observables_iter->second.PRN; total_gps_map.insert(std::pair(prn_, observables_iter->second)); it = available_gps_prns.find(prn_); if (it == available_gps_prns.end()) @@ -11394,9 +11388,9 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep } } - int32_t numGalSatellitesObserved = available_gal_prns.size(); - int32_t numGpsSatellitesObserved = available_gps_prns.size(); - int32_t numSatellitesObserved = numGalSatellitesObserved + numGpsSatellitesObserved; + const int32_t numGalSatellitesObserved = available_gal_prns.size(); + const int32_t numGpsSatellitesObserved = available_gps_prns.size(); + const int32_t numSatellitesObserved = numGalSatellitesObserved + numGpsSatellitesObserved; line += Rinex_Printer::rightJustify(std::to_string(numSatellitesObserved), 3); // Receiver clock offset (optional) @@ -11449,7 +11443,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep // } // Signal Strength Indicator (SSI) - int32_t ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); + const int32_t ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // CARRIER PHASE @@ -11511,7 +11505,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep // } // Signal Strength Indicator (SSI) - int32_t ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); + const int32_t ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // Galileo CARRIER PHASE @@ -11552,18 +11546,18 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Beidou_Dnav_Ephemeris { std::string line; - boost::posix_time::ptime p_bds_time = Rinex_Printer::compute_BDS_time(eph, obs_time); - std::string timestring = boost::posix_time::to_iso_string(p_bds_time); + const boost::posix_time::ptime p_bds_time = Rinex_Printer::compute_BDS_time(eph, obs_time); + const std::string timestring = boost::posix_time::to_iso_string(p_bds_time); // double utc_t = nav_msg.utc_time(nav_msg.sv_clock_correction(obs_time)); // double gps_t = eph.sv_clock_correction(obs_time); - double bds_t = obs_time; + const double bds_t = obs_time; - std::string month(timestring, 4, 2); - std::string day(timestring, 6, 2); - std::string hour(timestring, 9, 2); - std::string minutes(timestring, 11, 2); + const std::string month(timestring, 4, 2); + const std::string day(timestring, 6, 2); + const std::string hour(timestring, 9, 2); + const std::string minutes(timestring, 11, 2); - std::string year(timestring, 0, 4); + const std::string year(timestring, 0, 4); line += std::string(1, '>'); line += std::string(1, ' '); line += year; @@ -11577,7 +11571,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Beidou_Dnav_Ephemeris line += minutes; line += std::string(1, ' '); - double seconds = fmod(bds_t, 60); + const double seconds = fmod(bds_t, 60); // Add extra 0 if seconds are < 10 if (seconds < 10) { @@ -11623,7 +11617,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Beidou_Dnav_Ephemeris observables_iter != observablesB1I.cend(); observables_iter++) { - uint32_t prn_ = observables_iter->second.PRN; + const uint32_t prn_ = observables_iter->second.PRN; total_map.insert(std::pair(prn_, observables_iter->second)); it = available_prns.find(prn_); if (it == available_prns.end()) @@ -11638,7 +11632,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Beidou_Dnav_Ephemeris observables_iter != observablesB3I.cend(); observables_iter++) { - uint32_t prn_ = observables_iter->second.PRN; + const uint32_t prn_ = observables_iter->second.PRN; it = available_prns.find(prn_); if (it == available_prns.end()) { @@ -11658,7 +11652,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Beidou_Dnav_Ephemeris } } - int32_t numSatellitesObserved = available_prns.size(); + const int32_t numSatellitesObserved = available_prns.size(); line += Rinex_Printer::rightJustify(std::to_string(numSatellitesObserved), 3); // Receiver clock offset (optional) // line += rightJustify(asString(clockOffset, 12), 15); @@ -11692,7 +11686,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Beidou_Dnav_Ephemeris } // Signal Strength Indicator (SSI) - int32_t ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); + const int32_t ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // CARRIER PHASE @@ -11738,7 +11732,7 @@ void Rinex_Printer::to_date_time(int32_t gps_week, int32_t gps_tow, int& year, i // the GPS epoch is 06.01.1980 00:00, i.e. midnight 5. / 6. January 1980 // -> seconds since then - int32_t secs_since_gps_epoch = gps_week * secs_per_week + gps_tow; + const int32_t secs_since_gps_epoch = gps_week * secs_per_week + gps_tow; // find year, consider leap years bool is_leap_year; @@ -11879,8 +11873,7 @@ void Rinex_Printer::to_date_time(int32_t gps_week, int32_t gps_tow, int& year, i int32_t Rinex_Printer::signalStrength(const double snr) { - int32_t ss; - ss = static_cast(std::min(std::max(static_cast(floor(snr / 6)), 1), 9)); + auto ss = static_cast(std::min(std::max(static_cast(floor(snr / 6)), 1), 9)); return ss; } @@ -11890,7 +11883,7 @@ boost::posix_time::ptime Rinex_Printer::compute_UTC_time(const Gps_Navigation_Me // if we are processing a file -> wait to leap second to resolve the ambiguity else take the week from the local system time // idea: resolve the ambiguity with the leap second const double utc_t = nav_msg.utc_time(nav_msg.get_TOW()); - boost::posix_time::time_duration t = boost::posix_time::milliseconds(static_cast((utc_t + 604800 * static_cast(nav_msg.get_GPS_week())) * 1000)); + const boost::posix_time::time_duration t = boost::posix_time::milliseconds(static_cast((utc_t + 604800 * static_cast(nav_msg.get_GPS_week())) * 1000)); // Handle week rollover if (pre_2009_file_ == false) { @@ -11919,7 +11912,7 @@ boost::posix_time::ptime Rinex_Printer::compute_BDS_time(const Beidou_Dnav_Ephem // (see Pag. 17 in ftp://igs.org/pub/data/format/rinex300.pdf) // --??? No time correction here, since it will be done in the RINEX processor const double bds_t = obs_time; - boost::posix_time::time_duration t = boost::posix_time::milliseconds(static_cast((bds_t + 604800 * static_cast(eph.i_BEIDOU_week % 8192)) * 1000)); + const boost::posix_time::time_duration t = boost::posix_time::milliseconds(static_cast((bds_t + 604800 * static_cast(eph.i_BEIDOU_week % 8192)) * 1000)); boost::posix_time::ptime p_time(boost::gregorian::date(2006, 1, 1), t); return p_time; } @@ -11965,7 +11958,7 @@ boost::posix_time::ptime Rinex_Printer::compute_GPS_time(const Gps_CNAV_Ephemeri // (see Section 3 in ftp://igs.org/pub/data/format/rinex211.txt) // (see Pag. 17 in ftp://igs.org/pub/data/format/rinex300.pdf) // --??? No time correction here, since it will be done in the RINEX processor - boost::posix_time::time_duration t = boost::posix_time::milliseconds(static_cast((obs_time + 604800 * static_cast(eph.i_GPS_week % 1024)) * 1000)); + const boost::posix_time::time_duration t = boost::posix_time::milliseconds(static_cast((obs_time + 604800 * static_cast(eph.i_GPS_week % 1024)) * 1000)); boost::posix_time::ptime p_time(boost::gregorian::date(1999, 8, 22), t); return p_time; } @@ -11976,8 +11969,8 @@ boost::posix_time::ptime Rinex_Printer::compute_Galileo_time(const Galileo_Ephem // The RINEX v2.11 v3.00 format uses Galileo time for the observations epoch, not UTC time, thus, no leap seconds needed here. // (see Pag. 17 in ftp://igs.org/pub/data/format/rinex301.pdf) // --??? No time correction here, since it will be done in the RINEX processor - double galileo_t = obs_time; - boost::posix_time::time_duration t = boost::posix_time::milliseconds(static_cast((galileo_t + 604800 * static_cast(eph.WN_5)) * 1000)); // + const double galileo_t = obs_time; + const boost::posix_time::time_duration t = boost::posix_time::milliseconds(static_cast((galileo_t + 604800 * static_cast(eph.WN_5)) * 1000)); // boost::posix_time::ptime p_time(boost::gregorian::date(1999, 8, 22), t); return p_time; } @@ -11986,7 +11979,7 @@ boost::posix_time::ptime Rinex_Printer::compute_Galileo_time(const Galileo_Ephem boost::posix_time::ptime Rinex_Printer::compute_UTC_time(const Glonass_Gnav_Ephemeris& eph, const double obs_time) { double tod = 0.0; - double glot2utc = 3 * 3600; + const double glot2utc = 3 * 3600; double obs_time_glot = 0.0; int32_t i = 0; @@ -11997,21 +11990,21 @@ boost::posix_time::ptime Rinex_Printer::compute_UTC_time(const Glonass_Gnav_Ephe tod = fmod(obs_time_glot, 86400); // Form date and time duration types - boost::posix_time::time_duration t1(0, 0, tod); - boost::gregorian::date d1(eph.d_yr, 1, 1); - boost::gregorian::days d2(eph.d_N_T - 1); - boost::posix_time::ptime glo_time(d1 + d2, t1); + const boost::posix_time::time_duration t1(0, 0, tod); + const boost::gregorian::date d1(eph.d_yr, 1, 1); + const boost::gregorian::days d2(eph.d_N_T - 1); + const boost::posix_time::ptime glo_time(d1 + d2, t1); // Convert to utc - boost::posix_time::time_duration t2(0, 0, glot2utc); + const boost::posix_time::time_duration t2(0, 0, glot2utc); boost::posix_time::ptime utc_time = glo_time - t2; // Adjust for leap second correction for (i = 0; GLONASS_LEAP_SECONDS[i][0] > 0; i++) { - boost::posix_time::time_duration t3(GLONASS_LEAP_SECONDS[i][3], GLONASS_LEAP_SECONDS[i][4], GLONASS_LEAP_SECONDS[i][5]); - boost::gregorian::date d3(GLONASS_LEAP_SECONDS[i][0], GLONASS_LEAP_SECONDS[i][1], GLONASS_LEAP_SECONDS[i][2]); - boost::posix_time::ptime ls_time(d3, t3); + const boost::posix_time::time_duration t3(GLONASS_LEAP_SECONDS[i][3], GLONASS_LEAP_SECONDS[i][4], GLONASS_LEAP_SECONDS[i][5]); + const boost::gregorian::date d3(GLONASS_LEAP_SECONDS[i][0], GLONASS_LEAP_SECONDS[i][1], GLONASS_LEAP_SECONDS[i][2]); + const boost::posix_time::ptime ls_time(d3, t3); if (utc_time >= ls_time) { // We subtract the leap second when going from gpst to utc, values store as negatives @@ -12027,7 +12020,7 @@ boost::posix_time::ptime Rinex_Printer::compute_UTC_time(const Glonass_Gnav_Ephe double Rinex_Printer::get_leap_second(const Glonass_Gnav_Ephemeris& eph, const double gps_obs_time) { double tod = 0.0; - double glot2utc = 3 * 3600; + const double glot2utc = 3 * 3600; double obs_time_glot = 0.0; int32_t i = 0; double leap_second = 0; @@ -12039,21 +12032,21 @@ double Rinex_Printer::get_leap_second(const Glonass_Gnav_Ephemeris& eph, const d tod = fmod(obs_time_glot, 86400); // Form date and time duration types - boost::posix_time::time_duration t1(0, 0, tod); - boost::gregorian::date d1(eph.d_yr, 1, 1); - boost::gregorian::days d2(eph.d_N_T - 1); - boost::posix_time::ptime glo_time(d1 + d2, t1); + const boost::posix_time::time_duration t1(0, 0, tod); + const boost::gregorian::date d1(eph.d_yr, 1, 1); + const boost::gregorian::days d2(eph.d_N_T - 1); + const boost::posix_time::ptime glo_time(d1 + d2, t1); // Convert to utc - boost::posix_time::time_duration t2(0, 0, glot2utc); + const boost::posix_time::time_duration t2(0, 0, glot2utc); boost::posix_time::ptime utc_time = glo_time - t2; // Adjust for leap second correction for (i = 0; GLONASS_LEAP_SECONDS[i][0] > 0; i++) { - boost::posix_time::time_duration t3(GLONASS_LEAP_SECONDS[i][3], GLONASS_LEAP_SECONDS[i][4], GLONASS_LEAP_SECONDS[i][5]); - boost::gregorian::date d3(GLONASS_LEAP_SECONDS[i][0], GLONASS_LEAP_SECONDS[i][1], GLONASS_LEAP_SECONDS[i][2]); - boost::posix_time::ptime ls_time(d3, t3); + const boost::posix_time::time_duration t3(GLONASS_LEAP_SECONDS[i][3], GLONASS_LEAP_SECONDS[i][4], GLONASS_LEAP_SECONDS[i][5]); + const boost::gregorian::date d3(GLONASS_LEAP_SECONDS[i][0], GLONASS_LEAP_SECONDS[i][1], GLONASS_LEAP_SECONDS[i][2]); + const boost::posix_time::ptime ls_time(d3, t3); if (utc_time >= ls_time) { // We subtract the leap second when going from gpst to utc diff --git a/src/algorithms/PVT/libs/rtcm.cc b/src/algorithms/PVT/libs/rtcm.cc index 95a7e8bb1..eda367904 100644 --- a/src/algorithms/PVT/libs/rtcm.cc +++ b/src/algorithms/PVT/libs/rtcm.cc @@ -140,10 +140,10 @@ std::string Rtcm::add_CRC(const std::string& message_without_crc) const // 2) Computes CRC CRC_RTCM.process_bytes(bytes.data(), bytes.size()); - auto crc_frame = std::bitset<24>(CRC_RTCM.checksum()); + const auto crc_frame = std::bitset<24>(CRC_RTCM.checksum()); // 3) Builds the complete message - std::string complete_message = message_without_crc + crc_frame.to_string(); + const std::string complete_message = message_without_crc + crc_frame.to_string(); return bin_to_binary_data(complete_message); } @@ -152,11 +152,11 @@ bool Rtcm::check_CRC(const std::string& message) const { boost::crc_optimal<24, 0x1864CFBU, 0x0, 0x0, false, false> CRC_RTCM_CHECK; // Convert message to binary - std::string message_bin = Rtcm::binary_data_to_bin(message); + const std::string message_bin = Rtcm::binary_data_to_bin(message); // Check CRC - std::string crc = message_bin.substr(message_bin.length() - 24, 24); - auto read_crc = std::bitset<24>(crc); - std::string msg_without_crc = message_bin.substr(0, message_bin.length() - 24); + const std::string crc = message_bin.substr(message_bin.length() - 24, 24); + const auto read_crc = std::bitset<24>(crc); + const std::string msg_without_crc = message_bin.substr(0, message_bin.length() - 24); boost::dynamic_bitset frame_bits(msg_without_crc); std::vector bytes; @@ -164,7 +164,7 @@ bool Rtcm::check_CRC(const std::string& message) const std::reverse(bytes.begin(), bytes.end()); CRC_RTCM_CHECK.process_bytes(bytes.data(), bytes.size()); - auto computed_crc = std::bitset<24>(CRC_RTCM_CHECK.checksum()); + const auto computed_crc = std::bitset<24>(CRC_RTCM_CHECK.checksum()); if (read_crc == computed_crc) { return true; @@ -177,7 +177,7 @@ bool Rtcm::check_CRC(const std::string& message) const std::string Rtcm::bin_to_binary_data(const std::string& s) const { std::string s_aux; - auto remainder = static_cast(std::fmod(s.length(), 8)); + const auto remainder = static_cast(std::fmod(s.length(), 8)); std::vector c; c.reserve(s.length()); @@ -186,20 +186,20 @@ std::string Rtcm::bin_to_binary_data(const std::string& s) const { s_aux.assign(s, 0, remainder); boost::dynamic_bitset<> rembits(s_aux); - uint64_t n = rembits.to_ulong(); + const uint64_t n = rembits.to_ulong(); c[0] = static_cast(n); k++; } - std::size_t start = std::max(remainder, 0); + const std::size_t start = std::max(remainder, 0); for (std::size_t i = start; i < s.length() - 1; i = i + 8) { s_aux.assign(s, i, 4); std::bitset<4> bs(s_aux); uint32_t n = bs.to_ulong(); s_aux.assign(s, i + 4, 4); - std::bitset<4> bs2(s_aux); - uint32_t n2 = bs2.to_ulong(); + const std::bitset<4> bs2(s_aux); + const uint32_t n2 = bs2.to_ulong(); c[k] = static_cast(n * 16) + static_cast(n2); k++; } @@ -216,8 +216,8 @@ std::string Rtcm::binary_data_to_bin(const std::string& s) const for (char i : s) { - auto val = static_cast(i); - std::bitset<8> bs(val); + const auto val = static_cast(i); + const std::bitset<8> bs(val); ss << bs; } @@ -230,22 +230,22 @@ std::string Rtcm::bin_to_hex(const std::string& s) const { std::string s_aux; std::stringstream ss; - auto remainder = static_cast(std::fmod(s.length(), 4)); + const auto remainder = static_cast(std::fmod(s.length(), 4)); if (remainder != 0) { s_aux.assign(s, 0, remainder); boost::dynamic_bitset<> rembits(s_aux); - uint32_t n = rembits.to_ulong(); + const uint32_t n = rembits.to_ulong(); ss << std::hex << n; } - std::size_t start = std::max(remainder, 0); + const std::size_t start = std::max(remainder, 0); for (std::size_t i = start; i < s.length() - 1; i = i + 4) { s_aux.assign(s, i, 4); - std::bitset<4> bs(s_aux); - uint32_t n = bs.to_ulong(); + const std::bitset<4> bs(s_aux); + const uint32_t n = bs.to_ulong(); ss << std::hex << n; } return boost::to_upper_copy(ss.str()); @@ -258,12 +258,12 @@ std::string Rtcm::hex_to_bin(const std::string& s) const s_aux.clear(); std::stringstream ss; ss << s; - std::string s_lower = boost::to_upper_copy(ss.str()); + const std::string s_lower = boost::to_upper_copy(ss.str()); for (size_t i = 0; i < s.length(); i++) { uint64_t n; std::istringstream(s_lower.substr(i, 1)) >> std::hex >> n; - std::bitset<4> bs(n); + const std::bitset<4> bs(n); s_aux += bs.to_string(); } return s_aux; @@ -277,7 +277,7 @@ uint32_t Rtcm::bin_to_uint(const std::string& s) const LOG(WARNING) << "Cannot convert to a uint32_t"; return 0; } - uint32_t reading = strtoul(s.c_str(), nullptr, 2); + const uint32_t reading = strtoul(s.c_str(), nullptr, 2); return reading; } @@ -386,7 +386,7 @@ uint64_t Rtcm::hex_to_uint(const std::string& s) const LOG(WARNING) << "Cannot convert to a uint64_t"; return 0; } - uint64_t reading = strtoul(s.c_str(), nullptr, 16); + const uint64_t reading = strtoul(s.c_str(), nullptr, 16); return reading; } @@ -398,23 +398,23 @@ int64_t Rtcm::hex_to_int(const std::string& s) const LOG(WARNING) << "Cannot convert to a int64_t"; return 0; } - int64_t reading = strtol(s.c_str(), nullptr, 16); + const int64_t reading = strtol(s.c_str(), nullptr, 16); return reading; } std::string Rtcm::build_message(const std::string& data) const { - uint32_t msg_length_bits = data.length(); - uint32_t msg_length_bytes = std::ceil(static_cast(msg_length_bits) / 8.0); - auto message_length = std::bitset<10>(msg_length_bytes); - uint32_t zeros_to_fill = 8 * msg_length_bytes - msg_length_bits; - std::string b(zeros_to_fill, '0'); - std::string msg_content = data + b; - std::string msg_without_crc = preamble.to_string() + - reserved_field.to_string() + - message_length.to_string() + - msg_content; + const uint32_t msg_length_bits = data.length(); + const uint32_t msg_length_bytes = std::ceil(static_cast(msg_length_bits) / 8.0); + const auto message_length = std::bitset<10>(msg_length_bytes); + const uint32_t zeros_to_fill = 8 * msg_length_bytes - msg_length_bits; + const std::string b(zeros_to_fill, '0'); + const std::string msg_content = data + b; + const std::string msg_without_crc = preamble.to_string() + + reserved_field.to_string() + + message_length.to_string() + + msg_content; return Rtcm::add_CRC(msg_without_crc); } @@ -435,11 +435,11 @@ std::string Rtcm::build_message(const std::string& data) const std::bitset<64> Rtcm::get_MT1001_4_header(uint32_t msg_number, double obs_time, const std::map& observables, uint32_t ref_id, uint32_t smooth_int, bool sync_flag, bool divergence_free) { - uint32_t reference_station_id = ref_id; // Max: 4095 + const uint32_t reference_station_id = ref_id; // Max: 4095 const std::map& observables_ = observables; - bool synchronous_GNSS_flag = sync_flag; - bool divergence_free_smoothing_indicator = divergence_free; - uint32_t smoothing_interval = smooth_int; + const bool synchronous_GNSS_flag = sync_flag; + const bool divergence_free_smoothing_indicator = divergence_free; + const uint32_t smoothing_interval = smooth_int; Rtcm::set_DF002(msg_number); Rtcm::set_DF003(reference_station_id); Rtcm::set_DF004(obs_time); @@ -448,13 +448,13 @@ std::bitset<64> Rtcm::get_MT1001_4_header(uint32_t msg_number, double obs_time, Rtcm::set_DF007(divergence_free_smoothing_indicator); Rtcm::set_DF008(smoothing_interval); - std::string header = DF002.to_string() + - DF003.to_string() + - DF004.to_string() + - DF005.to_string() + - DF006.to_string() + - DF007.to_string() + - DF008.to_string(); + const std::string header = DF002.to_string() + + DF003.to_string() + + DF004.to_string() + + DF005.to_string() + + DF006.to_string() + + DF007.to_string() + + DF008.to_string(); std::bitset<64> header_msg(header); return header_msg; @@ -470,11 +470,11 @@ std::bitset<58> Rtcm::get_MT1001_sat_content(const Gps_Ephemeris& eph, double ob Rtcm::set_DF012(gnss_synchro); Rtcm::set_DF013(eph, obs_time, gnss_synchro); - std::string content = DF009.to_string() + - DF010.to_string() + - DF011.to_string() + - DF012.to_string() + - DF013.to_string(); + const std::string content = DF009.to_string() + + DF010.to_string() + + DF011.to_string() + + DF012.to_string() + + DF013.to_string(); std::bitset<58> content_msg(content); return content_msg; @@ -483,7 +483,7 @@ std::bitset<58> Rtcm::get_MT1001_sat_content(const Gps_Ephemeris& eph, double ob std::string Rtcm::print_MT1001(const Gps_Ephemeris& gps_eph, double obs_time, const std::map& observables, uint16_t station_id) { - auto ref_id = static_cast(station_id); + const auto ref_id = static_cast(station_id); uint32_t smooth_int = 0; bool sync_flag = false; bool divergence_free = false; @@ -504,14 +504,14 @@ std::string Rtcm::print_MT1001(const Gps_Ephemeris& gps_eph, double obs_time, co } } - std::bitset<64> header = Rtcm::get_MT1001_4_header(1001, obs_time, observablesL1, ref_id, smooth_int, sync_flag, divergence_free); + const std::bitset<64> header = Rtcm::get_MT1001_4_header(1001, obs_time, observablesL1, ref_id, smooth_int, sync_flag, divergence_free); std::string data = header.to_string(); for (observables_iter = observablesL1.cbegin(); observables_iter != observablesL1.cend(); observables_iter++) { - std::bitset<58> content = Rtcm::get_MT1001_sat_content(gps_eph, obs_time, observables_iter->second); + const std::bitset<58> content = Rtcm::get_MT1001_sat_content(gps_eph, obs_time, observables_iter->second); data += content.to_string(); } @@ -532,7 +532,7 @@ std::string Rtcm::print_MT1001(const Gps_Ephemeris& gps_eph, double obs_time, co std::string Rtcm::print_MT1002(const Gps_Ephemeris& gps_eph, double obs_time, const std::map& observables, uint16_t station_id) { - auto ref_id = static_cast(station_id); + const auto ref_id = static_cast(station_id); uint32_t smooth_int = 0; bool sync_flag = false; bool divergence_free = false; @@ -545,26 +545,26 @@ std::string Rtcm::print_MT1002(const Gps_Ephemeris& gps_eph, double obs_time, co observables_iter != observables.cend(); observables_iter++) { - std::string system_(&observables_iter->second.System, 1); - std::string sig_(observables_iter->second.Signal); + const std::string system_(&observables_iter->second.System, 1); + const std::string sig_(observables_iter->second.Signal); if ((system_ == "G") && (sig_ == "1C")) { observablesL1.insert(std::pair(observables_iter->first, observables_iter->second)); } } - std::bitset<64> header = Rtcm::get_MT1001_4_header(1002, obs_time, observablesL1, ref_id, smooth_int, sync_flag, divergence_free); + const std::bitset<64> header = Rtcm::get_MT1001_4_header(1002, obs_time, observablesL1, ref_id, smooth_int, sync_flag, divergence_free); std::string data = header.to_string(); for (observables_iter = observablesL1.cbegin(); observables_iter != observablesL1.cend(); observables_iter++) { - std::bitset<74> content = Rtcm::get_MT1002_sat_content(gps_eph, obs_time, observables_iter->second); + const std::bitset<74> content = Rtcm::get_MT1002_sat_content(gps_eph, obs_time, observables_iter->second); data += content.to_string(); } - std::string msg = build_message(data); + const std::string msg = build_message(data); if (server_is_running) { rtcm_message_queue->push(msg); @@ -582,13 +582,13 @@ std::bitset<74> Rtcm::get_MT1002_sat_content(const Gps_Ephemeris& eph, double ob Rtcm::set_DF012(gnss_synchro); Rtcm::set_DF013(eph, obs_time, gnss_synchro); - std::string content = DF009.to_string() + - DF010.to_string() + - DF011.to_string() + - DF012.to_string() + - DF013.to_string() + - DF014.to_string() + - DF015.to_string(); + const std::string content = DF009.to_string() + + DF010.to_string() + + DF011.to_string() + + DF012.to_string() + + DF013.to_string() + + DF014.to_string() + + DF015.to_string(); std::bitset<74> content_msg(content); return content_msg; @@ -603,7 +603,7 @@ std::bitset<74> Rtcm::get_MT1002_sat_content(const Gps_Ephemeris& eph, double ob std::string Rtcm::print_MT1003(const Gps_Ephemeris& ephL1, const Gps_CNAV_Ephemeris& ephL2, double obs_time, const std::map& observables, uint16_t station_id) { - auto ref_id = static_cast(station_id); + const auto ref_id = static_cast(station_id); uint32_t smooth_int = 0; bool sync_flag = false; bool divergence_free = false; @@ -618,8 +618,8 @@ std::string Rtcm::print_MT1003(const Gps_Ephemeris& ephL1, const Gps_CNAV_Epheme observables_iter != observables.cend(); observables_iter++) { - std::string system_(&observables_iter->second.System, 1); - std::string sig_(observables_iter->second.Signal); + const std::string system_(&observables_iter->second.System, 1); + const std::string sig_(observables_iter->second.Signal); if ((system_ == "G") && (sig_ == "1C")) { observablesL1.insert(std::pair(observables_iter->first, observables_iter->second)); @@ -639,7 +639,7 @@ std::string Rtcm::print_MT1003(const Gps_Ephemeris& ephL1, const Gps_CNAV_Epheme observables_iter != observablesL1.cend(); observables_iter++) { - uint32_t prn_ = observables_iter->second.PRN; + const uint32_t prn_ = observables_iter->second.PRN; for (observables_iter2 = observablesL2.cbegin(); observables_iter2 != observablesL2.cend(); observables_iter2++) @@ -656,7 +656,7 @@ std::string Rtcm::print_MT1003(const Gps_Ephemeris& ephL1, const Gps_CNAV_Epheme } } - std::bitset<64> header = Rtcm::get_MT1001_4_header(1003, obs_time, observablesL1_with_L2, ref_id, smooth_int, sync_flag, divergence_free); + const std::bitset<64> header = Rtcm::get_MT1001_4_header(1003, obs_time, observablesL1_with_L2, ref_id, smooth_int, sync_flag, divergence_free); std::string data = header.to_string(); for (common_observables_iter = common_observables.cbegin(); @@ -689,15 +689,15 @@ std::bitset<101> Rtcm::get_MT1003_sat_content(const Gps_Ephemeris& ephL1, const Rtcm::set_DF018(gnss_synchroL1, gnss_synchroL2); Rtcm::set_DF019(ephL2, obs_time, gnss_synchroL2); - std::string content = DF009.to_string() + - DF010.to_string() + - DF011.to_string() + - DF012.to_string() + - DF013.to_string() + - DF016_.to_string() + - DF017.to_string() + - DF018.to_string() + - DF019.to_string(); + const std::string content = DF009.to_string() + + DF010.to_string() + + DF011.to_string() + + DF012.to_string() + + DF013.to_string() + + DF016_.to_string() + + DF017.to_string() + + DF018.to_string() + + DF019.to_string(); std::bitset<101> content_msg(content); return content_msg; @@ -712,7 +712,7 @@ std::bitset<101> Rtcm::get_MT1003_sat_content(const Gps_Ephemeris& ephL1, const std::string Rtcm::print_MT1004(const Gps_Ephemeris& ephL1, const Gps_CNAV_Ephemeris& ephL2, double obs_time, const std::map& observables, uint16_t station_id) { - auto ref_id = static_cast(station_id); + const auto ref_id = static_cast(station_id); uint32_t smooth_int = 0; bool sync_flag = false; bool divergence_free = false; @@ -727,8 +727,8 @@ std::string Rtcm::print_MT1004(const Gps_Ephemeris& ephL1, const Gps_CNAV_Epheme observables_iter != observables.cend(); observables_iter++) { - std::string system_(&observables_iter->second.System, 1); - std::string sig_(observables_iter->second.Signal); + const std::string system_(&observables_iter->second.System, 1); + const std::string sig_(observables_iter->second.Signal); if ((system_ == "G") && (sig_ == "1C")) { observablesL1.insert(std::pair(observables_iter->first, observables_iter->second)); @@ -748,7 +748,7 @@ std::string Rtcm::print_MT1004(const Gps_Ephemeris& ephL1, const Gps_CNAV_Epheme observables_iter != observablesL1.cend(); observables_iter++) { - uint32_t prn_ = observables_iter->second.PRN; + const uint32_t prn_ = observables_iter->second.PRN; for (observables_iter2 = observablesL2.cbegin(); observables_iter2 != observablesL2.cend(); observables_iter2++) @@ -765,7 +765,7 @@ std::string Rtcm::print_MT1004(const Gps_Ephemeris& ephL1, const Gps_CNAV_Epheme } } - std::bitset<64> header = Rtcm::get_MT1001_4_header(1004, obs_time, observablesL1_with_L2, ref_id, smooth_int, sync_flag, divergence_free); + const std::bitset<64> header = Rtcm::get_MT1001_4_header(1004, obs_time, observablesL1_with_L2, ref_id, smooth_int, sync_flag, divergence_free); std::string data = header.to_string(); for (common_observables_iter = common_observables.cbegin(); @@ -801,18 +801,18 @@ std::bitset<125> Rtcm::get_MT1004_sat_content(const Gps_Ephemeris& ephL1, const Rtcm::set_DF019(ephL2, obs_time, gnss_synchroL2); Rtcm::set_DF020(gnss_synchroL2); - std::string content = DF009.to_string() + - DF010.to_string() + - DF011.to_string() + - DF012.to_string() + - DF013.to_string() + - DF014.to_string() + - DF015.to_string() + - DF016_.to_string() + - DF017.to_string() + - DF018.to_string() + - DF019.to_string() + - DF020.to_string(); + const std::string content = DF009.to_string() + + DF010.to_string() + + DF011.to_string() + + DF012.to_string() + + DF013.to_string() + + DF014.to_string() + + DF015.to_string() + + DF016_.to_string() + + DF017.to_string() + + DF018.to_string() + + DF019.to_string() + + DF020.to_string(); std::bitset<125> content_msg(content); return content_msg; @@ -837,11 +837,11 @@ std::bitset<125> Rtcm::get_MT1004_sat_content(const Gps_Ephemeris& ephL1, const */ std::bitset<152> Rtcm::get_MT1005_test() { - uint32_t mt1005 = 1005; - uint32_t reference_station_id = 2003; // Max: 4095 - double ECEF_X = 1114104.5999; // units: m - double ECEF_Y = -4850729.7108; // units: m - double ECEF_Z = 3975521.4643; // units: m + const uint32_t mt1005 = 1005; + const uint32_t reference_station_id = 2003; // Max: 4095 + const double ECEF_X = 1114104.5999; // units: m + const double ECEF_Y = -4850729.7108; // units: m + const double ECEF_Z = 3975521.4643; // units: m std::bitset<1> DF001_; @@ -859,19 +859,19 @@ std::bitset<152> Rtcm::get_MT1005_test() DF364 = std::bitset<2>("00"); // Quarter Cycle Indicator Rtcm::set_DF027(ECEF_Z); - std::string message = DF002.to_string() + - DF003.to_string() + - DF021.to_string() + - DF022.to_string() + - DF023.to_string() + - DF024.to_string() + - DF141.to_string() + - DF025.to_string() + - DF142.to_string() + - DF001_.to_string() + - DF026.to_string() + - DF364.to_string() + - DF027.to_string(); + const std::string message = DF002.to_string() + + DF003.to_string() + + DF021.to_string() + + DF022.to_string() + + DF023.to_string() + + DF024.to_string() + + DF141.to_string() + + DF025.to_string() + + DF142.to_string() + + DF001_.to_string() + + DF026.to_string() + + DF364.to_string() + + DF027.to_string(); std::bitset<152> test_msg(message); return test_msg; @@ -880,7 +880,7 @@ std::bitset<152> Rtcm::get_MT1005_test() std::string Rtcm::print_MT1005(uint32_t ref_id, double ecef_x, double ecef_y, double ecef_z, bool gps, bool glonass, bool galileo, bool non_physical, bool single_oscillator, uint32_t quarter_cycle_indicator) { - uint32_t msg_number = 1005; + const uint32_t msg_number = 1005; std::bitset<1> DF001_; Rtcm::set_DF002(msg_number); @@ -897,19 +897,19 @@ std::string Rtcm::print_MT1005(uint32_t ref_id, double ecef_x, double ecef_y, do DF364 = std::bitset<2>(quarter_cycle_indicator); Rtcm::set_DF027(ecef_z); - std::string data = DF002.to_string() + - DF003.to_string() + - DF021.to_string() + - DF022.to_string() + - DF023.to_string() + - DF024.to_string() + - DF141.to_string() + - DF025.to_string() + - DF142.to_string() + - DF001_.to_string() + - DF026.to_string() + - DF364.to_string() + - DF027.to_string(); + const std::string data = DF002.to_string() + + DF003.to_string() + + DF021.to_string() + + DF022.to_string() + + DF023.to_string() + + DF024.to_string() + + DF141.to_string() + + DF025.to_string() + + DF142.to_string() + + DF001_.to_string() + + DF026.to_string() + + DF364.to_string() + + DF027.to_string(); std::string msg = build_message(data); if (server_is_running) @@ -923,7 +923,7 @@ std::string Rtcm::print_MT1005(uint32_t ref_id, double ecef_x, double ecef_y, do int32_t Rtcm::read_MT1005(const std::string& message, uint32_t& ref_id, double& ecef_x, double& ecef_y, double& ecef_z, bool& gps, bool& glonass, bool& galileo) { // Convert message to binary - std::string message_bin = Rtcm::binary_data_to_bin(message); + const std::string message_bin = Rtcm::binary_data_to_bin(message); if (!Rtcm::check_CRC(message)) { @@ -932,8 +932,8 @@ int32_t Rtcm::read_MT1005(const std::string& message, uint32_t& ref_id, double& } // Check than the message number is correct - uint32_t preamble_length = 8; - uint32_t reserved_field_length = 6; + const uint32_t preamble_length = 8; + const uint32_t reserved_field_length = 6; uint32_t index = preamble_length + reserved_field_length; uint32_t read_message_length = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 10))); @@ -944,7 +944,7 @@ int32_t Rtcm::read_MT1005(const std::string& message, uint32_t& ref_id, double& return 1; } - uint32_t msg_number = 1005; + const uint32_t msg_number = 1005; Rtcm::set_DF002(msg_number); std::bitset<12> read_msg_number(message_bin.substr(index, 12)); index += 12; @@ -955,7 +955,6 @@ int32_t Rtcm::read_MT1005(const std::string& message, uint32_t& ref_id, double& return 1; } - ref_id = Rtcm::bin_to_uint(message_bin.substr(index, 12)); index += 12; @@ -1001,7 +1000,7 @@ std::string Rtcm::print_MT1005_test() std::string Rtcm::print_MT1006(uint32_t ref_id, double ecef_x, double ecef_y, double ecef_z, bool gps, bool glonass, bool galileo, bool non_physical, bool single_oscillator, uint32_t quarter_cycle_indicator, double height) { - uint32_t msg_number = 1006; + const uint32_t msg_number = 1006; std::bitset<1> DF001_; Rtcm::set_DF002(msg_number); @@ -1019,20 +1018,20 @@ std::string Rtcm::print_MT1006(uint32_t ref_id, double ecef_x, double ecef_y, do Rtcm::set_DF027(ecef_z); Rtcm::set_DF028(height); - std::string data = DF002.to_string() + - DF003.to_string() + - DF021.to_string() + - DF022.to_string() + - DF023.to_string() + - DF024.to_string() + - DF141.to_string() + - DF025.to_string() + - DF142.to_string() + - DF001_.to_string() + - DF026.to_string() + - DF364.to_string() + - DF027.to_string() + - DF028.to_string(); + const std::string data = DF002.to_string() + + DF003.to_string() + + DF021.to_string() + + DF022.to_string() + + DF023.to_string() + + DF024.to_string() + + DF141.to_string() + + DF025.to_string() + + DF142.to_string() + + DF001_.to_string() + + DF026.to_string() + + DF364.to_string() + + DF027.to_string() + + DF028.to_string(); std::string msg = build_message(data); if (server_is_running) @@ -1050,7 +1049,7 @@ std::string Rtcm::print_MT1006(uint32_t ref_id, double ecef_x, double ecef_y, do // ******************************************************** std::string Rtcm::print_MT1008(uint32_t ref_id, const std::string& antenna_descriptor, uint32_t antenna_setup_id, const std::string& antenna_serial_number) { - uint32_t msg_number = 1008; + const uint32_t msg_number = 1008; auto DF002_ = std::bitset<12>(msg_number); Rtcm::set_DF003(ref_id); std::string ant_descriptor = antenna_descriptor; @@ -1065,7 +1064,7 @@ std::string Rtcm::print_MT1008(uint32_t ref_id, const std::string& antenna_descr std::string DF030_str_; for (char c : ant_descriptor) { - auto character = std::bitset<8>(c); + const auto character = std::bitset<8>(c); DF030_str_ += character.to_string(); } @@ -1083,17 +1082,17 @@ std::string Rtcm::print_MT1008(uint32_t ref_id, const std::string& antenna_descr std::string DF033_str_; for (char c : ant_sn) { - auto character = std::bitset<8>(c); + const auto character = std::bitset<8>(c); DF033_str_ += character.to_string(); } - std::string data = DF002_.to_string() + - DF003.to_string() + - DF029.to_string() + - DF030_str_ + - DF031.to_string() + - DF032.to_string() + - DF033_str_; + const std::string data = DF002_.to_string() + + DF003.to_string() + + DF029.to_string() + + DF030_str_ + + DF031.to_string() + + DF032.to_string() + + DF033_str_; std::string msg = build_message(data); if (server_is_running) @@ -1112,11 +1111,11 @@ std::string Rtcm::print_MT1008(uint32_t ref_id, const std::string& antenna_descr std::bitset<61> Rtcm::get_MT1009_12_header(uint32_t msg_number, double obs_time, const std::map& observables, uint32_t ref_id, uint32_t smooth_int, bool sync_flag, bool divergence_free) { - uint32_t reference_station_id = ref_id; // Max: 4095 + const uint32_t reference_station_id = ref_id; // Max: 4095 const std::map& observables_ = observables; - bool synchronous_GNSS_flag = sync_flag; - bool divergence_free_smoothing_indicator = divergence_free; - uint32_t smoothing_interval = smooth_int; + const bool synchronous_GNSS_flag = sync_flag; + const bool divergence_free_smoothing_indicator = divergence_free; + const uint32_t smoothing_interval = smooth_int; Rtcm::set_DF002(msg_number); Rtcm::set_DF003(reference_station_id); Rtcm::set_DF034(obs_time); @@ -1125,13 +1124,13 @@ std::bitset<61> Rtcm::get_MT1009_12_header(uint32_t msg_number, double obs_time, Rtcm::set_DF036(divergence_free_smoothing_indicator); Rtcm::set_DF037(smoothing_interval); - std::string header = DF002.to_string() + - DF003.to_string() + - DF034.to_string() + - DF005.to_string() + - DF035.to_string() + - DF036.to_string() + - DF037.to_string(); + const std::string header = DF002.to_string() + + DF003.to_string() + + DF034.to_string() + + DF005.to_string() + + DF035.to_string() + + DF036.to_string() + + DF037.to_string(); std::bitset<61> header_msg(header); return header_msg; @@ -1140,7 +1139,7 @@ std::bitset<61> Rtcm::get_MT1009_12_header(uint32_t msg_number, double obs_time, std::bitset<64> Rtcm::get_MT1009_sat_content(const Glonass_Gnav_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro) { - bool code_indicator = false; // code indicator 0: C/A code 1: P(Y) code direct + const bool code_indicator = false; // code indicator 0: C/A code 1: P(Y) code direct Rtcm::set_DF038(gnss_synchro); Rtcm::set_DF039(code_indicator); Rtcm::set_DF040(eph.i_satellite_freq_channel); @@ -1148,12 +1147,12 @@ std::bitset<64> Rtcm::get_MT1009_sat_content(const Glonass_Gnav_Ephemeris& eph, Rtcm::set_DF042(gnss_synchro); Rtcm::set_DF043(eph, obs_time, gnss_synchro); - std::string content = DF038.to_string() + - DF039.to_string() + - DF040.to_string() + - DF041.to_string() + - DF042.to_string() + - DF043.to_string(); + const std::string content = DF038.to_string() + + DF039.to_string() + + DF040.to_string() + + DF041.to_string() + + DF042.to_string() + + DF043.to_string(); std::bitset<64> content_msg(content); return content_msg; @@ -1162,7 +1161,7 @@ std::bitset<64> Rtcm::get_MT1009_sat_content(const Glonass_Gnav_Ephemeris& eph, std::string Rtcm::print_MT1009(const Glonass_Gnav_Ephemeris& glonass_gnav_eph, double obs_time, const std::map& observables, uint16_t station_id) { - auto ref_id = static_cast(station_id); + const auto ref_id = static_cast(station_id); uint32_t smooth_int = 0; bool sync_flag = false; bool divergence_free = false; @@ -1175,22 +1174,22 @@ std::string Rtcm::print_MT1009(const Glonass_Gnav_Ephemeris& glonass_gnav_eph, d observables_iter != observables.end(); observables_iter++) { - std::string system_(&observables_iter->second.System, 1); - std::string sig_(observables_iter->second.Signal); + const std::string system_(&observables_iter->second.System, 1); + const std::string sig_(observables_iter->second.Signal); if ((system_ == "R") && (sig_ == "1C")) { observablesL1.insert(std::pair(observables_iter->first, observables_iter->second)); } } - std::bitset<61> header = Rtcm::get_MT1009_12_header(1009, obs_time, observablesL1, ref_id, smooth_int, sync_flag, divergence_free); + const std::bitset<61> header = Rtcm::get_MT1009_12_header(1009, obs_time, observablesL1, ref_id, smooth_int, sync_flag, divergence_free); std::string data = header.to_string(); for (observables_iter = observablesL1.begin(); observables_iter != observablesL1.end(); observables_iter++) { - std::bitset<64> content = Rtcm::get_MT1009_sat_content(glonass_gnav_eph, obs_time, observables_iter->second); + const std::bitset<64> content = Rtcm::get_MT1009_sat_content(glonass_gnav_eph, obs_time, observables_iter->second); data += content.to_string(); } @@ -1211,7 +1210,7 @@ std::string Rtcm::print_MT1009(const Glonass_Gnav_Ephemeris& glonass_gnav_eph, d std::string Rtcm::print_MT1010(const Glonass_Gnav_Ephemeris& glonass_gnav_eph, double obs_time, const std::map& observables, uint16_t station_id) { - auto ref_id = static_cast(station_id); + const auto ref_id = static_cast(station_id); uint32_t smooth_int = 0; bool sync_flag = false; bool divergence_free = false; @@ -1224,22 +1223,22 @@ std::string Rtcm::print_MT1010(const Glonass_Gnav_Ephemeris& glonass_gnav_eph, d observables_iter != observables.end(); observables_iter++) { - std::string system_(&observables_iter->second.System, 1); - std::string sig_(observables_iter->second.Signal); + const std::string system_(&observables_iter->second.System, 1); + const std::string sig_(observables_iter->second.Signal); if ((system_ == "R") && (sig_ == "1C")) { observablesL1.insert(std::pair(observables_iter->first, observables_iter->second)); } } - std::bitset<61> header = Rtcm::get_MT1009_12_header(1010, obs_time, observablesL1, ref_id, smooth_int, sync_flag, divergence_free); + const std::bitset<61> header = Rtcm::get_MT1009_12_header(1010, obs_time, observablesL1, ref_id, smooth_int, sync_flag, divergence_free); std::string data = header.to_string(); for (observables_iter = observablesL1.begin(); observables_iter != observablesL1.end(); observables_iter++) { - std::bitset<79> content = Rtcm::get_MT1010_sat_content(glonass_gnav_eph, obs_time, observables_iter->second); + const std::bitset<79> content = Rtcm::get_MT1010_sat_content(glonass_gnav_eph, obs_time, observables_iter->second); data += content.to_string(); } @@ -1254,7 +1253,7 @@ std::string Rtcm::print_MT1010(const Glonass_Gnav_Ephemeris& glonass_gnav_eph, d std::bitset<79> Rtcm::get_MT1010_sat_content(const Glonass_Gnav_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro) { - bool code_indicator = false; // code indicator 0: C/A code 1: P(Y) code direct + const bool code_indicator = false; // code indicator 0: C/A code 1: P(Y) code direct Rtcm::set_DF038(gnss_synchro); Rtcm::set_DF039(code_indicator); Rtcm::set_DF040(eph.i_satellite_freq_channel); @@ -1264,14 +1263,14 @@ std::bitset<79> Rtcm::get_MT1010_sat_content(const Glonass_Gnav_Ephemeris& eph, Rtcm::set_DF044(gnss_synchro); Rtcm::set_DF045(gnss_synchro); - std::string content = DF038.to_string() + - DF039.to_string() + - DF040.to_string() + - DF041.to_string() + - DF042.to_string() + - DF043.to_string() + - DF044.to_string() + - DF045.to_string(); + const std::string content = DF038.to_string() + + DF039.to_string() + + DF040.to_string() + + DF041.to_string() + + DF042.to_string() + + DF043.to_string() + + DF044.to_string() + + DF045.to_string(); std::bitset<79> content_msg(content); return content_msg; @@ -1286,7 +1285,7 @@ std::bitset<79> Rtcm::get_MT1010_sat_content(const Glonass_Gnav_Ephemeris& eph, std::string Rtcm::print_MT1011(const Glonass_Gnav_Ephemeris& ephL1, const Glonass_Gnav_Ephemeris& ephL2, double obs_time, const std::map& observables, uint16_t station_id) { - auto ref_id = static_cast(station_id); + const auto ref_id = static_cast(station_id); uint32_t smooth_int = 0; bool sync_flag = false; bool divergence_free = false; @@ -1301,8 +1300,8 @@ std::string Rtcm::print_MT1011(const Glonass_Gnav_Ephemeris& ephL1, const Glonas observables_iter != observables.end(); observables_iter++) { - std::string system_(&observables_iter->second.System, 1); - std::string sig_(observables_iter->second.Signal); + const std::string system_(&observables_iter->second.System, 1); + const std::string sig_(observables_iter->second.Signal); if ((system_ == "R") && (sig_ == "1C")) { observablesL1.insert(std::pair(observables_iter->first, observables_iter->second)); @@ -1322,7 +1321,7 @@ std::string Rtcm::print_MT1011(const Glonass_Gnav_Ephemeris& ephL1, const Glonas observables_iter != observablesL1.end(); observables_iter++) { - uint32_t prn_ = observables_iter->second.PRN; + const uint32_t prn_ = observables_iter->second.PRN; for (observables_iter2 = observablesL2.begin(); observables_iter2 != observablesL2.end(); observables_iter2++) @@ -1339,14 +1338,14 @@ std::string Rtcm::print_MT1011(const Glonass_Gnav_Ephemeris& ephL1, const Glonas } } - std::bitset<61> header = Rtcm::get_MT1009_12_header(1011, obs_time, observablesL1_with_L2, ref_id, smooth_int, sync_flag, divergence_free); + const std::bitset<61> header = Rtcm::get_MT1009_12_header(1011, obs_time, observablesL1_with_L2, ref_id, smooth_int, sync_flag, divergence_free); std::string data = header.to_string(); for (common_observables_iter = common_observables.begin(); common_observables_iter != common_observables.end(); common_observables_iter++) { - std::bitset<107> content = Rtcm::get_MT1011_sat_content(ephL1, ephL2, obs_time, common_observables_iter->first, common_observables_iter->second); + const std::bitset<107> content = Rtcm::get_MT1011_sat_content(ephL1, ephL2, obs_time, common_observables_iter->first, common_observables_iter->second); data += content.to_string(); } @@ -1361,7 +1360,7 @@ std::string Rtcm::print_MT1011(const Glonass_Gnav_Ephemeris& ephL1, const Glonas std::bitset<107> Rtcm::get_MT1011_sat_content(const Glonass_Gnav_Ephemeris& ephL1, const Glonass_Gnav_Ephemeris& ephL2, double obs_time, const Gnss_Synchro& gnss_synchroL1, const Gnss_Synchro& gnss_synchroL2) { - bool code_indicator = false; // code indicator 0: C/A code 1: P(Y) code direct + const bool code_indicator = false; // code indicator 0: C/A code 1: P(Y) code direct Rtcm::set_DF038(gnss_synchroL1); Rtcm::set_DF039(code_indicator); Rtcm::set_DF040(ephL1.i_satellite_freq_channel); @@ -1373,16 +1372,16 @@ std::bitset<107> Rtcm::get_MT1011_sat_content(const Glonass_Gnav_Ephemeris& ephL Rtcm::set_DF048(gnss_synchroL1, gnss_synchroL2); Rtcm::set_DF049(ephL2, obs_time, gnss_synchroL2); - std::string content = DF038.to_string() + - DF039.to_string() + - DF040.to_string() + - DF041.to_string() + - DF042.to_string() + - DF043.to_string() + - DF046_.to_string() + - DF047.to_string() + - DF048.to_string() + - DF049.to_string(); + const std::string content = DF038.to_string() + + DF039.to_string() + + DF040.to_string() + + DF041.to_string() + + DF042.to_string() + + DF043.to_string() + + DF046_.to_string() + + DF047.to_string() + + DF048.to_string() + + DF049.to_string(); std::bitset<107> content_msg(content); return content_msg; @@ -1397,7 +1396,7 @@ std::bitset<107> Rtcm::get_MT1011_sat_content(const Glonass_Gnav_Ephemeris& ephL std::string Rtcm::print_MT1012(const Glonass_Gnav_Ephemeris& ephL1, const Glonass_Gnav_Ephemeris& ephL2, double obs_time, const std::map& observables, uint16_t station_id) { - auto ref_id = static_cast(station_id); + const auto ref_id = static_cast(station_id); uint32_t smooth_int = 0; bool sync_flag = false; bool divergence_free = false; @@ -1412,8 +1411,8 @@ std::string Rtcm::print_MT1012(const Glonass_Gnav_Ephemeris& ephL1, const Glonas observables_iter != observables.end(); observables_iter++) { - std::string system_(&observables_iter->second.System, 1); - std::string sig_(observables_iter->second.Signal); + const std::string system_(&observables_iter->second.System, 1); + const std::string sig_(observables_iter->second.Signal); if ((system_ == "R") && (sig_ == "1C")) { observablesL1.insert(std::pair(observables_iter->first, observables_iter->second)); @@ -1433,7 +1432,7 @@ std::string Rtcm::print_MT1012(const Glonass_Gnav_Ephemeris& ephL1, const Glonas observables_iter != observablesL1.end(); observables_iter++) { - uint32_t prn_ = observables_iter->second.PRN; + const uint32_t prn_ = observables_iter->second.PRN; for (observables_iter2 = observablesL2.begin(); observables_iter2 != observablesL2.end(); observables_iter2++) @@ -1450,14 +1449,14 @@ std::string Rtcm::print_MT1012(const Glonass_Gnav_Ephemeris& ephL1, const Glonas } } - std::bitset<61> header = Rtcm::get_MT1009_12_header(1012, obs_time, observablesL1_with_L2, ref_id, smooth_int, sync_flag, divergence_free); + const std::bitset<61> header = Rtcm::get_MT1009_12_header(1012, obs_time, observablesL1_with_L2, ref_id, smooth_int, sync_flag, divergence_free); std::string data = header.to_string(); for (common_observables_iter = common_observables.begin(); common_observables_iter != common_observables.end(); common_observables_iter++) { - std::bitset<130> content = Rtcm::get_MT1012_sat_content(ephL1, ephL2, obs_time, common_observables_iter->first, common_observables_iter->second); + const std::bitset<130> content = Rtcm::get_MT1012_sat_content(ephL1, ephL2, obs_time, common_observables_iter->first, common_observables_iter->second); data += content.to_string(); } @@ -1472,7 +1471,7 @@ std::string Rtcm::print_MT1012(const Glonass_Gnav_Ephemeris& ephL1, const Glonas std::bitset<130> Rtcm::get_MT1012_sat_content(const Glonass_Gnav_Ephemeris& ephL1, const Glonass_Gnav_Ephemeris& ephL2, double obs_time, const Gnss_Synchro& gnss_synchroL1, const Gnss_Synchro& gnss_synchroL2) { - bool code_indicator = false; // code indicator 0: C/A code 1: P(Y) code direct + const bool code_indicator = false; // code indicator 0: C/A code 1: P(Y) code direct Rtcm::set_DF038(gnss_synchroL1); Rtcm::set_DF039(code_indicator); Rtcm::set_DF040(ephL1.i_satellite_freq_channel); @@ -1487,19 +1486,19 @@ std::bitset<130> Rtcm::get_MT1012_sat_content(const Glonass_Gnav_Ephemeris& ephL Rtcm::set_DF049(ephL2, obs_time, gnss_synchroL2); Rtcm::set_DF050(gnss_synchroL2); - std::string content = DF038.to_string() + - DF039.to_string() + - DF040.to_string() + - DF041.to_string() + - DF042.to_string() + - DF043.to_string() + - DF044.to_string() + - DF045.to_string() + - DF046_.to_string() + - DF047.to_string() + - DF048.to_string() + - DF049.to_string() + - DF050.to_string(); + const std::string content = DF038.to_string() + + DF039.to_string() + + DF040.to_string() + + DF041.to_string() + + DF042.to_string() + + DF043.to_string() + + DF044.to_string() + + DF045.to_string() + + DF046_.to_string() + + DF047.to_string() + + DF048.to_string() + + DF049.to_string() + + DF050.to_string(); std::bitset<130> content_msg(content); return content_msg; @@ -1514,7 +1513,7 @@ std::bitset<130> Rtcm::get_MT1012_sat_content(const Glonass_Gnav_Ephemeris& ephL std::string Rtcm::print_MT1019(const Gps_Ephemeris& gps_eph) { - uint32_t msg_number = 1019; + const uint32_t msg_number = 1019; Rtcm::set_DF002(msg_number); Rtcm::set_DF009(gps_eph); @@ -1548,39 +1547,37 @@ std::string Rtcm::print_MT1019(const Gps_Ephemeris& gps_eph) Rtcm::set_DF103(gps_eph); Rtcm::set_DF137(gps_eph); - std::string data; - data.clear(); - data = DF002.to_string() + - DF009.to_string() + - DF076.to_string() + - DF077.to_string() + - DF078.to_string() + - DF079.to_string() + - DF071.to_string() + - DF081.to_string() + - DF082.to_string() + - DF083.to_string() + - DF084.to_string() + - DF085.to_string() + - DF086.to_string() + - DF087.to_string() + - DF088.to_string() + - DF089.to_string() + - DF090.to_string() + - DF091.to_string() + - DF092.to_string() + - DF093.to_string() + - DF094.to_string() + - DF095.to_string() + - DF096.to_string() + - DF097.to_string() + - DF098.to_string() + - DF099.to_string() + - DF100.to_string() + - DF101.to_string() + - DF102.to_string() + - DF103.to_string() + - DF137.to_string(); + const std::string data = DF002.to_string() + + DF009.to_string() + + DF076.to_string() + + DF077.to_string() + + DF078.to_string() + + DF079.to_string() + + DF071.to_string() + + DF081.to_string() + + DF082.to_string() + + DF083.to_string() + + DF084.to_string() + + DF085.to_string() + + DF086.to_string() + + DF087.to_string() + + DF088.to_string() + + DF089.to_string() + + DF090.to_string() + + DF091.to_string() + + DF092.to_string() + + DF093.to_string() + + DF094.to_string() + + DF095.to_string() + + DF096.to_string() + + DF097.to_string() + + DF098.to_string() + + DF099.to_string() + + DF100.to_string() + + DF101.to_string() + + DF102.to_string() + + DF103.to_string() + + DF137.to_string(); if (data.length() != 488) { @@ -1599,7 +1596,7 @@ std::string Rtcm::print_MT1019(const Gps_Ephemeris& gps_eph) int32_t Rtcm::read_MT1019(const std::string& message, Gps_Ephemeris& gps_eph) { // Convert message to binary - std::string message_bin = Rtcm::binary_data_to_bin(message); + const std::string message_bin = Rtcm::binary_data_to_bin(message); if (!Rtcm::check_CRC(message)) { @@ -1607,11 +1604,11 @@ int32_t Rtcm::read_MT1019(const std::string& message, Gps_Ephemeris& gps_eph) return 1; } - uint32_t preamble_length = 8; - uint32_t reserved_field_length = 6; + const uint32_t preamble_length = 8; + const uint32_t reserved_field_length = 6; uint32_t index = preamble_length + reserved_field_length; - uint32_t read_message_length = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 10))); + const uint32_t read_message_length = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 10))); index += 10; if (read_message_length != 61) @@ -1621,7 +1618,7 @@ int32_t Rtcm::read_MT1019(const std::string& message, Gps_Ephemeris& gps_eph) } // Check than the message number is correct - uint32_t read_msg_number = Rtcm::bin_to_uint(message_bin.substr(index, 12)); + const uint32_t read_msg_number = Rtcm::bin_to_uint(message_bin.substr(index, 12)); index += 12; if (1019 != read_msg_number) @@ -1733,10 +1730,10 @@ int32_t Rtcm::read_MT1019(const std::string& message, Gps_Ephemeris& gps_eph) std::string Rtcm::print_MT1020(const Glonass_Gnav_Ephemeris& glonass_gnav_eph, const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model) { - uint32_t msg_number = 1020; - uint32_t glonass_gnav_alm_health = 0; - uint32_t glonass_gnav_alm_health_ind = 0; - uint32_t fifth_str_additional_data_ind = 1; + const uint32_t msg_number = 1020; + const uint32_t glonass_gnav_alm_health = 0; + const uint32_t glonass_gnav_alm_health_ind = 0; + const uint32_t fifth_str_additional_data_ind = 1; Rtcm::set_DF002(msg_number); Rtcm::set_DF038(glonass_gnav_eph); @@ -1775,45 +1772,43 @@ std::string Rtcm::print_MT1020(const Glonass_Gnav_Ephemeris& glonass_gnav_eph, c Rtcm::set_DF135(glonass_gnav_utc_model); Rtcm::set_DF136(glonass_gnav_eph); - std::string data; - data.clear(); - data = DF002.to_string() + - DF038.to_string() + - DF040.to_string() + - DF104.to_string() + - DF105.to_string() + - DF106.to_string() + - DF107.to_string() + - DF108.to_string() + - DF109.to_string() + - DF110.to_string() + - DF111.to_string() + - DF112.to_string() + - DF113.to_string() + - DF114.to_string() + - DF115.to_string() + - DF116.to_string() + - DF117.to_string() + - DF118.to_string() + - DF119.to_string() + - DF120.to_string() + - DF121.to_string() + - DF122.to_string() + - DF123.to_string() + - DF124.to_string() + - DF125.to_string() + - DF126.to_string() + - DF127.to_string() + - DF128.to_string() + - DF129.to_string() + - DF130.to_string() + - DF131.to_string() + - DF132.to_string() + - DF133.to_string() + - DF134.to_string() + - DF135.to_string() + - DF136.to_string() + - std::bitset<7>().to_string(); // Reserved bits + const std::string data = DF002.to_string() + + DF038.to_string() + + DF040.to_string() + + DF104.to_string() + + DF105.to_string() + + DF106.to_string() + + DF107.to_string() + + DF108.to_string() + + DF109.to_string() + + DF110.to_string() + + DF111.to_string() + + DF112.to_string() + + DF113.to_string() + + DF114.to_string() + + DF115.to_string() + + DF116.to_string() + + DF117.to_string() + + DF118.to_string() + + DF119.to_string() + + DF120.to_string() + + DF121.to_string() + + DF122.to_string() + + DF123.to_string() + + DF124.to_string() + + DF125.to_string() + + DF126.to_string() + + DF127.to_string() + + DF128.to_string() + + DF129.to_string() + + DF130.to_string() + + DF131.to_string() + + DF132.to_string() + + DF133.to_string() + + DF134.to_string() + + DF135.to_string() + + DF136.to_string() + + std::bitset<7>().to_string(); // Reserved bits if (data.length() != 360) { @@ -1832,7 +1827,7 @@ std::string Rtcm::print_MT1020(const Glonass_Gnav_Ephemeris& glonass_gnav_eph, c int32_t Rtcm::read_MT1020(const std::string& message, Glonass_Gnav_Ephemeris& glonass_gnav_eph, Glonass_Gnav_Utc_Model& glonass_gnav_utc_model) { // Convert message to binary - std::string message_bin = Rtcm::binary_data_to_bin(message); + const std::string message_bin = Rtcm::binary_data_to_bin(message); int32_t glonass_gnav_alm_health = 0; int32_t glonass_gnav_alm_health_ind = 0; int32_t fifth_str_additional_data_ind = 0; @@ -1843,11 +1838,11 @@ int32_t Rtcm::read_MT1020(const std::string& message, Glonass_Gnav_Ephemeris& gl return 1; } - uint32_t preamble_length = 8; - uint32_t reserved_field_length = 6; + const uint32_t preamble_length = 8; + const uint32_t reserved_field_length = 6; uint32_t index = preamble_length + reserved_field_length; - uint32_t read_message_length = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 10))); + const uint32_t read_message_length = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 10))); index += 10; if (read_message_length != 45) // 360 bits = 45 bytes @@ -1857,7 +1852,7 @@ int32_t Rtcm::read_MT1020(const std::string& message, Glonass_Gnav_Ephemeris& gl } // Check than the message number is correct - uint32_t read_msg_number = Rtcm::bin_to_uint(message_bin.substr(index, 12)); + const uint32_t read_msg_number = Rtcm::bin_to_uint(message_bin.substr(index, 12)); index += 12; if (1020 != read_msg_number) @@ -1998,7 +1993,7 @@ int32_t Rtcm::read_MT1020(const std::string& message, Glonass_Gnav_Ephemeris& gl std::string Rtcm::print_MT1029(uint32_t ref_id, const Gps_Ephemeris& gps_eph, double obs_time, const std::string& message) { - uint32_t msg_number = 1029; + const uint32_t msg_number = 1029; Rtcm::set_DF002(msg_number); Rtcm::set_DF003(ref_id); @@ -2027,20 +2022,20 @@ std::string Rtcm::print_MT1029(uint32_t ref_id, const Gps_Ephemeris& gps_eph, do first = false; } } - auto character = std::bitset<8>(c); + const auto character = std::bitset<8>(c); text_binary += character.to_string(); } - auto DF138_ = std::bitset<7>(i); - auto DF139_ = std::bitset<8>(message.length()); + const auto DF138_ = std::bitset<7>(i); + const auto DF139_ = std::bitset<8>(message.length()); - std::string data = DF002.to_string() + - DF003.to_string() + - DF051.to_string() + - DF052.to_string() + - DF138_.to_string() + - DF139_.to_string() + - text_binary; + const std::string data = DF002.to_string() + + DF003.to_string() + + DF051.to_string() + + DF052.to_string() + + DF138_.to_string() + + DF139_.to_string() + + text_binary; std::string msg = build_message(data); if (server_is_running) @@ -2059,7 +2054,7 @@ std::string Rtcm::print_MT1029(uint32_t ref_id, const Gps_Ephemeris& gps_eph, do std::string Rtcm::print_MT1045(const Galileo_Ephemeris& gal_eph) { - uint32_t msg_number = 1045; + const uint32_t msg_number = 1045; Rtcm::set_DF002(msg_number); Rtcm::set_DF252(gal_eph); @@ -2088,40 +2083,38 @@ std::string Rtcm::print_MT1045(const Galileo_Ephemeris& gal_eph) Rtcm::set_DF312(gal_eph); Rtcm::set_DF314(gal_eph); Rtcm::set_DF315(gal_eph); - uint32_t seven_zero = 0; - auto DF001_ = std::bitset<7>(seven_zero); + const uint32_t seven_zero = 0; + const auto DF001_ = std::bitset<7>(seven_zero); - std::string data; - data.clear(); - data = DF002.to_string() + - DF252.to_string() + - DF289.to_string() + - DF290.to_string() + - DF291.to_string() + - DF292.to_string() + - DF293.to_string() + - DF294.to_string() + - DF295.to_string() + - DF296.to_string() + - DF297.to_string() + - DF298.to_string() + - DF299.to_string() + - DF300.to_string() + - DF301.to_string() + - DF302.to_string() + - DF303.to_string() + - DF304.to_string() + - DF305.to_string() + - DF306.to_string() + - DF307.to_string() + - DF308.to_string() + - DF309.to_string() + - DF310.to_string() + - DF311.to_string() + - DF312.to_string() + - DF314.to_string() + - DF315.to_string() + - DF001_.to_string(); + const std::string data = DF002.to_string() + + DF252.to_string() + + DF289.to_string() + + DF290.to_string() + + DF291.to_string() + + DF292.to_string() + + DF293.to_string() + + DF294.to_string() + + DF295.to_string() + + DF296.to_string() + + DF297.to_string() + + DF298.to_string() + + DF299.to_string() + + DF300.to_string() + + DF301.to_string() + + DF302.to_string() + + DF303.to_string() + + DF304.to_string() + + DF305.to_string() + + DF306.to_string() + + DF307.to_string() + + DF308.to_string() + + DF309.to_string() + + DF310.to_string() + + DF311.to_string() + + DF312.to_string() + + DF314.to_string() + + DF315.to_string() + + DF001_.to_string(); if (data.length() != 496) { @@ -2140,7 +2133,7 @@ std::string Rtcm::print_MT1045(const Galileo_Ephemeris& gal_eph) int32_t Rtcm::read_MT1045(const std::string& message, Galileo_Ephemeris& gal_eph) { // Convert message to binary - std::string message_bin = Rtcm::binary_data_to_bin(message); + const std::string message_bin = Rtcm::binary_data_to_bin(message); if (!Rtcm::check_CRC(message)) { @@ -2148,11 +2141,11 @@ int32_t Rtcm::read_MT1045(const std::string& message, Galileo_Ephemeris& gal_eph return 1; } - uint32_t preamble_length = 8; - uint32_t reserved_field_length = 6; + const uint32_t preamble_length = 8; + const uint32_t reserved_field_length = 6; uint32_t index = preamble_length + reserved_field_length; - uint32_t read_message_length = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 10))); + const uint32_t read_message_length = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 10))); index += 10; if (read_message_length != 62) @@ -2162,7 +2155,7 @@ int32_t Rtcm::read_MT1045(const std::string& message, Galileo_Ephemeris& gal_eph } // Check than the message number is correct - uint32_t read_msg_number = Rtcm::bin_to_uint(message_bin.substr(index, 12)); + const uint32_t read_msg_number = Rtcm::bin_to_uint(message_bin.substr(index, 12)); index += 12; if (1045 != read_msg_number) @@ -2302,7 +2295,7 @@ std::string Rtcm::print_MSM_1(const Gps_Ephemeris& gps_eph, msg_number = 1071; } - std::string header = Rtcm::get_MSM_header(msg_number, + const std::string header = Rtcm::get_MSM_header(msg_number, obs_time, observables, ref_id, @@ -2312,9 +2305,9 @@ std::string Rtcm::print_MSM_1(const Gps_Ephemeris& gps_eph, divergence_free, more_messages); - std::string sat_data = Rtcm::get_MSM_1_content_sat_data(observables); + const std::string sat_data = Rtcm::get_MSM_1_content_sat_data(observables); - std::string signal_data = Rtcm::get_MSM_1_content_signal_data(observables); + const std::string signal_data = Rtcm::get_MSM_1_content_signal_data(observables); std::string message = build_message(header + sat_data + signal_data); @@ -2339,13 +2332,13 @@ std::string Rtcm::get_MSM_header(uint32_t msg_number, { // Find first element in observables block and define type of message auto observables_iter = observables.begin(); - std::string sys(observables_iter->second.System, 1); + const std::string sys(observables_iter->second.System, 1); Rtcm::set_DF002(msg_number); Rtcm::set_DF003(ref_id); Rtcm::set_DF393(more_messages); Rtcm::set_DF409(0); // Issue of Data Station. 0: not utilized - auto DF001_ = std::bitset<7>("0000000"); + const auto DF001_ = std::bitset<7>("0000000"); Rtcm::set_DF411(clock_steering_indicator); Rtcm::set_DF412(external_clock_indicator); Rtcm::set_DF417(divergence_free); @@ -2387,14 +2380,16 @@ std::string Rtcm::get_MSM_header(uint32_t msg_number, std::string Rtcm::get_MSM_1_content_sat_data(const std::map& observables) { std::string sat_data; - sat_data.clear(); Rtcm::set_DF394(observables); - uint32_t num_satellites = DF394.count(); + const uint32_t num_satellites = DF394.count(); + const uint32_t numobs = observables.size(); std::vector > observables_vector; + observables_vector.reserve(numobs); std::map::const_iterator gnss_synchro_iter; std::vector pos; + pos.reserve(numobs); std::vector::iterator it; for (gnss_synchro_iter = observables.cbegin(); @@ -2409,7 +2404,7 @@ std::string Rtcm::get_MSM_1_content_sat_data(const std::map > ordered_by_PRN_pos = Rtcm::sort_by_PRN_mask(observables_vector); + const std::vector > ordered_by_PRN_pos = Rtcm::sort_by_PRN_mask(observables_vector); for (uint32_t nsat = 0; nsat < num_satellites; nsat++) { @@ -2424,10 +2419,10 @@ std::string Rtcm::get_MSM_1_content_sat_data(const std::map& observables) { std::string signal_data; - signal_data.clear(); - uint32_t Ncells = observables.size(); + const uint32_t Ncells = observables.size(); std::vector > observables_vector; + observables_vector.reserve(Ncells); std::map::const_iterator map_iter; for (map_iter = observables.cbegin(); @@ -2439,7 +2434,7 @@ std::string Rtcm::get_MSM_1_content_signal_data(const std::map > ordered_by_signal = Rtcm::sort_by_signal(observables_vector); std::reverse(ordered_by_signal.begin(), ordered_by_signal.end()); - std::vector > ordered_by_PRN_pos = Rtcm::sort_by_PRN_mask(ordered_by_signal); + const std::vector > ordered_by_PRN_pos = Rtcm::sort_by_PRN_mask(ordered_by_signal); for (uint32_t cell = 0; cell < Ncells; cell++) { @@ -2497,7 +2492,7 @@ std::string Rtcm::print_MSM_2(const Gps_Ephemeris& gps_eph, msg_number = 1072; } - std::string header = Rtcm::get_MSM_header(msg_number, + const std::string header = Rtcm::get_MSM_header(msg_number, obs_time, observables, ref_id, @@ -2507,9 +2502,9 @@ std::string Rtcm::print_MSM_2(const Gps_Ephemeris& gps_eph, divergence_free, more_messages); - std::string sat_data = Rtcm::get_MSM_1_content_sat_data(observables); + const std::string sat_data = Rtcm::get_MSM_1_content_sat_data(observables); - std::string signal_data = Rtcm::get_MSM_2_content_signal_data(gps_eph, gps_cnav_eph, gal_eph, glo_gnav_eph, obs_time, observables); + const std::string signal_data = Rtcm::get_MSM_2_content_signal_data(gps_eph, gps_cnav_eph, gal_eph, glo_gnav_eph, obs_time, observables); std::string message = build_message(header + sat_data + signal_data); if (server_is_running) @@ -2533,9 +2528,10 @@ std::string Rtcm::get_MSM_2_content_signal_data(const Gps_Ephemeris& ephNAV, std::string second_data_type; std::string third_data_type; - uint32_t Ncells = observables.size(); + const uint32_t Ncells = observables.size(); std::vector > observables_vector; + observables_vector.reserve(Ncells); std::map::const_iterator map_iter; for (map_iter = observables.cbegin(); @@ -2547,7 +2543,7 @@ std::string Rtcm::get_MSM_2_content_signal_data(const Gps_Ephemeris& ephNAV, std::vector > ordered_by_signal = Rtcm::sort_by_signal(observables_vector); std::reverse(ordered_by_signal.begin(), ordered_by_signal.end()); - std::vector > ordered_by_PRN_pos = Rtcm::sort_by_PRN_mask(ordered_by_signal); + const std::vector > ordered_by_PRN_pos = Rtcm::sort_by_PRN_mask(ordered_by_signal); for (uint32_t cell = 0; cell < Ncells; cell++) { @@ -2610,7 +2606,7 @@ std::string Rtcm::print_MSM_3(const Gps_Ephemeris& gps_eph, msg_number = 1073; } - std::string header = Rtcm::get_MSM_header(msg_number, + const std::string header = Rtcm::get_MSM_header(msg_number, obs_time, observables, ref_id, @@ -2620,9 +2616,9 @@ std::string Rtcm::print_MSM_3(const Gps_Ephemeris& gps_eph, divergence_free, more_messages); - std::string sat_data = Rtcm::get_MSM_1_content_sat_data(observables); + const std::string sat_data = Rtcm::get_MSM_1_content_sat_data(observables); - std::string signal_data = Rtcm::get_MSM_3_content_signal_data(gps_eph, gps_cnav_eph, gal_eph, glo_gnav_eph, obs_time, observables); + const std::string signal_data = Rtcm::get_MSM_3_content_signal_data(gps_eph, gps_cnav_eph, gal_eph, glo_gnav_eph, obs_time, observables); std::string message = build_message(header + sat_data + signal_data); if (server_is_running) @@ -2647,9 +2643,10 @@ std::string Rtcm::get_MSM_3_content_signal_data(const Gps_Ephemeris& ephNAV, std::string third_data_type; std::string fourth_data_type; - uint32_t Ncells = observables.size(); + const uint32_t Ncells = observables.size(); std::vector > observables_vector; + observables_vector.reserve(Ncells); std::map::const_iterator map_iter; for (map_iter = observables.cbegin(); @@ -2661,7 +2658,7 @@ std::string Rtcm::get_MSM_3_content_signal_data(const Gps_Ephemeris& ephNAV, std::vector > ordered_by_signal = Rtcm::sort_by_signal(observables_vector); std::reverse(ordered_by_signal.begin(), ordered_by_signal.end()); - std::vector > ordered_by_PRN_pos = Rtcm::sort_by_PRN_mask(ordered_by_signal); + const std::vector > ordered_by_PRN_pos = Rtcm::sort_by_PRN_mask(ordered_by_signal); for (uint32_t cell = 0; cell < Ncells; cell++) { @@ -2726,7 +2723,7 @@ std::string Rtcm::print_MSM_4(const Gps_Ephemeris& gps_eph, msg_number = 1074; } - std::string header = Rtcm::get_MSM_header(msg_number, + const std::string header = Rtcm::get_MSM_header(msg_number, obs_time, observables, ref_id, @@ -2736,9 +2733,9 @@ std::string Rtcm::print_MSM_4(const Gps_Ephemeris& gps_eph, divergence_free, more_messages); - std::string sat_data = Rtcm::get_MSM_4_content_sat_data(observables); + const std::string sat_data = Rtcm::get_MSM_4_content_sat_data(observables); - std::string signal_data = Rtcm::get_MSM_4_content_signal_data(gps_eph, gps_cnav_eph, gal_eph, glo_gnav_eph, obs_time, observables); + const std::string signal_data = Rtcm::get_MSM_4_content_signal_data(gps_eph, gps_cnav_eph, gal_eph, glo_gnav_eph, obs_time, observables); std::string message = build_message(header + sat_data + signal_data); if (server_is_running) @@ -2757,11 +2754,14 @@ std::string Rtcm::get_MSM_4_content_sat_data(const std::map > observables_vector; + observables_vector.reserve(numobs); std::map::const_iterator gnss_synchro_iter; std::vector pos; + pos.reserve(numobs); std::vector::iterator it; for (gnss_synchro_iter = observables.cbegin(); @@ -2776,7 +2776,7 @@ std::string Rtcm::get_MSM_4_content_sat_data(const std::map > ordered_by_PRN_pos = Rtcm::sort_by_PRN_mask(observables_vector); + const std::vector > ordered_by_PRN_pos = Rtcm::sort_by_PRN_mask(observables_vector); for (uint32_t nsat = 0; nsat < num_satellites; nsat++) { @@ -2804,9 +2804,10 @@ std::string Rtcm::get_MSM_4_content_signal_data(const Gps_Ephemeris& ephNAV, std::string fourth_data_type; std::string fifth_data_type; - uint32_t Ncells = observables.size(); + const uint32_t Ncells = observables.size(); std::vector > observables_vector; + observables_vector.reserve(Ncells); std::map::const_iterator map_iter; for (map_iter = observables.cbegin(); @@ -2818,7 +2819,7 @@ std::string Rtcm::get_MSM_4_content_signal_data(const Gps_Ephemeris& ephNAV, std::vector > ordered_by_signal = Rtcm::sort_by_signal(observables_vector); std::reverse(ordered_by_signal.begin(), ordered_by_signal.end()); - std::vector > ordered_by_PRN_pos = Rtcm::sort_by_PRN_mask(ordered_by_signal); + const std::vector > ordered_by_PRN_pos = Rtcm::sort_by_PRN_mask(ordered_by_signal); for (uint32_t cell = 0; cell < Ncells; cell++) { @@ -2885,7 +2886,7 @@ std::string Rtcm::print_MSM_5(const Gps_Ephemeris& gps_eph, msg_number = 1075; } - std::string header = Rtcm::get_MSM_header(msg_number, + const std::string header = Rtcm::get_MSM_header(msg_number, obs_time, observables, ref_id, @@ -2895,9 +2896,9 @@ std::string Rtcm::print_MSM_5(const Gps_Ephemeris& gps_eph, divergence_free, more_messages); - std::string sat_data = Rtcm::get_MSM_5_content_sat_data(observables); + const std::string sat_data = Rtcm::get_MSM_5_content_sat_data(observables); - std::string signal_data = Rtcm::get_MSM_5_content_signal_data(gps_eph, gps_cnav_eph, gal_eph, glo_gnav_eph, obs_time, observables); + const std::string signal_data = Rtcm::get_MSM_5_content_signal_data(gps_eph, gps_cnav_eph, gal_eph, glo_gnav_eph, obs_time, observables); std::string message = build_message(header + sat_data + signal_data); if (server_is_running) @@ -2918,11 +2919,14 @@ std::string Rtcm::get_MSM_5_content_sat_data(const std::map > observables_vector; + observables_vector.reserve(numobs); std::map::const_iterator gnss_synchro_iter; std::vector pos; + pos.reserve(numobs); std::vector::iterator it; for (gnss_synchro_iter = observables.cbegin(); @@ -2937,7 +2941,7 @@ std::string Rtcm::get_MSM_5_content_sat_data(const std::map > ordered_by_PRN_pos = Rtcm::sort_by_PRN_mask(observables_vector); + const std::vector > ordered_by_PRN_pos = Rtcm::sort_by_PRN_mask(observables_vector); for (uint32_t nsat = 0; nsat < num_satellites; nsat++) { @@ -2970,9 +2974,10 @@ std::string Rtcm::get_MSM_5_content_signal_data(const Gps_Ephemeris& ephNAV, std::string fifth_data_type; std::string sixth_data_type; - uint32_t Ncells = observables.size(); + const uint32_t Ncells = observables.size(); std::vector > observables_vector; + observables_vector.reserve(Ncells); std::map::const_iterator map_iter; for (map_iter = observables.cbegin(); @@ -2984,7 +2989,7 @@ std::string Rtcm::get_MSM_5_content_signal_data(const Gps_Ephemeris& ephNAV, std::vector > ordered_by_signal = Rtcm::sort_by_signal(observables_vector); std::reverse(ordered_by_signal.begin(), ordered_by_signal.end()); - std::vector > ordered_by_PRN_pos = Rtcm::sort_by_PRN_mask(ordered_by_signal); + const std::vector > ordered_by_PRN_pos = Rtcm::sort_by_PRN_mask(ordered_by_signal); for (uint32_t cell = 0; cell < Ncells; cell++) { @@ -3053,7 +3058,7 @@ std::string Rtcm::print_MSM_6(const Gps_Ephemeris& gps_eph, msg_number = 1076; } - std::string header = Rtcm::get_MSM_header(msg_number, + const std::string header = Rtcm::get_MSM_header(msg_number, obs_time, observables, ref_id, @@ -3063,9 +3068,9 @@ std::string Rtcm::print_MSM_6(const Gps_Ephemeris& gps_eph, divergence_free, more_messages); - std::string sat_data = Rtcm::get_MSM_4_content_sat_data(observables); + const std::string sat_data = Rtcm::get_MSM_4_content_sat_data(observables); - std::string signal_data = Rtcm::get_MSM_6_content_signal_data(gps_eph, gps_cnav_eph, gal_eph, glo_gnav_eph, obs_time, observables); + const std::string signal_data = Rtcm::get_MSM_6_content_signal_data(gps_eph, gps_cnav_eph, gal_eph, glo_gnav_eph, obs_time, observables); std::string message = build_message(header + sat_data + signal_data); if (server_is_running) @@ -3091,9 +3096,10 @@ std::string Rtcm::get_MSM_6_content_signal_data(const Gps_Ephemeris& ephNAV, std::string fourth_data_type; std::string fifth_data_type; - uint32_t Ncells = observables.size(); + const uint32_t Ncells = observables.size(); std::vector > observables_vector; + observables_vector.reserve(Ncells); std::map::const_iterator map_iter; for (map_iter = observables.cbegin(); @@ -3105,7 +3111,7 @@ std::string Rtcm::get_MSM_6_content_signal_data(const Gps_Ephemeris& ephNAV, std::vector > ordered_by_signal = Rtcm::sort_by_signal(observables_vector); std::reverse(ordered_by_signal.begin(), ordered_by_signal.end()); - std::vector > ordered_by_PRN_pos = Rtcm::sort_by_PRN_mask(ordered_by_signal); + const std::vector > ordered_by_PRN_pos = Rtcm::sort_by_PRN_mask(ordered_by_signal); for (uint32_t cell = 0; cell < Ncells; cell++) { @@ -3172,7 +3178,7 @@ std::string Rtcm::print_MSM_7(const Gps_Ephemeris& gps_eph, msg_number = 1076; } - std::string header = Rtcm::get_MSM_header(msg_number, + const std::string header = Rtcm::get_MSM_header(msg_number, obs_time, observables, ref_id, @@ -3182,9 +3188,9 @@ std::string Rtcm::print_MSM_7(const Gps_Ephemeris& gps_eph, divergence_free, more_messages); - std::string sat_data = Rtcm::get_MSM_5_content_sat_data(observables); + const std::string sat_data = Rtcm::get_MSM_5_content_sat_data(observables); - std::string signal_data = Rtcm::get_MSM_7_content_signal_data(gps_eph, gps_cnav_eph, gal_eph, glo_gnav_eph, obs_time, observables); + const std::string signal_data = Rtcm::get_MSM_7_content_signal_data(gps_eph, gps_cnav_eph, gal_eph, glo_gnav_eph, obs_time, observables); std::string message = build_message(header + sat_data + signal_data); if (server_is_running) @@ -3211,9 +3217,10 @@ std::string Rtcm::get_MSM_7_content_signal_data(const Gps_Ephemeris& ephNAV, std::string fifth_data_type; std::string sixth_data_type; - uint32_t Ncells = observables.size(); + const uint32_t Ncells = observables.size(); std::vector > observables_vector; + observables_vector.reserve(Ncells); std::map::const_iterator map_iter; for (map_iter = observables.cbegin(); @@ -3225,7 +3232,7 @@ std::string Rtcm::get_MSM_7_content_signal_data(const Gps_Ephemeris& ephNAV, std::vector > ordered_by_signal = Rtcm::sort_by_signal(observables_vector); std::reverse(ordered_by_signal.begin(), ordered_by_signal.end()); - std::vector > ordered_by_PRN_pos = Rtcm::sort_by_PRN_mask(ordered_by_signal); + const std::vector > ordered_by_PRN_pos = Rtcm::sort_by_PRN_mask(ordered_by_signal); for (uint32_t cell = 0; cell < Ncells; cell++) { @@ -3292,12 +3299,12 @@ std::vector > Rtcm::sort_by_signal(const std::v { uint32_t value_a = 0; uint32_t value_b = 0; - std::string system_a(&a.second.System, 1); - std::string system_b(&b.second.System, 1); - std::string sig_a_(a.second.Signal); - std::string sig_a = sig_a_.substr(0, 2); - std::string sig_b_(b.second.Signal); - std::string sig_b = sig_b_.substr(0, 2); + const std::string system_a(&a.second.System, 1); + const std::string system_b(&b.second.System, 1); + const std::string sig_a_(a.second.Signal); + const std::string sig_a = sig_a_.substr(0, 2); + const std::string sig_b_(b.second.Signal); + const std::string sig_b = sig_b_.substr(0, 2); if (system_a == "G") { @@ -3387,7 +3394,7 @@ std::map Rtcm::galileo_signal_map = [] { boost::posix_time::ptime Rtcm::compute_GPS_time(const Gps_Ephemeris& eph, double obs_time) const { const double gps_t = obs_time; - boost::posix_time::time_duration t_duration = boost::posix_time::milliseconds(static_cast((gps_t + 604800 * static_cast(eph.i_GPS_week)) * 1000)); // NOLINT(google-runtime-int) + const boost::posix_time::time_duration t_duration = boost::posix_time::milliseconds(static_cast((gps_t + 604800 * static_cast(eph.i_GPS_week)) * 1000)); // NOLINT(google-runtime-int) if (eph.i_GPS_week < 512) { @@ -3403,7 +3410,7 @@ boost::posix_time::ptime Rtcm::compute_GPS_time(const Gps_Ephemeris& eph, double boost::posix_time::ptime Rtcm::compute_GPS_time(const Gps_CNAV_Ephemeris& eph, double obs_time) const { const double gps_t = obs_time; - boost::posix_time::time_duration t_duration = boost::posix_time::milliseconds(static_cast((gps_t + 604800 * static_cast(eph.i_GPS_week)) * 1000)); // NOLINT(google-runtime-int) + const boost::posix_time::time_duration t_duration = boost::posix_time::milliseconds(static_cast((gps_t + 604800 * static_cast(eph.i_GPS_week)) * 1000)); // NOLINT(google-runtime-int) boost::posix_time::ptime p_time(boost::gregorian::date(1999, 8, 22), t_duration); return p_time; } @@ -3411,8 +3418,8 @@ boost::posix_time::ptime Rtcm::compute_GPS_time(const Gps_CNAV_Ephemeris& eph, d boost::posix_time::ptime Rtcm::compute_Galileo_time(const Galileo_Ephemeris& eph, double obs_time) const { - double galileo_t = obs_time; - boost::posix_time::time_duration t_duration = boost::posix_time::milliseconds(static_cast((galileo_t + 604800 * static_cast(eph.WN_5)) * 1000)); // NOLINT(google-runtime-int) + const double galileo_t = obs_time; + const boost::posix_time::time_duration t_duration = boost::posix_time::milliseconds(static_cast((galileo_t + 604800 * static_cast(eph.WN_5)) * 1000)); // NOLINT(google-runtime-int) boost::posix_time::ptime p_time(boost::gregorian::date(1999, 8, 22), t_duration); return p_time; } @@ -3427,7 +3434,6 @@ boost::posix_time::ptime Rtcm::compute_GLONASS_time(const Glonass_Gnav_Ephemeris uint32_t Rtcm::lock_time(const Gps_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro) { - uint32_t lock_time_in_seconds; boost::posix_time::ptime current_time = Rtcm::compute_GPS_time(eph, obs_time); boost::posix_time::ptime last_lock_time = Rtcm::gps_L1_last_lock_time[65 - gnss_synchro.PRN]; if (last_lock_time.is_not_a_date_time()) // || CHECK LLI!!......) @@ -3435,7 +3441,7 @@ uint32_t Rtcm::lock_time(const Gps_Ephemeris& eph, double obs_time, const Gnss_S Rtcm::gps_L1_last_lock_time[65 - gnss_synchro.PRN] = current_time; } boost::posix_time::time_duration lock_duration = current_time - Rtcm::gps_L1_last_lock_time[65 - gnss_synchro.PRN]; - lock_time_in_seconds = static_cast(lock_duration.total_seconds()); + const auto lock_time_in_seconds = static_cast(lock_duration.total_seconds()); // Debug: // std::cout << "lock time PRN " << gnss_synchro.PRN << ": " << lock_time_in_seconds << " current time: " << current_time << '\n'; return lock_time_in_seconds; @@ -3444,23 +3450,21 @@ uint32_t Rtcm::lock_time(const Gps_Ephemeris& eph, double obs_time, const Gnss_S uint32_t Rtcm::lock_time(const Gps_CNAV_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro) { - uint32_t lock_time_in_seconds; - boost::posix_time::ptime current_time = Rtcm::compute_GPS_time(eph, obs_time); + const boost::posix_time::ptime current_time = Rtcm::compute_GPS_time(eph, obs_time); boost::posix_time::ptime last_lock_time = Rtcm::gps_L2_last_lock_time[65 - gnss_synchro.PRN]; if (last_lock_time.is_not_a_date_time()) // || CHECK LLI!!......) { Rtcm::gps_L2_last_lock_time[65 - gnss_synchro.PRN] = current_time; } boost::posix_time::time_duration lock_duration = current_time - Rtcm::gps_L2_last_lock_time[65 - gnss_synchro.PRN]; - lock_time_in_seconds = static_cast(lock_duration.total_seconds()); + const auto lock_time_in_seconds = static_cast(lock_duration.total_seconds()); return lock_time_in_seconds; } uint32_t Rtcm::lock_time(const Galileo_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro) { - uint32_t lock_time_in_seconds; - boost::posix_time::ptime current_time = Rtcm::compute_Galileo_time(eph, obs_time); + const boost::posix_time::ptime current_time = Rtcm::compute_Galileo_time(eph, obs_time); boost::posix_time::ptime last_lock_time; std::string sig_(gnss_synchro.Signal); @@ -3495,15 +3499,14 @@ uint32_t Rtcm::lock_time(const Galileo_Ephemeris& eph, double obs_time, const Gn lock_duration = current_time - Rtcm::gal_E5_last_lock_time[65 - gnss_synchro.PRN]; } - lock_time_in_seconds = static_cast(lock_duration.total_seconds()); + const auto lock_time_in_seconds = static_cast(lock_duration.total_seconds()); return lock_time_in_seconds; } uint32_t Rtcm::lock_time(const Glonass_Gnav_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro) { - uint32_t lock_time_in_seconds; - boost::posix_time::ptime current_time = Rtcm::compute_GLONASS_time(eph, obs_time); + const boost::posix_time::ptime current_time = Rtcm::compute_GLONASS_time(eph, obs_time); boost::posix_time::ptime last_lock_time; std::string sig_(gnss_synchro.Signal); @@ -3538,7 +3541,7 @@ uint32_t Rtcm::lock_time(const Glonass_Gnav_Ephemeris& eph, double obs_time, con lock_duration = current_time - Rtcm::glo_L2_last_lock_time[65 - gnss_synchro.PRN]; } - lock_time_in_seconds = static_cast(lock_duration.total_seconds()); + const auto lock_time_in_seconds = static_cast(lock_duration.total_seconds()); return lock_time_in_seconds; } @@ -3766,7 +3769,7 @@ int32_t Rtcm::set_DF008(int16_t smoothing_interval) int32_t Rtcm::set_DF009(const Gnss_Synchro& gnss_synchro) { - uint32_t prn_ = gnss_synchro.PRN; + const uint32_t prn_ = gnss_synchro.PRN; if (prn_ > 32) { LOG(WARNING) << "GPS satellite ID must be between 1 and 32, but PRN " << prn_ << " was found"; @@ -3778,7 +3781,7 @@ int32_t Rtcm::set_DF009(const Gnss_Synchro& gnss_synchro) int32_t Rtcm::set_DF009(const Gps_Ephemeris& gps_eph) { - uint32_t prn_ = gps_eph.i_satellite_PRN; + const uint32_t prn_ = gps_eph.i_satellite_PRN; if (prn_ > 32) { LOG(WARNING) << "GPS satellite ID must be between 1 and 32, but PRN " << prn_ << " was found"; @@ -3797,8 +3800,8 @@ int32_t Rtcm::set_DF010(bool code_indicator) int32_t Rtcm::set_DF011(const Gnss_Synchro& gnss_synchro) { - double ambiguity = std::floor(gnss_synchro.Pseudorange_m / 299792.458); - auto gps_L1_pseudorange = static_cast(std::round((gnss_synchro.Pseudorange_m - ambiguity * 299792.458) / 0.02)); + const double ambiguity = std::floor(gnss_synchro.Pseudorange_m / 299792.458); + const auto gps_L1_pseudorange = static_cast(std::round((gnss_synchro.Pseudorange_m - ambiguity * 299792.458) / 0.02)); DF011 = std::bitset<24>(gps_L1_pseudorange); return 0; } @@ -3807,12 +3810,12 @@ int32_t Rtcm::set_DF011(const Gnss_Synchro& gnss_synchro) int32_t Rtcm::set_DF012(const Gnss_Synchro& gnss_synchro) { const double lambda = SPEED_OF_LIGHT_M_S / GPS_L1_FREQ_HZ; - double ambiguity = std::floor(gnss_synchro.Pseudorange_m / 299792.458); - double gps_L1_pseudorange = std::round((gnss_synchro.Pseudorange_m - ambiguity * 299792.458) / 0.02); - double gps_L1_pseudorange_c = gps_L1_pseudorange * 0.02 + ambiguity * 299792.458; - double L1_phaserange_c = gnss_synchro.Carrier_phase_rads / TWO_PI; - double L1_phaserange_c_r = std::fmod(L1_phaserange_c - gps_L1_pseudorange_c / lambda + 1500.0, 3000.0) - 1500.0; - auto gps_L1_phaserange_minus_L1_pseudorange = static_cast(std::round(L1_phaserange_c_r * lambda / 0.0005)); + const double ambiguity = std::floor(gnss_synchro.Pseudorange_m / 299792.458); + const double gps_L1_pseudorange = std::round((gnss_synchro.Pseudorange_m - ambiguity * 299792.458) / 0.02); + const double gps_L1_pseudorange_c = gps_L1_pseudorange * 0.02 + ambiguity * 299792.458; + const double L1_phaserange_c = gnss_synchro.Carrier_phase_rads / TWO_PI; + const double L1_phaserange_c_r = std::fmod(L1_phaserange_c - gps_L1_pseudorange_c / lambda + 1500.0, 3000.0) - 1500.0; + const auto gps_L1_phaserange_minus_L1_pseudorange = static_cast(std::round(L1_phaserange_c_r * lambda / 0.0005)); DF012 = std::bitset<20>(gps_L1_phaserange_minus_L1_pseudorange); return 0; } @@ -3820,9 +3823,8 @@ int32_t Rtcm::set_DF012(const Gnss_Synchro& gnss_synchro) int32_t Rtcm::set_DF013(const Gps_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro) { - uint32_t lock_time_indicator; - uint32_t lock_time_period_s = Rtcm::lock_time(eph, obs_time, gnss_synchro); - lock_time_indicator = Rtcm::lock_time_indicator(lock_time_period_s); + const uint32_t lock_time_period_s = Rtcm::lock_time(eph, obs_time, gnss_synchro); + const uint32_t lock_time_indicator = Rtcm::lock_time_indicator(lock_time_period_s); DF013 = std::bitset<7>(lock_time_indicator); return 0; } @@ -3830,7 +3832,7 @@ int32_t Rtcm::set_DF013(const Gps_Ephemeris& eph, double obs_time, const Gnss_Sy int32_t Rtcm::set_DF014(const Gnss_Synchro& gnss_synchro) { - auto gps_L1_pseudorange_ambiguity = static_cast(std::floor(gnss_synchro.Pseudorange_m / 299792.458)); + const auto gps_L1_pseudorange_ambiguity = static_cast(std::floor(gnss_synchro.Pseudorange_m / 299792.458)); DF014 = std::bitset<8>(gps_L1_pseudorange_ambiguity); return 0; } @@ -3843,7 +3845,7 @@ int32_t Rtcm::set_DF015(const Gnss_Synchro& gnss_synchro) { CN0_dB_Hz_est = 63.75; } - auto CN0_dB_Hz = static_cast(std::round(CN0_dB_Hz_est / 0.25)); + const auto CN0_dB_Hz = static_cast(std::round(CN0_dB_Hz_est / 0.25)); DF015 = std::bitset<8>(CN0_dB_Hz); return 0; } @@ -3851,11 +3853,11 @@ int32_t Rtcm::set_DF015(const Gnss_Synchro& gnss_synchro) int32_t Rtcm::set_DF017(const Gnss_Synchro& gnss_synchroL1, const Gnss_Synchro& gnss_synchroL2) { - double ambiguity = std::floor(gnss_synchroL1.Pseudorange_m / 299792.458); - double gps_L1_pseudorange = std::round((gnss_synchroL1.Pseudorange_m - ambiguity * 299792.458) / 0.02); - double gps_L1_pseudorange_c = gps_L1_pseudorange * 0.02 + ambiguity * 299792.458; + const double ambiguity = std::floor(gnss_synchroL1.Pseudorange_m / 299792.458); + const double gps_L1_pseudorange = std::round((gnss_synchroL1.Pseudorange_m - ambiguity * 299792.458) / 0.02); + const double gps_L1_pseudorange_c = gps_L1_pseudorange * 0.02 + ambiguity * 299792.458; - double l2_l1_pseudorange = gnss_synchroL2.Pseudorange_m - gps_L1_pseudorange_c; + const double l2_l1_pseudorange = gnss_synchroL2.Pseudorange_m - gps_L1_pseudorange_c; int32_t pseudorange_difference = 0xFFFFE000; // invalid value; if (std::fabs(l2_l1_pseudorange) <= 163.82) { @@ -3870,11 +3872,11 @@ int32_t Rtcm::set_DF018(const Gnss_Synchro& gnss_synchroL1, const Gnss_Synchro& { const double lambda2 = SPEED_OF_LIGHT_M_S / GPS_L2_FREQ_HZ; int32_t l2_phaserange_minus_l1_pseudorange = 0xFFF80000; - double ambiguity = std::floor(gnss_synchroL1.Pseudorange_m / 299792.458); - double gps_L1_pseudorange = std::round((gnss_synchroL1.Pseudorange_m - ambiguity * 299792.458) / 0.02); - double gps_L1_pseudorange_c = gps_L1_pseudorange * 0.02 + ambiguity * 299792.458; - double L2_phaserange_c = gnss_synchroL2.Carrier_phase_rads / TWO_PI; - double L1_phaserange_c_r = std::fmod(L2_phaserange_c - gps_L1_pseudorange_c / lambda2 + 1500.0, 3000.0) - 1500.0; + const double ambiguity = std::floor(gnss_synchroL1.Pseudorange_m / 299792.458); + const double gps_L1_pseudorange = std::round((gnss_synchroL1.Pseudorange_m - ambiguity * 299792.458) / 0.02); + const double gps_L1_pseudorange_c = gps_L1_pseudorange * 0.02 + ambiguity * 299792.458; + const double L2_phaserange_c = gnss_synchroL2.Carrier_phase_rads / TWO_PI; + const double L1_phaserange_c_r = std::fmod(L2_phaserange_c - gps_L1_pseudorange_c / lambda2 + 1500.0, 3000.0) - 1500.0; if (std::fabs(L1_phaserange_c_r * lambda2) <= 262.1435) { @@ -3888,9 +3890,8 @@ int32_t Rtcm::set_DF018(const Gnss_Synchro& gnss_synchroL1, const Gnss_Synchro& int32_t Rtcm::set_DF019(const Gps_CNAV_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro) { - uint32_t lock_time_indicator; - uint32_t lock_time_period_s = Rtcm::lock_time(eph, obs_time, gnss_synchro); - lock_time_indicator = Rtcm::lock_time_indicator(lock_time_period_s); + const uint32_t lock_time_period_s = Rtcm::lock_time(eph, obs_time, gnss_synchro); + const uint32_t lock_time_indicator = Rtcm::lock_time_indicator(lock_time_period_s); DF019 = std::bitset<7>(lock_time_indicator); return 0; } @@ -3903,14 +3904,14 @@ int32_t Rtcm::set_DF020(const Gnss_Synchro& gnss_synchro) { CN0_dB_Hz_est = 63.75; } - auto CN0_dB_Hz = static_cast(std::round(CN0_dB_Hz_est / 0.25)); + const auto CN0_dB_Hz = static_cast(std::round(CN0_dB_Hz_est / 0.25)); DF020 = std::bitset<8>(CN0_dB_Hz); return 0; } int32_t Rtcm::set_DF021() { - uint16_t itfr_year = 0; + const uint16_t itfr_year = 0; DF021 = std::bitset<6>(itfr_year); return 0; } @@ -3939,7 +3940,7 @@ int32_t Rtcm::set_DF024(bool galileo_indicator) int32_t Rtcm::set_DF025(double antenna_ECEF_X_m) { - auto ant_ref_x = static_cast(std::round(antenna_ECEF_X_m * 10000)); + const auto ant_ref_x = static_cast(std::round(antenna_ECEF_X_m * 10000)); DF025 = std::bitset<38>(ant_ref_x); return 0; } @@ -3947,7 +3948,7 @@ int32_t Rtcm::set_DF025(double antenna_ECEF_X_m) int32_t Rtcm::set_DF026(double antenna_ECEF_Y_m) { - auto ant_ref_y = static_cast(std::round(antenna_ECEF_Y_m * 10000)); + const auto ant_ref_y = static_cast(std::round(antenna_ECEF_Y_m * 10000)); DF026 = std::bitset<38>(ant_ref_y); return 0; } @@ -3955,7 +3956,7 @@ int32_t Rtcm::set_DF026(double antenna_ECEF_Y_m) int32_t Rtcm::set_DF027(double antenna_ECEF_Z_m) { - auto ant_ref_z = static_cast(std::round(antenna_ECEF_Z_m * 10000)); + const auto ant_ref_z = static_cast(std::round(antenna_ECEF_Z_m * 10000)); DF027 = std::bitset<38>(ant_ref_z); return 0; } @@ -3963,7 +3964,7 @@ int32_t Rtcm::set_DF027(double antenna_ECEF_Z_m) int32_t Rtcm::set_DF028(double height) { - auto h_ = static_cast(std::round(height * 10000)); + const auto h_ = static_cast(std::round(height * 10000)); DF028 = std::bitset<16>(h_); return 0; } @@ -4028,7 +4029,7 @@ int32_t Rtcm::set_DF037(int16_t smoothing_interval) int32_t Rtcm::set_DF038(const Gnss_Synchro& gnss_synchro) { - uint32_t prn_ = gnss_synchro.PRN; + const uint32_t prn_ = gnss_synchro.PRN; if (prn_ > 24) { LOG(WARNING) << "GLONASS satellite ID (Slot Number) must be between 1 and 24, but PRN " << prn_ << " was found"; @@ -4040,7 +4041,7 @@ int32_t Rtcm::set_DF038(const Gnss_Synchro& gnss_synchro) int32_t Rtcm::set_DF038(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - uint32_t prn_ = glonass_gnav_eph.i_satellite_slot_number; + const uint32_t prn_ = glonass_gnav_eph.i_satellite_slot_number; if (prn_ > 24) { LOG(WARNING) << "GLONASS satellite ID (Slot Number) must be between 0 and 24, but PRN " << prn_ << " was found"; @@ -4059,7 +4060,7 @@ int32_t Rtcm::set_DF039(bool code_indicator) int32_t Rtcm::set_DF040(int32_t frequency_channel_number) { - uint32_t freq_ = frequency_channel_number + 7; + const uint32_t freq_ = frequency_channel_number + 7; if (freq_ > 20) { LOG(WARNING) << "GLONASS Satellite Frequency Number Conversion Error." @@ -4074,7 +4075,7 @@ int32_t Rtcm::set_DF040(int32_t frequency_channel_number) int32_t Rtcm::set_DF040(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - uint32_t freq_ = glonass_gnav_eph.i_satellite_freq_channel + 7; + const uint32_t freq_ = glonass_gnav_eph.i_satellite_freq_channel + 7; if (freq_ > 20) { LOG(WARNING) << "GLONASS Satellite Frequency Number Conversion Error." @@ -4089,8 +4090,8 @@ int32_t Rtcm::set_DF040(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) int32_t Rtcm::set_DF041(const Gnss_Synchro& gnss_synchro) { - double ambiguity = std::floor(gnss_synchro.Pseudorange_m / 599584.92); - auto glonass_L1_pseudorange = static_cast(std::round((gnss_synchro.Pseudorange_m - ambiguity * 599584.92) / 0.02)); + const double ambiguity = std::floor(gnss_synchro.Pseudorange_m / 599584.92); + const auto glonass_L1_pseudorange = static_cast(std::round((gnss_synchro.Pseudorange_m - ambiguity * 599584.92) / 0.02)); DF041 = std::bitset<25>(glonass_L1_pseudorange); return 0; } @@ -4099,12 +4100,12 @@ int32_t Rtcm::set_DF041(const Gnss_Synchro& gnss_synchro) int32_t Rtcm::set_DF042(const Gnss_Synchro& gnss_synchro) { const double lambda = SPEED_OF_LIGHT_M_S / (GLONASS_L1_CA_FREQ_HZ + (GLONASS_L1_CA_DFREQ_HZ * GLONASS_PRN.at(gnss_synchro.PRN))); - double ambiguity = std::floor(gnss_synchro.Pseudorange_m / 599584.92); - double glonass_L1_pseudorange = std::round((gnss_synchro.Pseudorange_m - ambiguity * 599584.92) / 0.02); - double glonass_L1_pseudorange_c = glonass_L1_pseudorange * 0.02 + ambiguity * 299792.458; - double L1_phaserange_c = gnss_synchro.Carrier_phase_rads / TWO_PI; - double L1_phaserange_c_r = std::fmod(L1_phaserange_c - glonass_L1_pseudorange_c / lambda + 1500.0, 3000.0) - 1500.0; - auto glonass_L1_phaserange_minus_L1_pseudorange = static_cast(std::round(L1_phaserange_c_r * lambda / 0.0005)); + const double ambiguity = std::floor(gnss_synchro.Pseudorange_m / 599584.92); + const double glonass_L1_pseudorange = std::round((gnss_synchro.Pseudorange_m - ambiguity * 599584.92) / 0.02); + const double glonass_L1_pseudorange_c = glonass_L1_pseudorange * 0.02 + ambiguity * 299792.458; + const double L1_phaserange_c = gnss_synchro.Carrier_phase_rads / TWO_PI; + const double L1_phaserange_c_r = std::fmod(L1_phaserange_c - glonass_L1_pseudorange_c / lambda + 1500.0, 3000.0) - 1500.0; + const auto glonass_L1_phaserange_minus_L1_pseudorange = static_cast(std::round(L1_phaserange_c_r * lambda / 0.0005)); DF042 = std::bitset<20>(glonass_L1_phaserange_minus_L1_pseudorange); return 0; } @@ -4112,9 +4113,8 @@ int32_t Rtcm::set_DF042(const Gnss_Synchro& gnss_synchro) int32_t Rtcm::set_DF043(const Glonass_Gnav_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro) { - uint32_t lock_time_indicator; - uint32_t lock_time_period_s = Rtcm::lock_time(eph, obs_time, gnss_synchro); - lock_time_indicator = Rtcm::lock_time_indicator(lock_time_period_s); + const uint32_t lock_time_period_s = Rtcm::lock_time(eph, obs_time, gnss_synchro); + const uint32_t lock_time_indicator = Rtcm::lock_time_indicator(lock_time_period_s); DF043 = std::bitset<7>(lock_time_indicator); return 0; } @@ -4122,7 +4122,7 @@ int32_t Rtcm::set_DF043(const Glonass_Gnav_Ephemeris& eph, double obs_time, cons int32_t Rtcm::set_DF044(const Gnss_Synchro& gnss_synchro) { - auto glonass_L1_pseudorange_ambiguity = static_cast(std::floor(gnss_synchro.Pseudorange_m / 599584.916)); + const auto glonass_L1_pseudorange_ambiguity = static_cast(std::floor(gnss_synchro.Pseudorange_m / 599584.916)); DF044 = std::bitset<7>(glonass_L1_pseudorange_ambiguity); return 0; } @@ -4136,7 +4136,7 @@ int32_t Rtcm::set_DF045(const Gnss_Synchro& gnss_synchro) LOG(WARNING) << "GLONASS L1 CNR must be between 0 and 63.75, but CNR " << CN0_dB_Hz_est << " was found. Setting to 63.75 dB-Hz"; CN0_dB_Hz_est = 63.75; } - auto CN0_dB_Hz = static_cast(std::round(CN0_dB_Hz_est / 0.25)); + const auto CN0_dB_Hz = static_cast(std::round(CN0_dB_Hz_est / 0.25)); DF045 = std::bitset<8>(CN0_dB_Hz); return 0; } @@ -4144,11 +4144,11 @@ int32_t Rtcm::set_DF045(const Gnss_Synchro& gnss_synchro) int32_t Rtcm::set_DF047(const Gnss_Synchro& gnss_synchroL1, const Gnss_Synchro& gnss_synchroL2) { - double ambiguity = std::floor(gnss_synchroL1.Pseudorange_m / 599584.92); - double glonass_L1_pseudorange = std::round((gnss_synchroL1.Pseudorange_m - ambiguity * 599584.92) / 0.02); - double glonass_L1_pseudorange_c = glonass_L1_pseudorange * 0.02 + ambiguity * 599584.92; + const double ambiguity = std::floor(gnss_synchroL1.Pseudorange_m / 599584.92); + const double glonass_L1_pseudorange = std::round((gnss_synchroL1.Pseudorange_m - ambiguity * 599584.92) / 0.02); + const double glonass_L1_pseudorange_c = glonass_L1_pseudorange * 0.02 + ambiguity * 599584.92; - double l2_l1_pseudorange = gnss_synchroL2.Pseudorange_m - glonass_L1_pseudorange_c; + const double l2_l1_pseudorange = gnss_synchroL2.Pseudorange_m - glonass_L1_pseudorange_c; int32_t pseudorange_difference = 0xFFFFE000; // invalid value; if (std::fabs(l2_l1_pseudorange) <= 163.82) { @@ -4163,11 +4163,11 @@ int32_t Rtcm::set_DF048(const Gnss_Synchro& gnss_synchroL1, const Gnss_Synchro& { const double lambda2 = SPEED_OF_LIGHT_M_S / GLONASS_L2_CA_FREQ_HZ; int32_t l2_phaserange_minus_l1_pseudorange = 0xFFF80000; - double ambiguity = std::floor(gnss_synchroL1.Pseudorange_m / 599584.92); - double glonass_L1_pseudorange = std::round((gnss_synchroL1.Pseudorange_m - ambiguity * 599584.92) / 0.02); - double glonass_L1_pseudorange_c = glonass_L1_pseudorange * 0.02 + ambiguity * 599584.92; - double L2_phaserange_c = gnss_synchroL2.Carrier_phase_rads / TWO_PI; - double L1_phaserange_c_r = std::fmod(L2_phaserange_c - glonass_L1_pseudorange_c / lambda2 + 1500.0, 3000.0) - 1500.0; + const double ambiguity = std::floor(gnss_synchroL1.Pseudorange_m / 599584.92); + const double glonass_L1_pseudorange = std::round((gnss_synchroL1.Pseudorange_m - ambiguity * 599584.92) / 0.02); + const double glonass_L1_pseudorange_c = glonass_L1_pseudorange * 0.02 + ambiguity * 599584.92; + const double L2_phaserange_c = gnss_synchroL2.Carrier_phase_rads / TWO_PI; + const double L1_phaserange_c_r = std::fmod(L2_phaserange_c - glonass_L1_pseudorange_c / lambda2 + 1500.0, 3000.0) - 1500.0; if (std::fabs(L1_phaserange_c_r * lambda2) <= 262.1435) { @@ -4181,9 +4181,8 @@ int32_t Rtcm::set_DF048(const Gnss_Synchro& gnss_synchroL1, const Gnss_Synchro& int32_t Rtcm::set_DF049(const Glonass_Gnav_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro) { - uint32_t lock_time_indicator; - uint32_t lock_time_period_s = Rtcm::lock_time(eph, obs_time, gnss_synchro); - lock_time_indicator = Rtcm::lock_time_indicator(lock_time_period_s); + const uint32_t lock_time_period_s = Rtcm::lock_time(eph, obs_time, gnss_synchro); + const uint32_t lock_time_indicator = Rtcm::lock_time_indicator(lock_time_period_s); DF049 = std::bitset<7>(lock_time_indicator); return 0; } @@ -4196,7 +4195,7 @@ int32_t Rtcm::set_DF050(const Gnss_Synchro& gnss_synchro) { CN0_dB_Hz_est = 63.75; } - auto CN0_dB_Hz = static_cast(std::round(CN0_dB_Hz_est / 0.25)); + const auto CN0_dB_Hz = static_cast(std::round(CN0_dB_Hz_est / 0.25)); DF050 = std::bitset<8>(CN0_dB_Hz); return 0; } @@ -4205,7 +4204,7 @@ int32_t Rtcm::set_DF050(const Gnss_Synchro& gnss_synchro) int32_t Rtcm::set_DF051(const Gps_Ephemeris& gps_eph, double obs_time) { const double gps_t = obs_time; - boost::posix_time::time_duration t_duration = boost::posix_time::milliseconds(static_cast((gps_t + 604800 * static_cast(gps_eph.i_GPS_week)) * 1000)); + const boost::posix_time::time_duration t_duration = boost::posix_time::milliseconds(static_cast((gps_t + 604800 * static_cast(gps_eph.i_GPS_week)) * 1000)); std::string now_ptime; if (gps_eph.i_GPS_week < 512) { @@ -4217,7 +4216,7 @@ int32_t Rtcm::set_DF051(const Gps_Ephemeris& gps_eph, double obs_time) boost::posix_time::ptime p_time(boost::gregorian::date(1999, 8, 22), t_duration); now_ptime = to_iso_string(p_time); } - std::string today_ptime = now_ptime.substr(0, 8); + const std::string today_ptime = now_ptime.substr(0, 8); boost::gregorian::date d(boost::gregorian::from_undelimited_string(today_ptime)); uint32_t mjd = d.modjulian_day(); DF051 = std::bitset<16>(mjd); @@ -4228,7 +4227,7 @@ int32_t Rtcm::set_DF051(const Gps_Ephemeris& gps_eph, double obs_time) int32_t Rtcm::set_DF052(const Gps_Ephemeris& gps_eph, double obs_time) { const double gps_t = obs_time; - boost::posix_time::time_duration t_duration = boost::posix_time::milliseconds(static_cast((gps_t + 604800 * static_cast(gps_eph.i_GPS_week)) * 1000)); + const boost::posix_time::time_duration t_duration = boost::posix_time::milliseconds(static_cast((gps_t + 604800 * static_cast(gps_eph.i_GPS_week)) * 1000)); std::string now_ptime; if (gps_eph.i_GPS_week < 512) { @@ -4240,9 +4239,9 @@ int32_t Rtcm::set_DF052(const Gps_Ephemeris& gps_eph, double obs_time) boost::posix_time::ptime p_time(boost::gregorian::date(1999, 8, 22), t_duration); now_ptime = to_iso_string(p_time); } - std::string hours = now_ptime.substr(9, 2); - std::string minutes = now_ptime.substr(11, 2); - std::string seconds = now_ptime.substr(13, 8); + const std::string hours = now_ptime.substr(9, 2); + const std::string minutes = now_ptime.substr(11, 2); + const std::string seconds = now_ptime.substr(13, 8); // boost::gregorian::date d(boost::gregorian::from_undelimited_string(today_ptime)); uint32_t seconds_of_day = boost::lexical_cast(hours) * 60 * 60 + boost::lexical_cast(minutes) * 60 + boost::lexical_cast(seconds); DF052 = std::bitset<17>(seconds_of_day); @@ -4252,7 +4251,7 @@ int32_t Rtcm::set_DF052(const Gps_Ephemeris& gps_eph, double obs_time) int32_t Rtcm::set_DF071(const Gps_Ephemeris& gps_eph) { - auto iode = static_cast(gps_eph.d_IODE_SF2); + const auto iode = static_cast(gps_eph.d_IODE_SF2); DF071 = std::bitset<8>(iode); return 0; } @@ -4260,7 +4259,7 @@ int32_t Rtcm::set_DF071(const Gps_Ephemeris& gps_eph) int32_t Rtcm::set_DF076(const Gps_Ephemeris& gps_eph) { - auto week_number = static_cast(gps_eph.i_GPS_week); + const auto week_number = static_cast(gps_eph.i_GPS_week); DF076 = std::bitset<10>(week_number); return 0; } @@ -4268,7 +4267,7 @@ int32_t Rtcm::set_DF076(const Gps_Ephemeris& gps_eph) int32_t Rtcm::set_DF077(const Gps_Ephemeris& gps_eph) { - auto ura = static_cast(gps_eph.i_SV_accuracy); + const auto ura = static_cast(gps_eph.i_SV_accuracy); DF077 = std::bitset<4>(ura); return 0; } @@ -4276,7 +4275,7 @@ int32_t Rtcm::set_DF077(const Gps_Ephemeris& gps_eph) int32_t Rtcm::set_DF078(const Gps_Ephemeris& gps_eph) { - auto code_on_L2 = static_cast(gps_eph.i_code_on_L2); + const auto code_on_L2 = static_cast(gps_eph.i_code_on_L2); DF078 = std::bitset<2>(code_on_L2); return 0; } @@ -4284,7 +4283,7 @@ int32_t Rtcm::set_DF078(const Gps_Ephemeris& gps_eph) int32_t Rtcm::set_DF079(const Gps_Ephemeris& gps_eph) { - auto idot = static_cast(std::round(gps_eph.d_IDOT / I_DOT_LSB)); + const auto idot = static_cast(std::round(gps_eph.d_IDOT / I_DOT_LSB)); DF079 = std::bitset<14>(idot); return 0; } @@ -4292,7 +4291,7 @@ int32_t Rtcm::set_DF079(const Gps_Ephemeris& gps_eph) int32_t Rtcm::set_DF080(const Gps_Ephemeris& gps_eph) { - auto iode = static_cast(gps_eph.d_IODE_SF2); + const auto iode = static_cast(gps_eph.d_IODE_SF2); DF080 = std::bitset<8>(iode); return 0; } @@ -4300,7 +4299,7 @@ int32_t Rtcm::set_DF080(const Gps_Ephemeris& gps_eph) int32_t Rtcm::set_DF081(const Gps_Ephemeris& gps_eph) { - auto toc = static_cast(std::round(gps_eph.d_Toc / T_OC_LSB)); + const auto toc = static_cast(std::round(gps_eph.d_Toc / T_OC_LSB)); DF081 = std::bitset<16>(toc); return 0; } @@ -4308,7 +4307,7 @@ int32_t Rtcm::set_DF081(const Gps_Ephemeris& gps_eph) int32_t Rtcm::set_DF082(const Gps_Ephemeris& gps_eph) { - auto af2 = static_cast(std::round(gps_eph.d_A_f2 / A_F2_LSB)); + const auto af2 = static_cast(std::round(gps_eph.d_A_f2 / A_F2_LSB)); DF082 = std::bitset<8>(af2); return 0; } @@ -4316,7 +4315,7 @@ int32_t Rtcm::set_DF082(const Gps_Ephemeris& gps_eph) int32_t Rtcm::set_DF083(const Gps_Ephemeris& gps_eph) { - auto af1 = static_cast(std::round(gps_eph.d_A_f1 / A_F1_LSB)); + const auto af1 = static_cast(std::round(gps_eph.d_A_f1 / A_F1_LSB)); DF083 = std::bitset<16>(af1); return 0; } @@ -4324,7 +4323,7 @@ int32_t Rtcm::set_DF083(const Gps_Ephemeris& gps_eph) int32_t Rtcm::set_DF084(const Gps_Ephemeris& gps_eph) { - auto af0 = static_cast(std::round(gps_eph.d_A_f0 / A_F0_LSB)); + const auto af0 = static_cast(std::round(gps_eph.d_A_f0 / A_F0_LSB)); DF084 = std::bitset<22>(af0); return 0; } @@ -4332,7 +4331,7 @@ int32_t Rtcm::set_DF084(const Gps_Ephemeris& gps_eph) int32_t Rtcm::set_DF085(const Gps_Ephemeris& gps_eph) { - auto iodc = static_cast(gps_eph.d_IODC); + const auto iodc = static_cast(gps_eph.d_IODC); DF085 = std::bitset<10>(iodc); return 0; } @@ -4340,7 +4339,7 @@ int32_t Rtcm::set_DF085(const Gps_Ephemeris& gps_eph) int32_t Rtcm::set_DF086(const Gps_Ephemeris& gps_eph) { - auto crs = static_cast(std::round(gps_eph.d_Crs / C_RS_LSB)); + const auto crs = static_cast(std::round(gps_eph.d_Crs / C_RS_LSB)); DF086 = std::bitset<16>(crs); return 0; } @@ -4348,7 +4347,7 @@ int32_t Rtcm::set_DF086(const Gps_Ephemeris& gps_eph) int32_t Rtcm::set_DF087(const Gps_Ephemeris& gps_eph) { - auto delta_n = static_cast(std::round(gps_eph.d_Delta_n / DELTA_N_LSB)); + const auto delta_n = static_cast(std::round(gps_eph.d_Delta_n / DELTA_N_LSB)); DF087 = std::bitset<16>(delta_n); return 0; } @@ -4356,7 +4355,7 @@ int32_t Rtcm::set_DF087(const Gps_Ephemeris& gps_eph) int32_t Rtcm::set_DF088(const Gps_Ephemeris& gps_eph) { - auto m0 = static_cast(std::round(gps_eph.d_M_0 / M_0_LSB)); + const auto m0 = static_cast(std::round(gps_eph.d_M_0 / M_0_LSB)); DF088 = std::bitset<32>(m0); return 0; } @@ -4364,14 +4363,14 @@ int32_t Rtcm::set_DF088(const Gps_Ephemeris& gps_eph) int32_t Rtcm::set_DF089(const Gps_Ephemeris& gps_eph) { - auto cuc = static_cast(std::round(gps_eph.d_Cuc / C_UC_LSB)); + const auto cuc = static_cast(std::round(gps_eph.d_Cuc / C_UC_LSB)); DF089 = std::bitset<16>(cuc); return 0; } int32_t Rtcm::set_DF090(const Gps_Ephemeris& gps_eph) { - auto ecc = static_cast(std::round(gps_eph.d_e_eccentricity / ECCENTRICITY_LSB)); + const auto ecc = static_cast(std::round(gps_eph.d_e_eccentricity / ECCENTRICITY_LSB)); DF090 = std::bitset<32>(ecc); return 0; } @@ -4379,7 +4378,7 @@ int32_t Rtcm::set_DF090(const Gps_Ephemeris& gps_eph) int32_t Rtcm::set_DF091(const Gps_Ephemeris& gps_eph) { - auto cus = static_cast(std::round(gps_eph.d_Cus / C_US_LSB)); + const auto cus = static_cast(std::round(gps_eph.d_Cus / C_US_LSB)); DF091 = std::bitset<16>(cus); return 0; } @@ -4387,7 +4386,7 @@ int32_t Rtcm::set_DF091(const Gps_Ephemeris& gps_eph) int32_t Rtcm::set_DF092(const Gps_Ephemeris& gps_eph) { - auto sqr_a = static_cast(std::round(gps_eph.d_sqrt_A / SQRT_A_LSB)); + const auto sqr_a = static_cast(std::round(gps_eph.d_sqrt_A / SQRT_A_LSB)); DF092 = std::bitset<32>(sqr_a); return 0; } @@ -4395,7 +4394,7 @@ int32_t Rtcm::set_DF092(const Gps_Ephemeris& gps_eph) int32_t Rtcm::set_DF093(const Gps_Ephemeris& gps_eph) { - auto toe = static_cast(std::round(gps_eph.d_Toe / T_OE_LSB)); + const auto toe = static_cast(std::round(gps_eph.d_Toe / T_OE_LSB)); DF093 = std::bitset<16>(toe); return 0; } @@ -4403,7 +4402,7 @@ int32_t Rtcm::set_DF093(const Gps_Ephemeris& gps_eph) int32_t Rtcm::set_DF094(const Gps_Ephemeris& gps_eph) { - auto cic = static_cast(std::round(gps_eph.d_Cic / C_IC_LSB)); + const auto cic = static_cast(std::round(gps_eph.d_Cic / C_IC_LSB)); DF094 = std::bitset<16>(cic); return 0; } @@ -4411,7 +4410,7 @@ int32_t Rtcm::set_DF094(const Gps_Ephemeris& gps_eph) int32_t Rtcm::set_DF095(const Gps_Ephemeris& gps_eph) { - auto Omega0 = static_cast(std::round(gps_eph.d_OMEGA0 / OMEGA_0_LSB)); + const auto Omega0 = static_cast(std::round(gps_eph.d_OMEGA0 / OMEGA_0_LSB)); DF095 = std::bitset<32>(Omega0); return 0; } @@ -4419,7 +4418,7 @@ int32_t Rtcm::set_DF095(const Gps_Ephemeris& gps_eph) int32_t Rtcm::set_DF096(const Gps_Ephemeris& gps_eph) { - auto cis = static_cast(std::round(gps_eph.d_Cis / C_IS_LSB)); + const auto cis = static_cast(std::round(gps_eph.d_Cis / C_IS_LSB)); DF096 = std::bitset<16>(cis); return 0; } @@ -4427,7 +4426,7 @@ int32_t Rtcm::set_DF096(const Gps_Ephemeris& gps_eph) int32_t Rtcm::set_DF097(const Gps_Ephemeris& gps_eph) { - auto i0 = static_cast(std::round(gps_eph.d_i_0 / I_0_LSB)); + const auto i0 = static_cast(std::round(gps_eph.d_i_0 / I_0_LSB)); DF097 = std::bitset<32>(i0); return 0; } @@ -4435,7 +4434,7 @@ int32_t Rtcm::set_DF097(const Gps_Ephemeris& gps_eph) int32_t Rtcm::set_DF098(const Gps_Ephemeris& gps_eph) { - auto crc = static_cast(std::round(gps_eph.d_Crc / C_RC_LSB)); + const auto crc = static_cast(std::round(gps_eph.d_Crc / C_RC_LSB)); DF098 = std::bitset<16>(crc); return 0; } @@ -4443,7 +4442,7 @@ int32_t Rtcm::set_DF098(const Gps_Ephemeris& gps_eph) int32_t Rtcm::set_DF099(const Gps_Ephemeris& gps_eph) { - auto omega = static_cast(std::round(gps_eph.d_OMEGA / OMEGA_LSB)); + const auto omega = static_cast(std::round(gps_eph.d_OMEGA / OMEGA_LSB)); DF099 = std::bitset<32>(omega); return 0; } @@ -4451,7 +4450,7 @@ int32_t Rtcm::set_DF099(const Gps_Ephemeris& gps_eph) int32_t Rtcm::set_DF100(const Gps_Ephemeris& gps_eph) { - auto omegadot = static_cast(std::round(gps_eph.d_OMEGA_DOT / OMEGA_DOT_LSB)); + const auto omegadot = static_cast(std::round(gps_eph.d_OMEGA_DOT / OMEGA_DOT_LSB)); DF100 = std::bitset<24>(omegadot); return 0; } @@ -4459,7 +4458,7 @@ int32_t Rtcm::set_DF100(const Gps_Ephemeris& gps_eph) int32_t Rtcm::set_DF101(const Gps_Ephemeris& gps_eph) { - auto tgd = static_cast(std::round(gps_eph.d_TGD / T_GD_LSB)); + const auto tgd = static_cast(std::round(gps_eph.d_TGD / T_GD_LSB)); DF101 = std::bitset<8>(tgd); return 0; } @@ -4467,7 +4466,7 @@ int32_t Rtcm::set_DF101(const Gps_Ephemeris& gps_eph) int32_t Rtcm::set_DF102(const Gps_Ephemeris& gps_eph) { - auto sv_heath = static_cast(gps_eph.i_SV_health); + const auto sv_heath = static_cast(gps_eph.i_SV_health); DF102 = std::bitset<6>(sv_heath); return 0; } @@ -4497,7 +4496,7 @@ int32_t Rtcm::set_DF105(uint32_t glonass_gnav_alm_health_ind) int32_t Rtcm::set_DF106(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { // Convert the value from (15, 30, 45, 60) to (00, 01, 10, 11) - auto P_1 = static_cast(std::round(glonass_gnav_eph.d_P_1 / 15.0 - 1.0)); + const auto P_1 = static_cast(std::round(glonass_gnav_eph.d_P_1 / 15.0 - 1.0)); DF106 = std::bitset<2>(P_1); return 0; } @@ -4541,7 +4540,7 @@ int32_t Rtcm::set_DF109(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) int32_t Rtcm::set_DF110(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - auto t_b = static_cast(std::round(glonass_gnav_eph.d_t_b / (15 * 60))); + const auto t_b = static_cast(std::round(glonass_gnav_eph.d_t_b / (15 * 60))); DF110 = std::bitset<7>(t_b); return 0; } @@ -4549,8 +4548,8 @@ int32_t Rtcm::set_DF110(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) int32_t Rtcm::set_DF111(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - auto VXn_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_VXn / TWO_N20))); - uint32_t VXn_sgn = glo_sgn(glonass_gnav_eph.d_VXn); + const auto VXn_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_VXn / TWO_N20))); + const uint32_t VXn_sgn = glo_sgn(glonass_gnav_eph.d_VXn); DF111 = std::bitset<24>(VXn_mag); DF111.set(23, VXn_sgn); @@ -4560,8 +4559,8 @@ int32_t Rtcm::set_DF111(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) int32_t Rtcm::set_DF112(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - auto Xn_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_Xn / TWO_N11))); - uint32_t Xn_sgn = glo_sgn(glonass_gnav_eph.d_Xn); + const auto Xn_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_Xn / TWO_N11))); + const uint32_t Xn_sgn = glo_sgn(glonass_gnav_eph.d_Xn); DF112 = std::bitset<27>(Xn_mag); DF112.set(26, Xn_sgn); @@ -4571,8 +4570,8 @@ int32_t Rtcm::set_DF112(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) int32_t Rtcm::set_DF113(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - auto AXn_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_AXn / TWO_N30))); - uint32_t AXn_sgn = glo_sgn(glonass_gnav_eph.d_AXn); + const auto AXn_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_AXn / TWO_N30))); + const uint32_t AXn_sgn = glo_sgn(glonass_gnav_eph.d_AXn); DF113 = std::bitset<5>(AXn_mag); DF113.set(4, AXn_sgn); @@ -4582,8 +4581,8 @@ int32_t Rtcm::set_DF113(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) int32_t Rtcm::set_DF114(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - auto VYn_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_VYn / TWO_N20))); - uint32_t VYn_sgn = glo_sgn(glonass_gnav_eph.d_VYn); + const auto VYn_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_VYn / TWO_N20))); + const uint32_t VYn_sgn = glo_sgn(glonass_gnav_eph.d_VYn); DF114 = std::bitset<24>(VYn_mag); DF114.set(23, VYn_sgn); @@ -4593,8 +4592,8 @@ int32_t Rtcm::set_DF114(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) int32_t Rtcm::set_DF115(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - auto Yn_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_Yn / TWO_N11))); - uint32_t Yn_sgn = glo_sgn(glonass_gnav_eph.d_Yn); + const auto Yn_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_Yn / TWO_N11))); + const uint32_t Yn_sgn = glo_sgn(glonass_gnav_eph.d_Yn); DF115 = std::bitset<27>(Yn_mag); DF115.set(26, Yn_sgn); @@ -4604,8 +4603,8 @@ int32_t Rtcm::set_DF115(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) int32_t Rtcm::set_DF116(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - auto AYn_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_AYn / TWO_N30))); - uint32_t AYn_sgn = glo_sgn(glonass_gnav_eph.d_AYn); + const auto AYn_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_AYn / TWO_N30))); + const uint32_t AYn_sgn = glo_sgn(glonass_gnav_eph.d_AYn); DF116 = std::bitset<5>(AYn_mag); DF116.set(4, AYn_sgn); @@ -4615,8 +4614,8 @@ int32_t Rtcm::set_DF116(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) int32_t Rtcm::set_DF117(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - auto VZn_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_VZn / TWO_N20))); - uint32_t VZn_sgn = glo_sgn(glonass_gnav_eph.d_VZn); + const auto VZn_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_VZn / TWO_N20))); + const uint32_t VZn_sgn = glo_sgn(glonass_gnav_eph.d_VZn); DF117 = std::bitset<24>(VZn_mag); DF117.set(23, VZn_sgn); @@ -4626,8 +4625,8 @@ int32_t Rtcm::set_DF117(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) int32_t Rtcm::set_DF118(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - auto Zn_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_Zn / TWO_N11))); - uint32_t Zn_sgn = glo_sgn(glonass_gnav_eph.d_Zn); + const auto Zn_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_Zn / TWO_N11))); + const uint32_t Zn_sgn = glo_sgn(glonass_gnav_eph.d_Zn); DF118 = std::bitset<27>(Zn_mag); DF118.set(26, Zn_sgn); @@ -4637,8 +4636,8 @@ int32_t Rtcm::set_DF118(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) int32_t Rtcm::set_DF119(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - auto AZn_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_AZn / TWO_N30))); - uint32_t AZn_sgn = glo_sgn(glonass_gnav_eph.d_AZn); + const auto AZn_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_AZn / TWO_N30))); + const uint32_t AZn_sgn = glo_sgn(glonass_gnav_eph.d_AZn); DF119 = std::bitset<5>(AZn_mag); DF119.set(4, AZn_sgn); @@ -4648,7 +4647,7 @@ int32_t Rtcm::set_DF119(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) int32_t Rtcm::set_DF120(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - auto P3_aux = static_cast(std::round(glonass_gnav_eph.d_P_3)); + const auto P3_aux = static_cast(std::round(glonass_gnav_eph.d_P_3)); DF120 = std::bitset<1>(P3_aux); return 0; } @@ -4656,8 +4655,8 @@ int32_t Rtcm::set_DF120(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) int32_t Rtcm::set_DF121(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - auto gamma_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_gamma_n / TWO_N40))); - uint32_t gamma_sgn = glo_sgn(glonass_gnav_eph.d_gamma_n); + const auto gamma_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_gamma_n / TWO_N40))); + const uint32_t gamma_sgn = glo_sgn(glonass_gnav_eph.d_gamma_n); DF121 = std::bitset<11>(gamma_mag); DF121.set(10, gamma_sgn); @@ -4667,7 +4666,7 @@ int32_t Rtcm::set_DF121(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) int32_t Rtcm::set_DF122(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - auto P_aux = static_cast(std::round(glonass_gnav_eph.d_P)); + const auto P_aux = static_cast(std::round(glonass_gnav_eph.d_P)); DF122 = std::bitset<2>(P_aux); return 0; } @@ -4675,7 +4674,7 @@ int32_t Rtcm::set_DF122(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) int32_t Rtcm::set_DF123(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - auto ln = static_cast((glonass_gnav_eph.d_l3rd_n)); + const auto ln = static_cast((glonass_gnav_eph.d_l3rd_n)); DF123 = std::bitset<1>(ln); return 0; } @@ -4683,8 +4682,8 @@ int32_t Rtcm::set_DF123(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) int32_t Rtcm::set_DF124(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - auto tau_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_tau_n / TWO_N30))); - uint32_t tau_sgn = glo_sgn(glonass_gnav_eph.d_tau_n); + const auto tau_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_tau_n / TWO_N30))); + const uint32_t tau_sgn = glo_sgn(glonass_gnav_eph.d_tau_n); DF124 = std::bitset<22>(tau_mag); DF124.set(21, tau_sgn); @@ -4694,8 +4693,8 @@ int32_t Rtcm::set_DF124(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) int32_t Rtcm::set_DF125(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - auto delta_tau_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_Delta_tau_n / TWO_N30))); - uint32_t delta_tau_sgn = glo_sgn(glonass_gnav_eph.d_Delta_tau_n); + const auto delta_tau_mag = static_cast(std::round(fabs(glonass_gnav_eph.d_Delta_tau_n / TWO_N30))); + const uint32_t delta_tau_sgn = glo_sgn(glonass_gnav_eph.d_Delta_tau_n); DF125 = std::bitset<5>(delta_tau_mag); DF125.set(4, delta_tau_sgn); @@ -4705,7 +4704,7 @@ int32_t Rtcm::set_DF125(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) int32_t Rtcm::set_DF126(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - auto ecc = static_cast(std::round(glonass_gnav_eph.d_E_n)); + const auto ecc = static_cast(std::round(glonass_gnav_eph.d_E_n)); DF126 = std::bitset<5>(ecc); return 0; } @@ -4713,7 +4712,7 @@ int32_t Rtcm::set_DF126(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) int32_t Rtcm::set_DF127(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - auto P4_aux = static_cast(std::round(glonass_gnav_eph.d_P_4)); + const auto P4_aux = static_cast(std::round(glonass_gnav_eph.d_P_4)); DF127 = std::bitset<1>(P4_aux); return 0; } @@ -4721,7 +4720,7 @@ int32_t Rtcm::set_DF127(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) int32_t Rtcm::set_DF128(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - auto F_t = static_cast(std::round(glonass_gnav_eph.d_F_T)); + const auto F_t = static_cast(std::round(glonass_gnav_eph.d_F_T)); DF128 = std::bitset<4>(F_t); return 0; } @@ -4729,7 +4728,7 @@ int32_t Rtcm::set_DF128(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) int32_t Rtcm::set_DF129(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - auto N_t = static_cast(std::round(glonass_gnav_eph.d_N_T)); + const auto N_t = static_cast(std::round(glonass_gnav_eph.d_N_T)); DF129 = std::bitset<11>(N_t); return 0; } @@ -4737,7 +4736,7 @@ int32_t Rtcm::set_DF129(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) int32_t Rtcm::set_DF130(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - auto M_aux = static_cast(std::round(glonass_gnav_eph.d_M)); + const auto M_aux = static_cast(std::round(glonass_gnav_eph.d_M)); DF130 = std::bitset<2>(M_aux); return 0; } @@ -4745,7 +4744,7 @@ int32_t Rtcm::set_DF130(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) int32_t Rtcm::set_DF131(uint32_t fifth_str_additional_data_ind) { - auto fith_str_data = static_cast(fifth_str_additional_data_ind); + const auto fith_str_data = static_cast(fifth_str_additional_data_ind); DF131 = std::bitset<1>(fith_str_data); return 0; } @@ -4753,7 +4752,7 @@ int32_t Rtcm::set_DF131(uint32_t fifth_str_additional_data_ind) int32_t Rtcm::set_DF132(const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model) { - auto N_A_aux = static_cast(std::round(glonass_gnav_utc_model.d_N_A)); + const auto N_A_aux = static_cast(std::round(glonass_gnav_utc_model.d_N_A)); DF132 = std::bitset<11>(N_A_aux); return 0; } @@ -4761,7 +4760,7 @@ int32_t Rtcm::set_DF132(const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model) int32_t Rtcm::set_DF133(const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model) { - auto tau_c = static_cast(std::round(glonass_gnav_utc_model.d_tau_c / TWO_N31)); + const auto tau_c = static_cast(std::round(glonass_gnav_utc_model.d_tau_c / TWO_N31)); DF133 = std::bitset<32>(tau_c); return 0; } @@ -4769,7 +4768,7 @@ int32_t Rtcm::set_DF133(const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model) int32_t Rtcm::set_DF134(const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model) { - auto N_4_aux = static_cast(std::round(glonass_gnav_utc_model.d_N_4)); + const auto N_4_aux = static_cast(std::round(glonass_gnav_utc_model.d_N_4)); DF134 = std::bitset<5>(N_4_aux); return 0; } @@ -4777,7 +4776,7 @@ int32_t Rtcm::set_DF134(const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model) int32_t Rtcm::set_DF135(const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model) { - auto tau_gps = static_cast(std::round(glonass_gnav_utc_model.d_tau_gps) / TWO_N30); + const auto tau_gps = static_cast(std::round(glonass_gnav_utc_model.d_tau_gps) / TWO_N30); DF135 = std::bitset<22>(tau_gps); return 0; } @@ -4785,7 +4784,7 @@ int32_t Rtcm::set_DF135(const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model) int32_t Rtcm::set_DF136(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - auto l_n = static_cast(std::round(glonass_gnav_eph.d_l5th_n)); + const auto l_n = static_cast(std::round(glonass_gnav_eph.d_l5th_n)); DF136 = std::bitset<1>(l_n); return 0; } @@ -4814,7 +4813,7 @@ int32_t Rtcm::set_DF248(double obs_time) int32_t Rtcm::set_DF252(const Galileo_Ephemeris& gal_eph) { - uint32_t prn_ = gal_eph.i_satellite_PRN; + const uint32_t prn_ = gal_eph.i_satellite_PRN; if (prn_ > 63) { LOG(WARNING) << "Galileo satellite ID must be between 0 and 63, but PRN " << prn_ << " was found"; @@ -4826,7 +4825,7 @@ int32_t Rtcm::set_DF252(const Galileo_Ephemeris& gal_eph) int32_t Rtcm::set_DF289(const Galileo_Ephemeris& gal_eph) { - auto galileo_week_number = static_cast(gal_eph.WN_5); + const auto galileo_week_number = static_cast(gal_eph.WN_5); if (galileo_week_number > 4095) { LOG(WARNING) << "Error decoding Galileo week number (it has a 4096 roll-off, but " << galileo_week_number << " was detected)"; @@ -4838,7 +4837,7 @@ int32_t Rtcm::set_DF289(const Galileo_Ephemeris& gal_eph) int32_t Rtcm::set_DF290(const Galileo_Ephemeris& gal_eph) { - auto iod_nav = static_cast(gal_eph.IOD_nav_1); + const auto iod_nav = static_cast(gal_eph.IOD_nav_1); if (iod_nav > 1023) { LOG(WARNING) << "Error decoding Galileo IODnav (it has a max of 1023, but " << iod_nav << " was detected)"; @@ -4850,7 +4849,7 @@ int32_t Rtcm::set_DF290(const Galileo_Ephemeris& gal_eph) int32_t Rtcm::set_DF291(const Galileo_Ephemeris& gal_eph) { - auto SISA = static_cast(gal_eph.SISA_3); + const auto SISA = static_cast(gal_eph.SISA_3); // SISA = 0; // SIS Accuracy, data content definition not given in Galileo OS SIS ICD, Issue 1.1, Sept 2010 DF291 = std::bitset<8>(SISA); return 0; @@ -4859,7 +4858,7 @@ int32_t Rtcm::set_DF291(const Galileo_Ephemeris& gal_eph) int32_t Rtcm::set_DF292(const Galileo_Ephemeris& gal_eph) { - auto idot = static_cast(std::round(gal_eph.iDot_2 / FNAV_IDOT_2_LSB)); + const auto idot = static_cast(std::round(gal_eph.iDot_2 / FNAV_IDOT_2_LSB)); DF292 = std::bitset<14>(idot); return 0; } @@ -4867,7 +4866,7 @@ int32_t Rtcm::set_DF292(const Galileo_Ephemeris& gal_eph) int32_t Rtcm::set_DF293(const Galileo_Ephemeris& gal_eph) { - auto toc = static_cast(gal_eph.t0c_4); + const auto toc = static_cast(gal_eph.t0c_4); if (toc > 604740) { LOG(WARNING) << "Error decoding Galileo ephemeris time (max of 604740, but " << toc << " was detected)"; @@ -4879,7 +4878,7 @@ int32_t Rtcm::set_DF293(const Galileo_Ephemeris& gal_eph) int32_t Rtcm::set_DF294(const Galileo_Ephemeris& gal_eph) { - auto af2 = static_cast(std::round(gal_eph.af2_4 / FNAV_AF2_1_LSB)); + const auto af2 = static_cast(std::round(gal_eph.af2_4 / FNAV_AF2_1_LSB)); DF294 = std::bitset<6>(af2); return 0; } @@ -4887,7 +4886,7 @@ int32_t Rtcm::set_DF294(const Galileo_Ephemeris& gal_eph) int32_t Rtcm::set_DF295(const Galileo_Ephemeris& gal_eph) { - auto af1 = static_cast(std::round(gal_eph.af1_4 / FNAV_AF1_1_LSB)); + const auto af1 = static_cast(std::round(gal_eph.af1_4 / FNAV_AF1_1_LSB)); DF295 = std::bitset<21>(af1); return 0; } @@ -4895,7 +4894,7 @@ int32_t Rtcm::set_DF295(const Galileo_Ephemeris& gal_eph) int32_t Rtcm::set_DF296(const Galileo_Ephemeris& gal_eph) { - int64_t af0 = static_cast(std::round(gal_eph.af0_4 / FNAV_AF0_1_LSB)); + const int64_t af0 = static_cast(std::round(gal_eph.af0_4 / FNAV_AF0_1_LSB)); DF296 = std::bitset<31>(af0); return 0; } @@ -4903,7 +4902,7 @@ int32_t Rtcm::set_DF296(const Galileo_Ephemeris& gal_eph) int32_t Rtcm::set_DF297(const Galileo_Ephemeris& gal_eph) { - auto crs = static_cast(std::round(gal_eph.C_rs_3 / FNAV_CRS_3_LSB)); + const auto crs = static_cast(std::round(gal_eph.C_rs_3 / FNAV_CRS_3_LSB)); DF297 = std::bitset<16>(crs); return 0; } @@ -4911,7 +4910,7 @@ int32_t Rtcm::set_DF297(const Galileo_Ephemeris& gal_eph) int32_t Rtcm::set_DF298(const Galileo_Ephemeris& gal_eph) { - auto delta_n = static_cast(std::round(gal_eph.delta_n_3 / FNAV_DELTAN_3_LSB)); + const auto delta_n = static_cast(std::round(gal_eph.delta_n_3 / FNAV_DELTAN_3_LSB)); DF298 = std::bitset<16>(delta_n); return 0; } @@ -4919,7 +4918,7 @@ int32_t Rtcm::set_DF298(const Galileo_Ephemeris& gal_eph) int32_t Rtcm::set_DF299(const Galileo_Ephemeris& gal_eph) { - auto m0 = static_cast(std::round(gal_eph.M0_1 / FNAV_M0_2_LSB)); + const auto m0 = static_cast(std::round(gal_eph.M0_1 / FNAV_M0_2_LSB)); DF299 = std::bitset<32>(m0); return 0; } @@ -4927,7 +4926,7 @@ int32_t Rtcm::set_DF299(const Galileo_Ephemeris& gal_eph) int32_t Rtcm::set_DF300(const Galileo_Ephemeris& gal_eph) { - int32_t cuc = static_cast(std::round(gal_eph.C_uc_3 / FNAV_CUC_3_LSB)); + const int32_t cuc = static_cast(std::round(gal_eph.C_uc_3 / FNAV_CUC_3_LSB)); DF300 = std::bitset<16>(cuc); return 0; } @@ -4935,7 +4934,7 @@ int32_t Rtcm::set_DF300(const Galileo_Ephemeris& gal_eph) int32_t Rtcm::set_DF301(const Galileo_Ephemeris& gal_eph) { - auto ecc = static_cast(std::round(gal_eph.e_1 / FNAV_E_2_LSB)); + const auto ecc = static_cast(std::round(gal_eph.e_1 / FNAV_E_2_LSB)); DF301 = std::bitset<32>(ecc); return 0; } @@ -4943,7 +4942,7 @@ int32_t Rtcm::set_DF301(const Galileo_Ephemeris& gal_eph) int32_t Rtcm::set_DF302(const Galileo_Ephemeris& gal_eph) { - auto cus = static_cast(std::round(gal_eph.C_us_3 / FNAV_CUS_3_LSB)); + const auto cus = static_cast(std::round(gal_eph.C_us_3 / FNAV_CUS_3_LSB)); DF302 = std::bitset<16>(cus); return 0; } @@ -4951,7 +4950,7 @@ int32_t Rtcm::set_DF302(const Galileo_Ephemeris& gal_eph) int32_t Rtcm::set_DF303(const Galileo_Ephemeris& gal_eph) { - auto sqr_a = static_cast(std::round(gal_eph.A_1 / FNAV_A12_2_LSB)); + const auto sqr_a = static_cast(std::round(gal_eph.A_1 / FNAV_A12_2_LSB)); DF303 = std::bitset<32>(sqr_a); return 0; } @@ -4959,7 +4958,7 @@ int32_t Rtcm::set_DF303(const Galileo_Ephemeris& gal_eph) int32_t Rtcm::set_DF304(const Galileo_Ephemeris& gal_eph) { - auto toe = static_cast(std::round(gal_eph.t0e_1 / FNAV_T0E_3_LSB)); + const auto toe = static_cast(std::round(gal_eph.t0e_1 / FNAV_T0E_3_LSB)); DF304 = std::bitset<14>(toe); return 0; } @@ -4967,7 +4966,7 @@ int32_t Rtcm::set_DF304(const Galileo_Ephemeris& gal_eph) int32_t Rtcm::set_DF305(const Galileo_Ephemeris& gal_eph) { - auto cic = static_cast(std::round(gal_eph.C_ic_4 / FNAV_CIC_4_LSB)); + const auto cic = static_cast(std::round(gal_eph.C_ic_4 / FNAV_CIC_4_LSB)); DF305 = std::bitset<16>(cic); return 0; } @@ -4975,7 +4974,7 @@ int32_t Rtcm::set_DF305(const Galileo_Ephemeris& gal_eph) int32_t Rtcm::set_DF306(const Galileo_Ephemeris& gal_eph) { - auto Omega0 = static_cast(std::round(gal_eph.OMEGA_0_2 / FNAV_OMEGA0_2_LSB)); + const auto Omega0 = static_cast(std::round(gal_eph.OMEGA_0_2 / FNAV_OMEGA0_2_LSB)); DF306 = std::bitset<32>(Omega0); return 0; } @@ -4983,7 +4982,7 @@ int32_t Rtcm::set_DF306(const Galileo_Ephemeris& gal_eph) int32_t Rtcm::set_DF307(const Galileo_Ephemeris& gal_eph) { - auto cis = static_cast(std::round(gal_eph.C_is_4 / FNAV_CIS_4_LSB)); + const auto cis = static_cast(std::round(gal_eph.C_is_4 / FNAV_CIS_4_LSB)); DF307 = std::bitset<16>(cis); return 0; } @@ -4991,7 +4990,7 @@ int32_t Rtcm::set_DF307(const Galileo_Ephemeris& gal_eph) int32_t Rtcm::set_DF308(const Galileo_Ephemeris& gal_eph) { - auto i0 = static_cast(std::round(gal_eph.i_0_2 / FNAV_I0_3_LSB)); + const auto i0 = static_cast(std::round(gal_eph.i_0_2 / FNAV_I0_3_LSB)); DF308 = std::bitset<32>(i0); return 0; } @@ -4999,7 +4998,7 @@ int32_t Rtcm::set_DF308(const Galileo_Ephemeris& gal_eph) int32_t Rtcm::set_DF309(const Galileo_Ephemeris& gal_eph) { - int32_t crc = static_cast(std::round(gal_eph.C_rc_3 / FNAV_CRC_3_LSB)); + const int32_t crc = static_cast(std::round(gal_eph.C_rc_3 / FNAV_CRC_3_LSB)); DF309 = std::bitset<16>(crc); return 0; } @@ -5007,7 +5006,7 @@ int32_t Rtcm::set_DF309(const Galileo_Ephemeris& gal_eph) int32_t Rtcm::set_DF310(const Galileo_Ephemeris& gal_eph) { - auto omega = static_cast(std::round(gal_eph.omega_2 / FNAV_OMEGA0_2_LSB)); + const auto omega = static_cast(std::round(gal_eph.omega_2 / FNAV_OMEGA0_2_LSB)); DF310 = std::bitset<32>(omega); return 0; } @@ -5015,7 +5014,7 @@ int32_t Rtcm::set_DF310(const Galileo_Ephemeris& gal_eph) int32_t Rtcm::set_DF311(const Galileo_Ephemeris& gal_eph) { - auto Omegadot = static_cast(std::round(gal_eph.OMEGA_dot_3 / FNAV_OMEGADOT_2_LSB)); + const auto Omegadot = static_cast(std::round(gal_eph.OMEGA_dot_3 / FNAV_OMEGADOT_2_LSB)); DF311 = std::bitset<24>(Omegadot); return 0; } @@ -5023,7 +5022,7 @@ int32_t Rtcm::set_DF311(const Galileo_Ephemeris& gal_eph) int32_t Rtcm::set_DF312(const Galileo_Ephemeris& gal_eph) { - auto bdg_E1_E5a = static_cast(std::round(gal_eph.BGD_E1E5a_5 / FNAV_BGD_1_LSB)); + const auto bdg_E1_E5a = static_cast(std::round(gal_eph.BGD_E1E5a_5 / FNAV_BGD_1_LSB)); DF312 = std::bitset<10>(bdg_E1_E5a); return 0; } @@ -5031,7 +5030,7 @@ int32_t Rtcm::set_DF312(const Galileo_Ephemeris& gal_eph) int32_t Rtcm::set_DF313(const Galileo_Ephemeris& gal_eph) { - auto bdg_E5b_E1 = static_cast(std::round(gal_eph.BGD_E1E5b_5)); + const auto bdg_E5b_E1 = static_cast(std::round(gal_eph.BGD_E1E5b_5)); // bdg_E5b_E1 = 0; // reserved DF313 = std::bitset<10>(bdg_E5b_E1); return 0; @@ -5282,8 +5281,8 @@ std::string Rtcm::set_DF396(const std::map& observables) int32_t Rtcm::set_DF397(const Gnss_Synchro& gnss_synchro) { - double meters_to_miliseconds = SPEED_OF_LIGHT_M_S * 0.001; - double rough_range_s = std::round(gnss_synchro.Pseudorange_m / meters_to_miliseconds / TWO_N10) * meters_to_miliseconds * TWO_N10; + const double meters_to_miliseconds = SPEED_OF_LIGHT_M_S * 0.001; + const double rough_range_s = std::round(gnss_synchro.Pseudorange_m / meters_to_miliseconds / TWO_N10) * meters_to_miliseconds * TWO_N10; uint32_t int_ms = 0; @@ -5303,8 +5302,8 @@ int32_t Rtcm::set_DF397(const Gnss_Synchro& gnss_synchro) int32_t Rtcm::set_DF398(const Gnss_Synchro& gnss_synchro) { - double meters_to_miliseconds = SPEED_OF_LIGHT_M_S * 0.001; - double rough_range_m = std::round(gnss_synchro.Pseudorange_m / meters_to_miliseconds / TWO_N10) * meters_to_miliseconds * TWO_N10; + const double meters_to_miliseconds = SPEED_OF_LIGHT_M_S * 0.001; + const double rough_range_m = std::round(gnss_synchro.Pseudorange_m / meters_to_miliseconds / TWO_N10) * meters_to_miliseconds * TWO_N10; uint32_t rr_mod_ms; if ((rough_range_m <= 0.0) || (rough_range_m > meters_to_miliseconds * 255.0)) { @@ -5322,8 +5321,8 @@ int32_t Rtcm::set_DF398(const Gnss_Synchro& gnss_synchro) int32_t Rtcm::set_DF399(const Gnss_Synchro& gnss_synchro) { double lambda = 0.0; - std::string sig_(gnss_synchro.Signal); - std::string sig = sig_.substr(0, 2); + const std::string sig_(gnss_synchro.Signal); + const std::string sig = sig_.substr(0, 2); if (sig == "1C") { @@ -5363,13 +5362,11 @@ int32_t Rtcm::set_DF399(const Gnss_Synchro& gnss_synchro) int32_t Rtcm::set_DF400(const Gnss_Synchro& gnss_synchro) { - double meters_to_miliseconds = SPEED_OF_LIGHT_M_S * 0.001; - double rough_range_m = std::round(gnss_synchro.Pseudorange_m / meters_to_miliseconds / TWO_N10) * meters_to_miliseconds * TWO_N10; - double psrng_s; + const double meters_to_miliseconds = SPEED_OF_LIGHT_M_S * 0.001; + const double rough_range_m = std::round(gnss_synchro.Pseudorange_m / meters_to_miliseconds / TWO_N10) * meters_to_miliseconds * TWO_N10; + const double psrng_s = gnss_synchro.Pseudorange_m - rough_range_m; int32_t fine_pseudorange; - psrng_s = gnss_synchro.Pseudorange_m - rough_range_m; - if (psrng_s == 0 || (std::fabs(psrng_s) > 292.7)) { fine_pseudorange = -16384; // 4000h: invalid value @@ -5386,15 +5383,14 @@ int32_t Rtcm::set_DF400(const Gnss_Synchro& gnss_synchro) int32_t Rtcm::set_DF401(const Gnss_Synchro& gnss_synchro) { - double meters_to_miliseconds = SPEED_OF_LIGHT_M_S * 0.001; - double rough_range_m = std::round(gnss_synchro.Pseudorange_m / meters_to_miliseconds / TWO_N10) * meters_to_miliseconds * TWO_N10; - double phrng_m; + const double meters_to_miliseconds = SPEED_OF_LIGHT_M_S * 0.001; + const double rough_range_m = std::round(gnss_synchro.Pseudorange_m / meters_to_miliseconds / TWO_N10) * meters_to_miliseconds * TWO_N10; int64_t fine_phaserange; double lambda = 0.0; - std::string sig_(gnss_synchro.Signal); - std::string sig = sig_.substr(0, 2); - std::string sys(&gnss_synchro.System, 1); + const std::string sig_(gnss_synchro.Signal); + const std::string sig = sig_.substr(0, 2); + const std::string sys(&gnss_synchro.System, 1); if ((sig == "1C") && (sys == "G")) { @@ -5426,7 +5422,7 @@ int32_t Rtcm::set_DF401(const Gnss_Synchro& gnss_synchro) lambda = SPEED_OF_LIGHT_M_S / (GLONASS_L2_CA_FREQ_HZ); } - phrng_m = (gnss_synchro.Carrier_phase_rads / TWO_PI) * lambda - rough_range_m; + double phrng_m = (gnss_synchro.Carrier_phase_rads / TWO_PI) * lambda - rough_range_m; /* Subtract phase - pseudorange integer cycle offset */ /* TODO: check LLI! */ @@ -5454,9 +5450,8 @@ int32_t Rtcm::set_DF401(const Gnss_Synchro& gnss_synchro) int32_t Rtcm::set_DF402(const Gps_Ephemeris& ephNAV, const Gps_CNAV_Ephemeris& ephCNAV, const Galileo_Ephemeris& ephFNAV, const Glonass_Gnav_Ephemeris& ephGNAV, double obs_time, const Gnss_Synchro& gnss_synchro) { uint32_t lock_time_period_s = 0; - uint32_t lock_time_indicator; - std::string sig_(gnss_synchro.Signal); - std::string sys(&gnss_synchro.System, 1); + const std::string sig_(gnss_synchro.Signal); + const std::string sys(&gnss_synchro.System, 1); if ((sig_ == "1C") && (sys == "G")) { lock_time_period_s = Rtcm::lock_time(ephNAV, obs_time, gnss_synchro); @@ -5474,7 +5469,7 @@ int32_t Rtcm::set_DF402(const Gps_Ephemeris& ephNAV, const Gps_CNAV_Ephemeris& e { lock_time_period_s = Rtcm::lock_time(ephGNAV, obs_time, gnss_synchro); } - lock_time_indicator = Rtcm::msm_lock_time_indicator(lock_time_period_s); + const uint32_t lock_time_indicator = Rtcm::msm_lock_time_indicator(lock_time_period_s); DF402 = std::bitset<4>(lock_time_indicator); return 0; } @@ -5482,8 +5477,7 @@ int32_t Rtcm::set_DF402(const Gps_Ephemeris& ephNAV, const Gps_CNAV_Ephemeris& e int32_t Rtcm::set_DF403(const Gnss_Synchro& gnss_synchro) { - uint32_t cnr_dB_Hz; - cnr_dB_Hz = static_cast(std::round(gnss_synchro.CN0_dB_hz)); + const auto cnr_dB_Hz = static_cast(std::round(gnss_synchro.CN0_dB_hz)); DF403 = std::bitset<6>(cnr_dB_Hz); return 0; } @@ -5492,10 +5486,10 @@ int32_t Rtcm::set_DF403(const Gnss_Synchro& gnss_synchro) int32_t Rtcm::set_DF404(const Gnss_Synchro& gnss_synchro) { double lambda = 0.0; - std::string sig_(gnss_synchro.Signal); - std::string sig = sig_.substr(0, 2); + const std::string sig_(gnss_synchro.Signal); + const std::string sig = sig_.substr(0, 2); int32_t fine_phaserange_rate; - std::string sys_(&gnss_synchro.System, 1); + const std::string sys_(&gnss_synchro.System, 1); if ((sig_ == "1C") && (sys_ == "G")) { @@ -5526,8 +5520,8 @@ int32_t Rtcm::set_DF404(const Gnss_Synchro& gnss_synchro) // TODO Need to add slot number and freq number to gnss syncro lambda = SPEED_OF_LIGHT_M_S / (GLONASS_L2_CA_FREQ_HZ); } - double rough_phase_range_rate = std::round(-gnss_synchro.Carrier_Doppler_hz * lambda); - double phrr = (-gnss_synchro.Carrier_Doppler_hz * lambda - rough_phase_range_rate); + const double rough_phase_range_rate = std::round(-gnss_synchro.Carrier_Doppler_hz * lambda); + const double phrr = (-gnss_synchro.Carrier_Doppler_hz * lambda - rough_phase_range_rate); if (phrr == 0.0 || (std::fabs(phrr) > 1.6384)) { @@ -5545,13 +5539,11 @@ int32_t Rtcm::set_DF404(const Gnss_Synchro& gnss_synchro) int32_t Rtcm::set_DF405(const Gnss_Synchro& gnss_synchro) { - double meters_to_miliseconds = SPEED_OF_LIGHT_M_S * 0.001; - double rough_range_m = std::round(gnss_synchro.Pseudorange_m / meters_to_miliseconds / TWO_N10) * meters_to_miliseconds * TWO_N10; - double psrng_s; + const double meters_to_miliseconds = SPEED_OF_LIGHT_M_S * 0.001; + const double rough_range_m = std::round(gnss_synchro.Pseudorange_m / meters_to_miliseconds / TWO_N10) * meters_to_miliseconds * TWO_N10; + const double psrng_s = gnss_synchro.Pseudorange_m - rough_range_m; int64_t fine_pseudorange; - psrng_s = gnss_synchro.Pseudorange_m - rough_range_m; - if (psrng_s == 0.0 || (std::fabs(psrng_s) > 292.7)) { fine_pseudorange = -524288; @@ -5568,13 +5560,13 @@ int32_t Rtcm::set_DF405(const Gnss_Synchro& gnss_synchro) int32_t Rtcm::set_DF406(const Gnss_Synchro& gnss_synchro) { int64_t fine_phaserange_ex; - double meters_to_miliseconds = SPEED_OF_LIGHT_M_S * 0.001; - double rough_range_m = std::round(gnss_synchro.Pseudorange_m / meters_to_miliseconds / TWO_N10) * meters_to_miliseconds * TWO_N10; + const double meters_to_miliseconds = SPEED_OF_LIGHT_M_S * 0.001; + const double rough_range_m = std::round(gnss_synchro.Pseudorange_m / meters_to_miliseconds / TWO_N10) * meters_to_miliseconds * TWO_N10; double phrng_m; double lambda = 0.0; std::string sig_(gnss_synchro.Signal); sig_ = sig_.substr(0, 2); - std::string sys_(&gnss_synchro.System, 1); + const std::string sys_(&gnss_synchro.System, 1); if ((sig_ == "1C") && (sys_ == "G")) { @@ -5632,11 +5624,10 @@ int32_t Rtcm::set_DF406(const Gnss_Synchro& gnss_synchro) int32_t Rtcm::set_DF407(const Gps_Ephemeris& ephNAV, const Gps_CNAV_Ephemeris& ephCNAV, const Galileo_Ephemeris& ephFNAV, const Glonass_Gnav_Ephemeris& ephGNAV, double obs_time, const Gnss_Synchro& gnss_synchro) { - uint32_t lock_time_indicator; uint32_t lock_time_period_s = 0; - std::string sig_(gnss_synchro.Signal); - std::string sys_(&gnss_synchro.System, 1); + const std::string sig_(gnss_synchro.Signal); + const std::string sys_(&gnss_synchro.System, 1); if ((sig_ == "1C") && (sys_ == "G")) { lock_time_period_s = Rtcm::lock_time(ephNAV, obs_time, gnss_synchro); @@ -5657,7 +5648,7 @@ int32_t Rtcm::set_DF407(const Gps_Ephemeris& ephNAV, const Gps_CNAV_Ephemeris& e { lock_time_period_s = Rtcm::lock_time(ephGNAV, obs_time, gnss_synchro); } - lock_time_indicator = Rtcm::msm_extended_lock_time_indicator(lock_time_period_s); + const uint32_t lock_time_indicator = Rtcm::msm_extended_lock_time_indicator(lock_time_period_s); DF407 = std::bitset<10>(lock_time_indicator); return 0; } @@ -5665,8 +5656,7 @@ int32_t Rtcm::set_DF407(const Gps_Ephemeris& ephNAV, const Gps_CNAV_Ephemeris& e int32_t Rtcm::set_DF408(const Gnss_Synchro& gnss_synchro) { - uint32_t cnr_dB_Hz; - cnr_dB_Hz = static_cast(std::round(gnss_synchro.CN0_dB_hz / 0.0625)); + const auto cnr_dB_Hz = static_cast(std::round(gnss_synchro.CN0_dB_hz / 0.0625)); DF408 = std::bitset<10>(cnr_dB_Hz); return 0; } diff --git a/src/algorithms/PVT/libs/rtcm_printer.cc b/src/algorithms/PVT/libs/rtcm_printer.cc index ebfc3f5f3..b5c451849 100644 --- a/src/algorithms/PVT/libs/rtcm_printer.cc +++ b/src/algorithms/PVT/libs/rtcm_printer.cc @@ -60,8 +60,8 @@ namespace errorlib = boost::system; Rtcm_Printer::Rtcm_Printer(const std::string& filename, bool flag_rtcm_file_dump, bool flag_rtcm_server, bool flag_rtcm_tty_port, uint16_t rtcm_tcp_port, uint16_t rtcm_station_id, const std::string& rtcm_dump_devname, bool time_tag_name, const std::string& base_path) { - boost::posix_time::ptime pt = boost::posix_time::second_clock::local_time(); - tm timeinfo = boost::posix_time::to_tm(pt); + const boost::posix_time::ptime pt = boost::posix_time::second_clock::local_time(); + const tm timeinfo = boost::posix_time::to_tm(pt); d_rtcm_file_dump = flag_rtcm_file_dump; rtcm_base_path = base_path; if (d_rtcm_file_dump) @@ -200,8 +200,7 @@ Rtcm_Printer::~Rtcm_Printer() } if (rtcm_file_descriptor.is_open()) { - int64_t pos; - pos = rtcm_file_descriptor.tellp(); + const auto pos = rtcm_file_descriptor.tellp(); try { rtcm_file_descriptor.close(); @@ -232,7 +231,7 @@ Rtcm_Printer::~Rtcm_Printer() bool Rtcm_Printer::Print_Rtcm_MT1001(const Gps_Ephemeris& gps_eph, double obs_time, const std::map& observables) { - std::string m1001 = rtcm->print_MT1001(gps_eph, obs_time, observables, station_id); + const std::string m1001 = rtcm->print_MT1001(gps_eph, obs_time, observables, station_id); Rtcm_Printer::Print_Message(m1001); return true; } @@ -240,7 +239,7 @@ bool Rtcm_Printer::Print_Rtcm_MT1001(const Gps_Ephemeris& gps_eph, double obs_ti bool Rtcm_Printer::Print_Rtcm_MT1002(const Gps_Ephemeris& gps_eph, double obs_time, const std::map& observables) { - std::string m1002 = rtcm->print_MT1002(gps_eph, obs_time, observables, station_id); + const std::string m1002 = rtcm->print_MT1002(gps_eph, obs_time, observables, station_id); Rtcm_Printer::Print_Message(m1002); return true; } @@ -248,7 +247,7 @@ bool Rtcm_Printer::Print_Rtcm_MT1002(const Gps_Ephemeris& gps_eph, double obs_ti bool Rtcm_Printer::Print_Rtcm_MT1003(const Gps_Ephemeris& gps_eph, const Gps_CNAV_Ephemeris& cnav_eph, double obs_time, const std::map& observables) { - std::string m1003 = rtcm->print_MT1003(gps_eph, cnav_eph, obs_time, observables, station_id); + const std::string m1003 = rtcm->print_MT1003(gps_eph, cnav_eph, obs_time, observables, station_id); Rtcm_Printer::Print_Message(m1003); return true; } @@ -256,7 +255,7 @@ bool Rtcm_Printer::Print_Rtcm_MT1003(const Gps_Ephemeris& gps_eph, const Gps_CNA bool Rtcm_Printer::Print_Rtcm_MT1004(const Gps_Ephemeris& gps_eph, const Gps_CNAV_Ephemeris& cnav_eph, double obs_time, const std::map& observables) { - std::string m1003 = rtcm->print_MT1004(gps_eph, cnav_eph, obs_time, observables, station_id); + const std::string m1003 = rtcm->print_MT1004(gps_eph, cnav_eph, obs_time, observables, station_id); Rtcm_Printer::Print_Message(m1003); return true; } @@ -264,7 +263,7 @@ bool Rtcm_Printer::Print_Rtcm_MT1004(const Gps_Ephemeris& gps_eph, const Gps_CNA bool Rtcm_Printer::Print_Rtcm_MT1009(const Glonass_Gnav_Ephemeris& glonass_gnav_eph, double obs_time, const std::map& observables) { - std::string m1009 = rtcm->print_MT1009(glonass_gnav_eph, obs_time, observables, station_id); + const std::string m1009 = rtcm->print_MT1009(glonass_gnav_eph, obs_time, observables, station_id); Rtcm_Printer::Print_Message(m1009); return true; } @@ -272,7 +271,7 @@ bool Rtcm_Printer::Print_Rtcm_MT1009(const Glonass_Gnav_Ephemeris& glonass_gnav_ bool Rtcm_Printer::Print_Rtcm_MT1010(const Glonass_Gnav_Ephemeris& glonass_gnav_eph, double obs_time, const std::map& observables) { - std::string m1010 = rtcm->print_MT1010(glonass_gnav_eph, obs_time, observables, station_id); + const std::string m1010 = rtcm->print_MT1010(glonass_gnav_eph, obs_time, observables, station_id); Rtcm_Printer::Print_Message(m1010); return true; } @@ -280,7 +279,7 @@ bool Rtcm_Printer::Print_Rtcm_MT1010(const Glonass_Gnav_Ephemeris& glonass_gnav_ bool Rtcm_Printer::Print_Rtcm_MT1011(const Glonass_Gnav_Ephemeris& glonass_gnav_ephL1, const Glonass_Gnav_Ephemeris& glonass_gnav_ephL2, double obs_time, const std::map& observables) { - std::string m1011 = rtcm->print_MT1011(glonass_gnav_ephL1, glonass_gnav_ephL2, obs_time, observables, station_id); + const std::string m1011 = rtcm->print_MT1011(glonass_gnav_ephL1, glonass_gnav_ephL2, obs_time, observables, station_id); Rtcm_Printer::Print_Message(m1011); return true; } @@ -288,7 +287,7 @@ bool Rtcm_Printer::Print_Rtcm_MT1011(const Glonass_Gnav_Ephemeris& glonass_gnav_ bool Rtcm_Printer::Print_Rtcm_MT1012(const Glonass_Gnav_Ephemeris& glonass_gnav_ephL1, const Glonass_Gnav_Ephemeris& glonass_gnav_ephL2, double obs_time, const std::map& observables) { - std::string m1012 = rtcm->print_MT1012(glonass_gnav_ephL1, glonass_gnav_ephL2, obs_time, observables, station_id); + const std::string m1012 = rtcm->print_MT1012(glonass_gnav_ephL1, glonass_gnav_ephL2, obs_time, observables, station_id); Rtcm_Printer::Print_Message(m1012); return true; } @@ -296,7 +295,7 @@ bool Rtcm_Printer::Print_Rtcm_MT1012(const Glonass_Gnav_Ephemeris& glonass_gnav_ bool Rtcm_Printer::Print_Rtcm_MT1019(const Gps_Ephemeris& gps_eph) { - std::string m1019 = rtcm->print_MT1019(gps_eph); + const std::string m1019 = rtcm->print_MT1019(gps_eph); Rtcm_Printer::Print_Message(m1019); return true; } @@ -304,7 +303,7 @@ bool Rtcm_Printer::Print_Rtcm_MT1019(const Gps_Ephemeris& gps_eph) bool Rtcm_Printer::Print_Rtcm_MT1020(const Glonass_Gnav_Ephemeris& glonass_gnav_eph, const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model) { - std::string m1020 = rtcm->print_MT1020(glonass_gnav_eph, glonass_gnav_utc_model); + const std::string m1020 = rtcm->print_MT1020(glonass_gnav_eph, glonass_gnav_utc_model); Rtcm_Printer::Print_Message(m1020); return true; } @@ -312,7 +311,7 @@ bool Rtcm_Printer::Print_Rtcm_MT1020(const Glonass_Gnav_Ephemeris& glonass_gnav_ bool Rtcm_Printer::Print_Rtcm_MT1045(const Galileo_Ephemeris& gal_eph) { - std::string m1045 = rtcm->print_MT1045(gal_eph); + const std::string m1045 = rtcm->print_MT1045(gal_eph); Rtcm_Printer::Print_Message(m1045); return true; } @@ -378,11 +377,11 @@ int Rtcm_Printer::init_serial(const std::string& serial_device) // clang-format off struct termios options{}; // clang-format on - int64_t BAUD; - int64_t DATABITS; - int64_t STOPBITS; - int64_t PARITYON; - int64_t PARITY; + const int64_t BAUD = B9600; // BAUD = B38400; + const int64_t DATABITS = CS8; + const int64_t STOPBITS = 0; + const int64_t PARITYON = 0; + const int64_t PARITY = 0; fd = open(serial_device.c_str(), O_RDWR | O_NOCTTY | O_NDELAY | O_CLOEXEC); if (fd == -1) @@ -396,13 +395,6 @@ int Rtcm_Printer::init_serial(const std::string& serial_device) } tcgetattr(fd, &options); // read serial port options - BAUD = B9600; - // BAUD = B38400; - DATABITS = CS8; - STOPBITS = 0; - PARITYON = 0; - PARITY = 0; - options.c_cflag = BAUD | DATABITS | STOPBITS | PARITYON | PARITY | CLOCAL | CREAD; // enable receiver, set 8 bit data, ignore control lines // options.c_cflag |= (CLOCAL | CREAD | CS8); diff --git a/src/algorithms/PVT/libs/rtklib_solver.cc b/src/algorithms/PVT/libs/rtklib_solver.cc index 9f49d943d..a5ebf58cf 100644 --- a/src/algorithms/PVT/libs/rtklib_solver.cc +++ b/src/algorithms/PVT/libs/rtklib_solver.cc @@ -61,15 +61,15 @@ namespace errorlib = boost::system; #endif -Rtklib_Solver::Rtklib_Solver(int nchannels, const std::string &dump_filename, bool flag_dump_to_file, bool flag_dump_to_mat, const rtk_t &rtk) +Rtklib_Solver::Rtklib_Solver(const rtk_t &rtk, int nchannels, const std::string &dump_filename, bool flag_dump_to_file, bool flag_dump_to_mat) { // init empty ephemeris for all the available GNSS channels + rtk_ = rtk; d_nchannels = nchannels; d_dump_filename = dump_filename; d_flag_dump_enabled = flag_dump_to_file; d_flag_dump_mat_enabled = flag_dump_to_mat; this->set_averaging_flag(false); - rtk_ = rtk; // ############# ENABLE DATA FILE LOG ################# if (d_flag_dump_enabled == true) @@ -96,7 +96,7 @@ Rtklib_Solver::~Rtklib_Solver() DLOG(INFO) << "Rtklib_Solver destructor called."; if (d_dump_file.is_open() == true) { - auto pos = d_dump_file.tellp(); + const auto pos = d_dump_file.tellp(); try { d_dump_file.close(); @@ -129,19 +129,18 @@ Rtklib_Solver::~Rtklib_Solver() } -bool Rtklib_Solver::save_matfile() +bool Rtklib_Solver::save_matfile() const { // READ DUMP FILE - std::string dump_filename = d_dump_filename; - std::ifstream::pos_type size; - int32_t number_of_double_vars = 21; - int32_t number_of_uint32_vars = 2; - int32_t number_of_uint8_vars = 3; - int32_t number_of_float_vars = 2; - int32_t epoch_size_bytes = sizeof(double) * number_of_double_vars + - sizeof(uint32_t) * number_of_uint32_vars + - sizeof(uint8_t) * number_of_uint8_vars + - sizeof(float) * number_of_float_vars; + const std::string dump_filename = d_dump_filename; + const int32_t number_of_double_vars = 21; + const int32_t number_of_uint32_vars = 2; + const int32_t number_of_uint8_vars = 3; + const int32_t number_of_float_vars = 2; + const int32_t epoch_size_bytes = sizeof(double) * number_of_double_vars + + sizeof(uint32_t) * number_of_uint32_vars + + sizeof(uint8_t) * number_of_uint8_vars + + sizeof(float) * number_of_float_vars; std::ifstream dump_file; dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); try @@ -158,7 +157,7 @@ bool Rtklib_Solver::save_matfile() if (dump_file.is_open()) { std::cout << "Generating .mat file for " << dump_filename << '\n'; - size = dump_file.tellg(); + const std::ifstream::pos_type size = dump_file.tellg(); num_epoch = static_cast(size) / static_cast(epoch_size_bytes); dump_file.seekg(0, std::ios::beg); } @@ -433,7 +432,7 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ { case 'G': { - std::string sig_(gnss_observables_iter->second.Signal); + const std::string sig_(gnss_observables_iter->second.Signal); if (sig_ == "1C") { band1 = true; @@ -462,7 +461,7 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ { case 'E': { - std::string sig_(gnss_observables_iter->second.Signal); + const std::string sig_(gnss_observables_iter->second.Signal); // Galileo E1 if (sig_ == "1B") { @@ -473,7 +472,7 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ // convert ephemeris from GNSS-SDR class to RTKLIB structure eph_data[valid_obs] = eph_to_rtklib(galileo_ephemeris_iter->second); // convert observation from GNSS-SDR class to RTKLIB structure - obsd_t newobs = {{0, 0}, '0', '0', {}, {}, {}, {}, {}, {}}; + obsd_t newobs{}; obs_data[valid_obs + glo_valid_obs] = insert_obs_to_rtklib(newobs, gnss_observables_iter->second, galileo_ephemeris_iter->second.WN_5, @@ -512,7 +511,7 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ // convert ephemeris from GNSS-SDR class to RTKLIB structure eph_data[valid_obs] = eph_to_rtklib(galileo_ephemeris_iter->second); // convert observation from GNSS-SDR class to RTKLIB structure - auto default_code_ = static_cast(CODE_NONE); + const auto default_code_ = static_cast(CODE_NONE); obsd_t newobs = {{0, 0}, '0', '0', {}, {}, {default_code_, default_code_, default_code_}, {}, {0.0, 0.0, 0.0}, {}}; @@ -543,7 +542,7 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ // convert ephemeris from GNSS-SDR class to RTKLIB structure eph_data[valid_obs] = eph_to_rtklib(gps_ephemeris_iter->second, this->is_pre_2009()); // convert observation from GNSS-SDR class to RTKLIB structure - obsd_t newobs = {{0, 0}, '0', '0', {}, {}, {}, {}, {}, {}}; + obsd_t newobs{}; obs_data[valid_obs + glo_valid_obs] = insert_obs_to_rtklib(newobs, gnss_observables_iter->second, gps_ephemeris_iter->second.i_GPS_week, @@ -589,7 +588,7 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ // convert ephemeris from GNSS-SDR class to RTKLIB structure eph_data[valid_obs] = eph_to_rtklib(gps_cnav_ephemeris_iter->second); // convert observation from GNSS-SDR class to RTKLIB structure - auto default_code_ = static_cast(CODE_NONE); + const auto default_code_ = static_cast(CODE_NONE); obsd_t newobs = {{0, 0}, '0', '0', {}, {}, {default_code_, default_code_, default_code_}, {}, {0.0, 0.0, 0.0}, {}}; @@ -636,7 +635,7 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ // convert ephemeris from GNSS-SDR class to RTKLIB structure eph_data[valid_obs] = eph_to_rtklib(gps_cnav_ephemeris_iter->second); // convert observation from GNSS-SDR class to RTKLIB structure - auto default_code_ = static_cast(CODE_NONE); + const auto default_code_ = static_cast(CODE_NONE); obsd_t newobs = {{0, 0}, '0', '0', {}, {}, {default_code_, default_code_, default_code_}, {}, {0.0, 0.0, 0.0}, {}}; @@ -656,7 +655,7 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ } case 'R': // TODO This should be using rtk lib nomenclature { - std::string sig_(gnss_observables_iter->second.Signal); + const std::string sig_(gnss_observables_iter->second.Signal); // GLONASS GNAV L1 if (sig_ == "1G") { @@ -667,7 +666,7 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ // convert ephemeris from GNSS-SDR class to RTKLIB structure geph_data[glo_valid_obs] = eph_to_rtklib(glonass_gnav_ephemeris_iter->second, gnav_utc); // convert observation from GNSS-SDR class to RTKLIB structure - obsd_t newobs = {{0, 0}, '0', '0', {}, {}, {}, {}, {}, {}}; + obsd_t newobs{}; obs_data[valid_obs + glo_valid_obs] = insert_obs_to_rtklib(newobs, gnss_observables_iter->second, glonass_gnav_ephemeris_iter->second.d_WN, @@ -705,7 +704,7 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ // convert ephemeris from GNSS-SDR class to RTKLIB structure geph_data[glo_valid_obs] = eph_to_rtklib(glonass_gnav_ephemeris_iter->second, gnav_utc); // convert observation from GNSS-SDR class to RTKLIB structure - obsd_t newobs = {{0, 0}, '0', '0', {}, {}, {}, {}, {}, {}}; + obsd_t newobs{}; obs_data[valid_obs + glo_valid_obs] = insert_obs_to_rtklib(newobs, gnss_observables_iter->second, glonass_gnav_ephemeris_iter->second.d_WN, @@ -724,7 +723,7 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ { // BEIDOU B1I // - find the ephemeris for the current BEIDOU SV observation. The SV PRN ID is the map key - std::string sig_(gnss_observables_iter->second.Signal); + const std::string sig_(gnss_observables_iter->second.Signal); if (sig_ == "B1") { beidou_ephemeris_iter = beidou_dnav_ephemeris_map.find(gnss_observables_iter->second.PRN); @@ -733,7 +732,7 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ // convert ephemeris from GNSS-SDR class to RTKLIB structure eph_data[valid_obs] = eph_to_rtklib(beidou_ephemeris_iter->second); // convert observation from GNSS-SDR class to RTKLIB structure - obsd_t newobs = {{0, 0}, '0', '0', {}, {}, {}, {}, {}, {}}; + obsd_t newobs{}; obs_data[valid_obs + glo_valid_obs] = insert_obs_to_rtklib(newobs, gnss_observables_iter->second, beidou_ephemeris_iter->second.i_BEIDOU_week + BEIDOU_DNAV_BDT2GPST_WEEK_NUM_OFFSET, @@ -770,7 +769,7 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ // convert ephemeris from GNSS-SDR class to RTKLIB structure eph_data[valid_obs] = eph_to_rtklib(beidou_ephemeris_iter->second); // convert observation from GNSS-SDR class to RTKLIB structure - auto default_code_ = static_cast(CODE_NONE); + const auto default_code_ = static_cast(CODE_NONE); obsd_t newobs = {{0, 0}, '0', '0', {}, {}, {default_code_, default_code_, default_code_}, {}, {0.0, 0.0, 0.0}, {}}; @@ -981,12 +980,11 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ DLOG(INFO) << "RTKLIB Position at RX TOW = " << gnss_observables_map.begin()->second.RX_time << " in ECEF (X,Y,Z,t[meters]) = " << rx_position_and_time[0] << ", " << rx_position_and_time[1] << ", " << rx_position_and_time[2] << ", " << rx_position_and_time[4]; - boost::posix_time::ptime p_time; // gtime_t rtklib_utc_time = gpst2utc(pvt_sol.time); // Corrected RX Time (Non integer multiply of 1 ms of granularity) // Uncorrected RX Time (integer multiply of 1 ms and the same observables time reported in RTCM and RINEX) - gtime_t rtklib_time = timeadd(pvt_sol.time, rx_position_and_time[3]); // uncorrected rx time - gtime_t rtklib_utc_time = gpst2utc(rtklib_time); - p_time = boost::posix_time::from_time_t(rtklib_utc_time.time); + const gtime_t rtklib_time = timeadd(pvt_sol.time, rx_position_and_time[3]); // uncorrected rx time + const gtime_t rtklib_utc_time = gpst2utc(rtklib_time); + boost::posix_time::ptime p_time = boost::posix_time::from_time_t(rtklib_utc_time.time); p_time += boost::posix_time::microseconds(static_cast(round(rtklib_utc_time.sec * 1e6))); // NOLINT(google-runtime-int) this->set_position_UTC_time(p_time); @@ -1048,7 +1046,7 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ this->set_rx_vel({enuv[0], enuv[1], enuv[2]}); - double clock_drift_ppm = pvt_sol.dtr[5] / SPEED_OF_LIGHT_M_S * 1e6; + const double clock_drift_ppm = pvt_sol.dtr[5] / SPEED_OF_LIGHT_M_S * 1e6; this->set_clock_drift_ppm(clock_drift_ppm); // User clock drift [ppm] diff --git a/src/algorithms/PVT/libs/rtklib_solver.h b/src/algorithms/PVT/libs/rtklib_solver.h index bf8fcd2aa..497fd8862 100644 --- a/src/algorithms/PVT/libs/rtklib_solver.h +++ b/src/algorithms/PVT/libs/rtklib_solver.h @@ -68,7 +68,7 @@ class Rtklib_Solver : public Pvt_Solution { public: - Rtklib_Solver(int nchannels, const std::string& dump_filename, bool flag_dump_to_file, bool flag_dump_to_mat, const rtk_t& rtk); + Rtklib_Solver(const rtk_t& rtk, int nchannels, const std::string& dump_filename, bool flag_dump_to_file, bool flag_dump_to_mat); ~Rtklib_Solver(); bool get_PVT(const std::map& gnss_observables_map, bool flag_averaging); @@ -107,7 +107,7 @@ public: std::map beidou_dnav_almanac_map; private: - bool save_matfile(); + bool save_matfile() const; std::array obs_data{}; std::array dop_{}; diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc index a8b24a8ee..8fdb35c96 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc @@ -210,7 +210,7 @@ void pcps_acquisition::set_local_code(std::complex* code) gr::thread::scoped_lock lock(d_setlock); // require mutex with work function called by the scheduler if (d_acq_parameters.bit_transition_flag) { - int32_t offset = d_fft_size / 2; + const int32_t offset = d_fft_size / 2; std::fill_n(d_fft_if->get_inbuf(), offset, gr_complex(0.0, 0.0)); memcpy(d_fft_if->get_inbuf() + offset, code, sizeof(gr_complex) * offset); } @@ -309,7 +309,7 @@ void pcps_acquisition::init() if (d_dump) { - uint32_t effective_fft_size = (d_acq_parameters.bit_transition_flag ? (d_fft_size / 2) : d_fft_size); + const uint32_t effective_fft_size = (d_acq_parameters.bit_transition_flag ? (d_fft_size / 2) : d_fft_size); d_grid = arma::fmat(effective_fft_size, d_num_doppler_bins, arma::fill::zeros); d_narrow_grid = arma::fmat(effective_fft_size, d_num_doppler_bins_step2, arma::fill::zeros); } @@ -320,7 +320,7 @@ void pcps_acquisition::update_grid_doppler_wipeoffs() { for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) { - int32_t doppler = -static_cast(d_acq_parameters.doppler_max) + d_doppler_center + d_doppler_step * doppler_index; + const int32_t doppler = -static_cast(d_acq_parameters.doppler_max) + d_doppler_center + d_doppler_step * doppler_index; update_local_carrier(d_grid_doppler_wipeoffs[doppler_index], static_cast(d_doppler_bias + doppler)); } } @@ -330,7 +330,7 @@ void pcps_acquisition::update_grid_doppler_wipeoffs_step2() { for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins_step2; doppler_index++) { - float doppler = (static_cast(doppler_index) - static_cast(floor(d_num_doppler_bins_step2 / 2.0))) * d_acq_parameters.doppler_step2; + const float doppler = (static_cast(doppler_index) - static_cast(floor(d_num_doppler_bins_step2 / 2.0))) * d_acq_parameters.doppler_step2; update_local_carrier(d_grid_doppler_wipeoffs_step_two[doppler_index], d_doppler_center_step_two + doppler); } } @@ -620,7 +620,7 @@ void pcps_acquisition::acquisition_core(uint64_t samp_count) // Initialize acquisition algorithm int32_t doppler = 0; uint32_t indext = 0U; - int32_t effective_fft_size = (d_acq_parameters.bit_transition_flag ? d_fft_size / 2 : d_fft_size); + const int32_t effective_fft_size = (d_acq_parameters.bit_transition_flag ? d_fft_size / 2 : d_fft_size); if (d_cshort) { volk_gnsssdr_16ic_convert_32fc(d_data_buffer.data(), d_data_buffer_sc.data(), d_consumed_samples); @@ -666,7 +666,7 @@ void pcps_acquisition::acquisition_core(uint64_t samp_count) d_ifft->execute(); // Compute squared magnitude (and accumulate in case of non-coherent integration) - size_t offset = (d_acq_parameters.bit_transition_flag ? effective_fft_size : 0); + const size_t offset = (d_acq_parameters.bit_transition_flag ? effective_fft_size : 0); if (d_num_noncoherent_integrations_counter == 1) { volk_32fc_magnitude_squared_32f(d_magnitude_grid[doppler_index].data(), d_ifft->get_outbuf() + offset, effective_fft_size); @@ -724,7 +724,7 @@ void pcps_acquisition::acquisition_core(uint64_t samp_count) // compute the inverse FFT d_ifft->execute(); - size_t offset = (d_acq_parameters.bit_transition_flag ? effective_fft_size : 0); + const size_t offset = (d_acq_parameters.bit_transition_flag ? effective_fft_size : 0); if (d_num_noncoherent_integrations_counter == 1) { volk_32fc_magnitude_squared_32f(d_magnitude_grid[doppler_index].data(), d_ifft->get_outbuf() + offset, effective_fft_size); @@ -811,7 +811,7 @@ void pcps_acquisition::acquisition_core(uint64_t samp_count) } d_state = 0; d_active = false; - bool was_step_two = d_step_two; + const bool was_step_two = d_step_two; d_step_two = false; if (was_step_two) { @@ -849,7 +849,7 @@ void pcps_acquisition::acquisition_core(uint64_t samp_count) else { d_state = 0; // Negative acquisition - bool was_step_two = d_step_two; + const bool was_step_two = d_step_two; d_step_two = false; if (was_step_two) { @@ -884,17 +884,17 @@ bool pcps_acquisition::start() void pcps_acquisition::calculate_threshold() { - float pfa = (d_step_two ? d_acq_parameters.pfa2 : d_acq_parameters.pfa); + const float pfa = (d_step_two ? d_acq_parameters.pfa2 : d_acq_parameters.pfa); if (pfa <= 0.0) { return; } - auto effective_fft_size = static_cast(d_acq_parameters.bit_transition_flag ? (d_fft_size / 2) : d_fft_size); - int num_doppler_bins = (d_step_two ? d_num_doppler_bins_step2 : d_num_doppler_bins); + const auto effective_fft_size = static_cast(d_acq_parameters.bit_transition_flag ? (d_fft_size / 2) : d_fft_size); + const int num_doppler_bins = (d_step_two ? d_num_doppler_bins_step2 : d_num_doppler_bins); - int num_bins = effective_fft_size * num_doppler_bins; + const int num_bins = effective_fft_size * num_doppler_bins; d_threshold = static_cast(2.0 * boost::math::gamma_p_inv(2.0 * d_acq_parameters.max_dwells, std::pow(1.0 - pfa, 1.0 / static_cast(num_bins)))); } diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc index d8245bc0d..86d0dc269 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc @@ -169,7 +169,7 @@ void pcps_acquisition_fpga::acquisition_core(uint32_t num_doppler_bins, uint32_t float secondpeak = 0.0; uint32_t total_block_exp; uint64_t initial_sample; - int32_t doppler; + d_acquisition_fpga->set_doppler_sweep(num_doppler_bins, doppler_step, doppler_min); d_acquisition_fpga->run_acquisition(); d_acquisition_fpga->read_acquisition_results(&indext, @@ -180,7 +180,7 @@ void pcps_acquisition_fpga::acquisition_core(uint32_t num_doppler_bins, uint32_t &d_doppler_index, &total_block_exp); - doppler = static_cast(doppler_min) + doppler_step * (d_doppler_index - 1); + const auto doppler = static_cast(doppler_min) + doppler_step * (d_doppler_index - 1); if (total_block_exp > d_total_block_exp) { @@ -276,7 +276,7 @@ void pcps_acquisition_fpga::set_active(bool active) d_state = 0; // Positive acquisition break; } - num_second_acq = num_second_acq + 1; + num_second_acq += 1; } d_acquisition_fpga->close_device(); if (d_test_statistics <= d_threshold) diff --git a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.cc b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.cc index c25247f39..2871aab15 100644 --- a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.cc +++ b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.cc @@ -158,7 +158,7 @@ hybrid_observables_gs::~hybrid_observables_gs() DLOG(INFO) << "Observables block destructor called."; if (d_dump_file.is_open()) { - auto pos = d_dump_file.tellp(); + const auto pos = d_dump_file.tellp(); try { d_dump_file.close(); @@ -196,10 +196,9 @@ void hybrid_observables_gs::msg_handler_pvt_to_observables(const pmt::pmt_t &msg gr::thread::scoped_lock lock(d_setlock); // require mutex with work function called by the scheduler try { - if (pmt::any_ref(msg).type() == typeid(double)) + if (pmt::any_ref(msg).type().hash_code() == d_double_type_hash_code) { - double new_rx_clock_offset_s; - new_rx_clock_offset_s = boost::any_cast(pmt::any_ref(msg)); + const auto new_rx_clock_offset_s = boost::any_cast(pmt::any_ref(msg)); d_T_rx_TOW_ms = d_T_rx_TOW_ms - static_cast(round(new_rx_clock_offset_s * 1000.0)); // align the receiver clock to integer multiple of 20 ms if (d_T_rx_TOW_ms % 20) @@ -227,8 +226,8 @@ int32_t hybrid_observables_gs::save_matfile() const // READ DUMP FILE std::string dump_filename = d_dump_filename; std::ifstream::pos_type size; - int32_t number_of_double_vars = 7; - int32_t epoch_size_bytes = sizeof(double) * number_of_double_vars * d_nchannels_out; + const int32_t number_of_double_vars = 7; + const int32_t epoch_size_bytes = sizeof(double) * number_of_double_vars * d_nchannels_out; std::ifstream dump_file; std::cout << "Generating .mat file for " << dump_filename << '\n'; dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); @@ -416,11 +415,11 @@ bool hybrid_observables_gs::interp_trk_obs(Gnss_Synchro &interpolated_obs, uint3 interpolated_obs = d_gnss_synchro_history->get(ch, nearest_element); // 2nd: Linear interpolation: y(t) = y(t1) + (y(t2) - y(t1)) * (t - t1) / (t2 - t1) - double T_rx_s = static_cast(rx_clock) / static_cast(interpolated_obs.fs); + const double T_rx_s = static_cast(rx_clock) / static_cast(interpolated_obs.fs); - double time_factor = (T_rx_s - d_gnss_synchro_history->get(ch, t1_idx).RX_time) / - (d_gnss_synchro_history->get(ch, t2_idx).RX_time - - d_gnss_synchro_history->get(ch, t1_idx).RX_time); + const double time_factor = (T_rx_s - d_gnss_synchro_history->get(ch, t1_idx).RX_time) / + (d_gnss_synchro_history->get(ch, t2_idx).RX_time - + d_gnss_synchro_history->get(ch, t1_idx).RX_time); // CARRIER PHASE INTERPOLATION interpolated_obs.Carrier_phase_rads = d_gnss_synchro_history->get(ch, t1_idx).Carrier_phase_rads + (d_gnss_synchro_history->get(ch, t2_idx).Carrier_phase_rads - d_gnss_synchro_history->get(ch, t1_idx).Carrier_phase_rads) * time_factor; @@ -517,8 +516,8 @@ void hybrid_observables_gs::compute_pranges(std::vector &data) con // std::cout.precision(17); // std::cout << " d_T_rx_TOW_ms: " << static_cast(d_T_rx_TOW_ms) << '\n'; std::vector::iterator it; - auto current_T_rx_TOW_ms = static_cast(d_T_rx_TOW_ms); - double current_T_rx_TOW_s = current_T_rx_TOW_ms / 1000.0; + const auto current_T_rx_TOW_ms = static_cast(d_T_rx_TOW_ms); + const double current_T_rx_TOW_s = current_T_rx_TOW_ms / 1000.0; for (it = data.begin(); it != data.end(); it++) { if (it->Flag_valid_word) @@ -591,8 +590,8 @@ void hybrid_observables_gs::smooth_pseudoranges(std::vector &data) { // 2. Compute the smoothed pseudorange for this channel // Hatch filter algorithm (https://insidegnss.com/can-you-list-all-the-properties-of-the-carrier-smoothing-filter/) - double r_sm = d_channel_last_pseudorange_smooth[it->Channel_ID]; - double factor = ((d_smooth_filter_M - 1.0) / d_smooth_filter_M); + const double r_sm = d_channel_last_pseudorange_smooth[it->Channel_ID]; + const double factor = ((d_smooth_filter_M - 1.0) / d_smooth_filter_M); it->Pseudorange_m = factor * r_sm + (1.0 / d_smooth_filter_M) * it->Pseudorange_m + wavelength_m * (factor / TWO_PI) * (it->Carrier_phase_rads - d_channel_last_carrier_phase_rads[it->Channel_ID]); } d_channel_last_pseudorange_smooth[it->Channel_ID] = it->Pseudorange_m; @@ -704,7 +703,7 @@ int hybrid_observables_gs::general_work(int noutput_items __attribute__((unused) { for (uint32_t n = 0; n < d_nchannels_out; n++) { - std::shared_ptr gnss_synchro_sptr = std::make_shared(epoch_data[n]); + const std::shared_ptr gnss_synchro_sptr = std::make_shared(epoch_data[n]); // publish valid gnss_synchro to the gnss_flowgraph channel status monitor this->message_port_pub(pmt::mp("status"), pmt::make_any(gnss_synchro_sptr)); } diff --git a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.h b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.h index b62f1af10..697c159be 100644 --- a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.h +++ b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.h @@ -27,11 +27,13 @@ #include // for boost::circular_buffer #include // for block #include // for gr_vector_int +#include // for size_t #include // for int32_t #include // for std::ofstream #include // for std::map #include // for std::shared, std:unique_ptr #include // for std::string +#include // for typeid #include // for std::vector #if GNURADIO_USES_STD_POINTERS #else @@ -68,6 +70,8 @@ private: explicit hybrid_observables_gs(const Obs_Conf& conf_); + const size_t d_double_type_hash_code = typeid(double).hash_code(); + void msg_handler_pvt_to_observables(const pmt::pmt_t& msg); double compute_T_rx_s(const Gnss_Synchro& a) const; bool interp_trk_obs(Gnss_Synchro& interpolated_obs, uint32_t ch, uint64_t rx_clock) const; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.cc index 3330272b7..67dc7448e 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.cc @@ -241,7 +241,7 @@ void beidou_b1i_telemetry_decoder_gs::decode_subframe(float *frame_symbols) if (d_nav.have_new_ephemeris() == true) { // get object for this SV (mandatory) - std::shared_ptr tmp_obj = std::make_shared(d_nav.get_ephemeris()); + const std::shared_ptr tmp_obj = std::make_shared(d_nav.get_ephemeris()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "BEIDOU DNAV Ephemeris have been received in channel" << d_channel << " from satellite " << d_satellite; std::cout << TEXT_YELLOW << "New BEIDOU B1I DNAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << TEXT_RESET << '\n'; @@ -249,7 +249,7 @@ void beidou_b1i_telemetry_decoder_gs::decode_subframe(float *frame_symbols) if (d_nav.have_new_utc_model() == true) { // get object for this SV (mandatory) - std::shared_ptr tmp_obj = std::make_shared(d_nav.get_utc_model()); + const std::shared_ptr tmp_obj = std::make_shared(d_nav.get_utc_model()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "BEIDOU DNAV UTC Model have been received in channel" << d_channel << " from satellite " << d_satellite; std::cout << TEXT_YELLOW << "New BEIDOU B1I DNAV utc model message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite << TEXT_RESET << '\n'; @@ -257,7 +257,7 @@ void beidou_b1i_telemetry_decoder_gs::decode_subframe(float *frame_symbols) if (d_nav.have_new_iono() == true) { // get object for this SV (mandatory) - std::shared_ptr tmp_obj = std::make_shared(d_nav.get_iono()); + const std::shared_ptr tmp_obj = std::make_shared(d_nav.get_iono()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "BEIDOU DNAV Iono have been received in channel" << d_channel << " from satellite " << d_satellite; std::cout << TEXT_YELLOW << "New BEIDOU B1I DNAV Iono message received in channel " << d_channel << ": Iono model parameters from satellite " << d_satellite << TEXT_RESET << '\n'; @@ -362,6 +362,7 @@ void beidou_b1i_telemetry_decoder_gs::set_channel(int32_t channel) } } + void beidou_b1i_telemetry_decoder_gs::reset() { d_last_valid_preamble = d_sample_counter; @@ -371,6 +372,7 @@ void beidou_b1i_telemetry_decoder_gs::reset() DLOG(INFO) << "Beidou B1I Telemetry decoder reset for satellite " << d_satellite; } + int beidou_b1i_telemetry_decoder_gs::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { @@ -427,7 +429,6 @@ int beidou_b1i_telemetry_decoder_gs::general_work(int noutput_items __attribute_ DLOG(INFO) << "Starting BeiDou DNAV frame decoding for BeiDou B1I SAT " << this->d_satellite; d_preamble_index = d_sample_counter; // record the preamble sample stamp - d_stat = 2; // ******* SAMPLES TO SYMBOLS ******* @@ -539,7 +540,7 @@ int beidou_b1i_telemetry_decoder_gs::general_work(int noutput_items __attribute_ // Reporting sow as gps time of week d_TOW_at_Preamble_ms = static_cast((d_nav.get_SOW() + BEIDOU_DNAV_BDT2GPST_LEAP_SEC_OFFSET) * 1000.0); // check TOW update consistency - uint32_t last_d_TOW_at_current_symbol_ms = d_TOW_at_current_symbol_ms; + const uint32_t last_d_TOW_at_current_symbol_ms = d_TOW_at_current_symbol_ms; // compute new TOW d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + d_required_symbols * d_symbol_duration_ms; flag_SOW_set = true; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.cc index 20f448d4a..60d492891 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.cc @@ -242,7 +242,7 @@ void beidou_b3i_telemetry_decoder_gs::decode_subframe(float *frame_symbols) if (d_nav.have_new_ephemeris() == true) { // get object for this SV (mandatory) - std::shared_ptr tmp_obj = + const std::shared_ptr tmp_obj = std::make_shared(d_nav.get_ephemeris()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "BEIDOU DNAV Ephemeris have been received in channel" @@ -253,7 +253,7 @@ void beidou_b3i_telemetry_decoder_gs::decode_subframe(float *frame_symbols) if (d_nav.have_new_utc_model() == true) { // get object for this SV (mandatory) - std::shared_ptr tmp_obj = + const std::shared_ptr tmp_obj = std::make_shared(d_nav.get_utc_model()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "BEIDOU DNAV UTC Model have been received in channel" @@ -265,7 +265,7 @@ void beidou_b3i_telemetry_decoder_gs::decode_subframe(float *frame_symbols) if (d_nav.have_new_iono() == true) { // get object for this SV (mandatory) - std::shared_ptr tmp_obj = + const std::shared_ptr tmp_obj = std::make_shared(d_nav.get_iono()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "BEIDOU DNAV Iono have been received in channel" << d_channel @@ -570,7 +570,7 @@ int beidou_b3i_telemetry_decoder_gs::general_work( // Reporting sow as gps time of week d_TOW_at_Preamble_ms = static_cast((d_nav.get_SOW() + BEIDOU_DNAV_BDT2GPST_LEAP_SEC_OFFSET) * 1000.0); // check TOW update consistency - uint32_t last_d_TOW_at_current_symbol_ms = d_TOW_at_current_symbol_ms; + const uint32_t last_d_TOW_at_current_symbol_ms = d_TOW_at_current_symbol_ms; // compute new TOW d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + d_required_symbols * d_symbol_duration_ms; flag_SOW_set = true; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_gs.cc index cac8c056f..0fd79eb54 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_gs.cc @@ -114,7 +114,7 @@ galileo_telemetry_decoder_gs::galileo_telemetry_decoder_gs( d_codelength = 0; d_datalength = 0; d_max_symbols_without_valid_frame = 0; - std::cout << "Galileo unified telemetry decoder error: Unknown frame type \n"; + std::cout << "Galileo unified telemetry decoder error: Unknown frame type\n"; } d_page_part_symbols.reserve(d_frame_length_symbols); @@ -166,8 +166,8 @@ galileo_telemetry_decoder_gs::galileo_telemetry_decoder_gs( d_symbol_history.set_capacity(d_required_symbols + 1); // vars for Viterbi decoder - int32_t max_states = 1U << static_cast(d_mm); // 2^d_mm - std::array g_encoder{{121, 91}}; // Polynomial G1 and G2 + const int32_t max_states = 1U << static_cast(d_mm); // 2^d_mm + std::array g_encoder{{121, 91}}; // Polynomial G1 and G2 d_out0.reserve(max_states); d_out1.reserve(max_states); d_state0.reserve(max_states); @@ -274,21 +274,21 @@ void galileo_telemetry_decoder_gs::decode_INAV_word(float *page_part_symbols, in if (d_inav_nav.have_new_ephemeris() == true) { // get object for this SV (mandatory) - std::shared_ptr tmp_obj = std::make_shared(d_inav_nav.get_ephemeris()); + const std::shared_ptr tmp_obj = std::make_shared(d_inav_nav.get_ephemeris()); std::cout << "New Galileo E1 I/NAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << '\n'; this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); } if (d_inav_nav.have_new_iono_and_GST() == true) { // get object for this SV (mandatory) - std::shared_ptr tmp_obj = std::make_shared(d_inav_nav.get_iono()); + const std::shared_ptr tmp_obj = std::make_shared(d_inav_nav.get_iono()); std::cout << "New Galileo E1 I/NAV message received in channel " << d_channel << ": iono/GST model parameters from satellite " << d_satellite << '\n'; this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); } if (d_inav_nav.have_new_utc_model() == true) { // get object for this SV (mandatory) - std::shared_ptr tmp_obj = std::make_shared(d_inav_nav.get_utc_model()); + const std::shared_ptr tmp_obj = std::make_shared(d_inav_nav.get_utc_model()); std::cout << "New Galileo E1 I/NAV message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite << '\n'; this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); d_delta_t = tmp_obj->A_0G_10 + tmp_obj->A_1G_10 * (static_cast(d_TOW_at_current_symbol_ms) / 1000.0 - tmp_obj->t_0G_10 + 604800 * (std::fmod(static_cast(d_inav_nav.get_Galileo_week() - tmp_obj->WN_0G_10), 64.0))); @@ -296,7 +296,7 @@ void galileo_telemetry_decoder_gs::decode_INAV_word(float *page_part_symbols, in } if (d_inav_nav.have_new_almanac() == true) { - std::shared_ptr tmp_obj = std::make_shared(d_inav_nav.get_almanac()); + const std::shared_ptr tmp_obj = std::make_shared(d_inav_nav.get_almanac()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); // debug std::cout << "Galileo E1 I/NAV almanac received in channel " << d_channel << " from satellite " << d_satellite << '\n'; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_gs.cc index ef0db7a80..75994ef82 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_gs.cc @@ -179,7 +179,7 @@ void glonass_l1_ca_telemetry_decoder_gs::decode_string(const double *frame_symbo { // get object for this SV (mandatory) d_nav.set_rf_link(d_satellite.get_rf_link()); - std::shared_ptr tmp_obj = std::make_shared(d_nav.get_ephemeris()); + const std::shared_ptr tmp_obj = std::make_shared(d_nav.get_ephemeris()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "GLONASS GNAV Ephemeris have been received in channel" << d_channel << " from satellite " << d_satellite; std::cout << "New GLONASS L1 GNAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << '\n'; @@ -187,15 +187,15 @@ void glonass_l1_ca_telemetry_decoder_gs::decode_string(const double *frame_symbo if (d_nav.have_new_utc_model() == true) { // get object for this SV (mandatory) - std::shared_ptr tmp_obj = std::make_shared(d_nav.get_utc_model()); + const std::shared_ptr tmp_obj = std::make_shared(d_nav.get_utc_model()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "GLONASS GNAV UTC Model have been received in channel" << d_channel << " from satellite " << d_satellite; std::cout << "New GLONASS L1 GNAV message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite << '\n'; } if (d_nav.have_new_almanac() == true) { - uint32_t slot_nbr = d_nav.get_alm_satellite_slot_number(); - std::shared_ptr + const uint32_t slot_nbr = d_nav.get_alm_satellite_slot_number(); + const std::shared_ptr tmp_obj = std::make_shared(d_nav.get_almanac(slot_nbr)); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "GLONASS GNAV Almanac have been received in channel" << d_channel << " in slot number " << slot_nbr; @@ -326,7 +326,7 @@ int glonass_l1_ca_telemetry_decoder_gs::general_work(int noutput_items __attribu { // NEW GLONASS string received // 0. fetch the symbols into an array - int32_t string_length = GLONASS_GNAV_STRING_SYMBOLS - d_symbols_per_preamble; + const int32_t string_length = GLONASS_GNAV_STRING_SYMBOLS - d_symbols_per_preamble; std::array string_symbols{}; // ******* SYMBOL TO BIT ******* diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_gs.cc index 7a8e25636..50de69f3c 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_gs.cc @@ -179,7 +179,7 @@ void glonass_l2_ca_telemetry_decoder_gs::decode_string(const double *frame_symbo { // get object for this SV (mandatory) d_nav.set_rf_link(d_satellite.get_rf_link()); - std::shared_ptr tmp_obj = std::make_shared(d_nav.get_ephemeris()); + const std::shared_ptr tmp_obj = std::make_shared(d_nav.get_ephemeris()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "GLONASS GNAV Ephemeris have been received in channel" << d_channel << " from satellite " << d_satellite; std::cout << TEXT_CYAN << "New GLONASS L2 GNAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << TEXT_RESET << '\n'; @@ -187,15 +187,15 @@ void glonass_l2_ca_telemetry_decoder_gs::decode_string(const double *frame_symbo if (d_nav.have_new_utc_model() == true) { // get object for this SV (mandatory) - std::shared_ptr tmp_obj = std::make_shared(d_nav.get_utc_model()); + const std::shared_ptr tmp_obj = std::make_shared(d_nav.get_utc_model()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "GLONASS GNAV UTC Model have been received in channel" << d_channel << " from satellite " << d_satellite; std::cout << TEXT_CYAN << "New GLONASS L2 GNAV message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite << TEXT_RESET << '\n'; } if (d_nav.have_new_almanac() == true) { - uint32_t slot_nbr = d_nav.get_alm_satellite_slot_number(); - std::shared_ptr tmp_obj = std::make_shared(d_nav.get_almanac(slot_nbr)); + const uint32_t slot_nbr = d_nav.get_alm_satellite_slot_number(); + const std::shared_ptr tmp_obj = std::make_shared(d_nav.get_almanac(slot_nbr)); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "GLONASS GNAV Almanac have been received in channel" << d_channel << " in slot number " << slot_nbr; std::cout << TEXT_CYAN << "New GLONASS L2 GNAV almanac received in channel " << d_channel << " from satellite " << d_satellite << TEXT_RESET << '\n'; @@ -325,7 +325,7 @@ int glonass_l2_ca_telemetry_decoder_gs::general_work(int noutput_items __attribu { // NEW GLONASS string received // 0. fetch the symbols into an array - int32_t string_length = GLONASS_GNAV_STRING_SYMBOLS - d_symbols_per_preamble; + const int32_t string_length = GLONASS_GNAV_STRING_SYMBOLS - d_symbols_per_preamble; std::array string_symbols{}; // ******* SYMBOL TO BIT ******* diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc index b38638a65..c9e726c48 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc @@ -135,29 +135,20 @@ gps_l1_ca_telemetry_decoder_gs::~gps_l1_ca_telemetry_decoder_gs() bool gps_l1_ca_telemetry_decoder_gs::gps_word_parityCheck(uint32_t gpsword) { - uint32_t d1; - uint32_t d2; - uint32_t d3; - uint32_t d4; - uint32_t d5; - uint32_t d6; - uint32_t d7; - uint32_t t; - uint32_t parity; // XOR as many bits in parallel as possible. The magic constants pick // up bits which are to be XOR'ed together to implement the GPS parity // check algorithm described in IS-GPS-200K. This avoids lengthy shift- // and-xor loops. - d1 = gpsword & 0xFBFFBF00U; - d2 = my_rotl::rotl(gpsword, 1U) & 0x07FFBF01U; - d3 = my_rotl::rotl(gpsword, 2U) & 0xFC0F8100U; - d4 = my_rotl::rotl(gpsword, 3U) & 0xF81FFE02U; - d5 = my_rotl::rotl(gpsword, 4U) & 0xFC00000EU; - d6 = my_rotl::rotl(gpsword, 5U) & 0x07F00001U; - d7 = my_rotl::rotl(gpsword, 6U) & 0x00003000U; - t = d1 ^ d2 ^ d3 ^ d4 ^ d5 ^ d6 ^ d7; + const uint32_t d1 = gpsword & 0xFBFFBF00U; + const uint32_t d2 = my_rotl::rotl(gpsword, 1U) & 0x07FFBF01U; + const uint32_t d3 = my_rotl::rotl(gpsword, 2U) & 0xFC0F8100U; + const uint32_t d4 = my_rotl::rotl(gpsword, 3U) & 0xF81FFE02U; + const uint32_t d5 = my_rotl::rotl(gpsword, 4U) & 0xFC00000EU; + const uint32_t d6 = my_rotl::rotl(gpsword, 5U) & 0x07F00001U; + const uint32_t d7 = my_rotl::rotl(gpsword, 6U) & 0x00003000U; + const uint32_t t = d1 ^ d2 ^ d3 ^ d4 ^ d5 ^ d6 ^ d7; // Now XOR the 5 6-bit fields together to produce the 6-bit final result. - parity = t ^ my_rotl::rotl(t, 6U) ^ my_rotl::rotl(t, 12U) ^ my_rotl::rotl(t, 18U) ^ my_rotl::rotl(t, 24U); + uint32_t parity = t ^ my_rotl::rotl(t, 6U) ^ my_rotl::rotl(t, 12U) ^ my_rotl::rotl(t, 18U) ^ my_rotl::rotl(t, 24U); parity = parity & 0x3FU; if (parity == (gpsword & 0x3FU)) { @@ -269,7 +260,7 @@ bool gps_l1_ca_telemetry_decoder_gs::decode_subframe() // NEW GPS SUBFRAME HAS ARRIVED! if (subframe_synchro_confirmation) { - int32_t subframe_ID = d_nav.subframe_decoder(subframe.data()); // decode the subframe + const int32_t subframe_ID = d_nav.subframe_decoder(subframe.data()); // decode the subframe if (subframe_ID > 0 and subframe_ID < 6) { std::cout << "New GPS NAV message received in channel " << this->d_channel << ": " diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_gs.cc index d8555bf01..2b58102d7 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_gs.cc @@ -150,7 +150,7 @@ int gps_l2c_telemetry_decoder_gs::general_work(int noutput_items __attribute__(( uint32_t delay = 0; // add the symbol to the decoder - uint8_t symbol_clip = static_cast(in[0].Prompt_I > 0) * 255; + const uint8_t symbol_clip = static_cast(in[0].Prompt_I > 0) * 255; flag_new_cnav_frame = cnav_msg_decoder_add_symbol(&d_cnav_decoder, symbol_clip, &msg, &delay); consume_each(1); // one by one @@ -198,20 +198,20 @@ int gps_l2c_telemetry_decoder_gs::general_work(int noutput_items __attribute__(( if (d_CNAV_Message.have_new_ephemeris() == true) { // get ephemeris object for this SV - std::shared_ptr tmp_obj = std::make_shared(d_CNAV_Message.get_ephemeris()); + const std::shared_ptr tmp_obj = std::make_shared(d_CNAV_Message.get_ephemeris()); std::cout << TEXT_BLUE << "New GPS CNAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << TEXT_RESET << '\n'; this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); } if (d_CNAV_Message.have_new_iono() == true) { - std::shared_ptr tmp_obj = std::make_shared(d_CNAV_Message.get_iono()); + const std::shared_ptr tmp_obj = std::make_shared(d_CNAV_Message.get_iono()); std::cout << TEXT_BLUE << "New GPS CNAV message received in channel " << d_channel << ": iono model parameters from satellite " << d_satellite << TEXT_RESET << '\n'; this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); } if (d_CNAV_Message.have_new_utc_model() == true) { - std::shared_ptr tmp_obj = std::make_shared(d_CNAV_Message.get_utc_model()); + const std::shared_ptr tmp_obj = std::make_shared(d_CNAV_Message.get_utc_model()); std::cout << TEXT_BLUE << "New GPS CNAV message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite << TEXT_RESET << '\n'; this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); } diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_gs.cc index 921b78606..ff3c1fc70 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_gs.cc @@ -190,20 +190,20 @@ int gps_l5_telemetry_decoder_gs::general_work(int noutput_items __attribute__((u if (d_CNAV_Message.have_new_ephemeris() == true) { // get ephemeris object for this SV - std::shared_ptr tmp_obj = std::make_shared(d_CNAV_Message.get_ephemeris()); + const std::shared_ptr tmp_obj = std::make_shared(d_CNAV_Message.get_ephemeris()); std::cout << TEXT_MAGENTA << "New GPS L5 CNAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << TEXT_RESET << '\n'; this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); } if (d_CNAV_Message.have_new_iono() == true) { - std::shared_ptr tmp_obj = std::make_shared(d_CNAV_Message.get_iono()); + const std::shared_ptr tmp_obj = std::make_shared(d_CNAV_Message.get_iono()); std::cout << TEXT_MAGENTA << "New GPS L5 CNAV message received in channel " << d_channel << ": iono model parameters from satellite " << d_satellite << TEXT_RESET << '\n'; this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); } if (d_CNAV_Message.have_new_utc_model() == true) { - std::shared_ptr tmp_obj = std::make_shared(d_CNAV_Message.get_utc_model()); + const std::shared_ptr tmp_obj = std::make_shared(d_CNAV_Message.get_utc_model()); std::cout << TEXT_MAGENTA << "New GPS L5 CNAV message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite << TEXT_RESET << '\n'; this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); } @@ -217,7 +217,7 @@ int gps_l5_telemetry_decoder_gs::general_work(int noutput_items __attribute__((u // symbolTime_ms = msg->tow * 6000 + *pdelay * 10 + (12 * 10); 12 symbols of the encoder's transitory // check TOW update consistency - uint32_t last_d_TOW_at_current_symbol_ms = d_TOW_at_current_symbol_ms; + const uint32_t last_d_TOW_at_current_symbol_ms = d_TOW_at_current_symbol_ms; d_TOW_at_current_symbol_ms = msg.tow * 6000 + (delay + 12) * GPS_L5I_SYMBOL_PERIOD_MS; if (last_d_TOW_at_current_symbol_ms != 0 and std::llabs(static_cast(d_TOW_at_current_symbol_ms) - static_cast(last_d_TOW_at_current_symbol_ms)) > static_cast(GPS_L5I_SYMBOL_PERIOD_MS)) { diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_gs.cc index f812f72d8..c9ffa163c 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_gs.cc @@ -199,7 +199,7 @@ void sbas_l1_telemetry_decoder_gs::Symbol_Aligner_And_Decoder::reset() bool sbas_l1_telemetry_decoder_gs::Symbol_Aligner_And_Decoder::get_bits(const std::vector &symbols, std::vector &bits) { const int32_t traceback_depth = 5 * d_KK; - int32_t nbits_requested = symbols.size() / D_SYMBOLS_PER_BIT; + const int32_t nbits_requested = symbols.size() / D_SYMBOLS_PER_BIT; int32_t nbits_decoded; // fill two vectors with the two possible symbol alignments std::vector symbols_vd1(symbols); // aligned symbol vector -> copy input symbol vector @@ -213,8 +213,8 @@ bool sbas_l1_telemetry_decoder_gs::Symbol_Aligner_And_Decoder::get_bits(const st std::vector bits_vd1(nbits_requested); std::vector bits_vd2(nbits_requested); // decode - float metric_vd1 = d_vd1->decode_continuous(symbols_vd1.data(), traceback_depth, bits_vd1.data(), nbits_requested, nbits_decoded); - float metric_vd2 = d_vd2->decode_continuous(symbols_vd2.data(), traceback_depth, bits_vd2.data(), nbits_requested, nbits_decoded); + const float metric_vd1 = d_vd1->decode_continuous(symbols_vd1.data(), traceback_depth, bits_vd1.data(), nbits_requested, nbits_decoded); + const float metric_vd2 = d_vd2->decode_continuous(symbols_vd2.data(), traceback_depth, bits_vd2.data(), nbits_requested, nbits_decoded); // choose the bits with the better metric for (int32_t i = 0; i < nbits_decoded; i++) { @@ -242,8 +242,8 @@ void sbas_l1_telemetry_decoder_gs::Frame_Detector::reset() void sbas_l1_telemetry_decoder_gs::Frame_Detector::get_frame_candidates(const std::vector &bits, std::vector>> &msg_candidates) { std::stringstream ss; - uint32_t sbas_msg_length = 250; - std::vector> preambles = {{0, 1, 0, 1, 0, 0, 1, 1}, + const uint32_t sbas_msg_length = 250; + const std::vector> preambles = {{0, 1, 0, 1, 0, 0, 1, 1}, {1, 0, 0, 1, 1, 0, 1, 0}, {1, 1, 0, 0, 0, 1, 1, 0}}; VLOG(FLOW) << "get_frame_candidates(): " @@ -322,7 +322,7 @@ void sbas_l1_telemetry_decoder_gs::Crc_Verifier::get_valid_frames(const std::vec // verify CRC d_checksum_agent.reset(0); d_checksum_agent.process_bytes(candidate_bytes.data(), candidate_bytes.size()); - uint32_t crc = d_checksum_agent.checksum(); + const uint32_t crc = d_checksum_agent.checksum(); VLOG(SAMP_SYNC) << "candidate " << candidate_it - msg_candidates.begin() << ": final crc remainder= " << std::hex << crc << std::setfill(' ') << std::resetiosflags(std::ios::hex); @@ -354,8 +354,8 @@ void sbas_l1_telemetry_decoder_gs::Crc_Verifier::zerropad_back_and_convert_to_by VLOG(LMORE) << "zerropad_back_and_convert_to_bytes():" << byte; for (auto candidate_bit_it = msg_candidate.cbegin(); candidate_bit_it < msg_candidate.cend(); ++candidate_bit_it) { - int32_t idx_bit = candidate_bit_it - msg_candidate.begin(); - int32_t bit_pos_in_current_byte = (bits_per_byte - 1) - (idx_bit % bits_per_byte); + const int32_t idx_bit = candidate_bit_it - msg_candidate.begin(); + const int32_t bit_pos_in_current_byte = (bits_per_byte - 1) - (idx_bit % bits_per_byte); byte |= static_cast(*candidate_bit_it) << bit_pos_in_current_byte; ss << *candidate_bit_it; if (idx_bit % bits_per_byte == bits_per_byte - 1) @@ -382,7 +382,7 @@ void sbas_l1_telemetry_decoder_gs::Crc_Verifier::zerropad_front_and_convert_to_b VLOG(LMORE) << "zerropad_front_and_convert_to_bytes():" << byte; for (auto candidate_bit_it = msg_candidate.cbegin(); candidate_bit_it < msg_candidate.cend(); ++candidate_bit_it) { - int32_t bit_pos_in_current_byte = (bits_per_byte - 1) - (idx_bit % bits_per_byte); + const int32_t bit_pos_in_current_byte = (bits_per_byte - 1) - (idx_bit % bits_per_byte); byte |= static_cast(*candidate_bit_it) << bit_pos_in_current_byte; ss << *candidate_bit_it; if (idx_bit % bits_per_byte == bits_per_byte - 1) @@ -417,7 +417,7 @@ int sbas_l1_telemetry_decoder_gs::general_work(int noutput_items __attribute__(( d_sample_buf.push_back(current_symbol.Prompt_I); // add new symbol to the symbol queue // store the time stamp of the first sample in the processed sample block - double sample_stamp = static_cast(in[0].Tracking_sample_counter) / static_cast(in[0].fs); + const double sample_stamp = static_cast(in[0].Tracking_sample_counter) / static_cast(in[0].fs); // decode only if enough samples in buffer if (d_sample_buf.size() >= d_block_size) @@ -425,12 +425,12 @@ int sbas_l1_telemetry_decoder_gs::general_work(int noutput_items __attribute__(( // align correlation samples in pairs // and obtain the symbols by summing the paired correlation samples std::vector symbols; - bool sample_alignment = d_sample_aligner.get_symbols(d_sample_buf, symbols); + const bool sample_alignment = d_sample_aligner.get_symbols(d_sample_buf, symbols); // align symbols in pairs // and obtain the bits by decoding the symbol pairs std::vector bits; - bool symbol_alignment = d_symbol_aligner_and_decoder.get_bits(symbols, bits); + const bool symbol_alignment = d_symbol_aligner_and_decoder.get_bits(symbols, bits); // search for preambles // and extract the corresponding message candidates @@ -447,9 +447,9 @@ int sbas_l1_telemetry_decoder_gs::general_work(int noutput_items __attribute__(( // std::vector sbas_raw_msgs; for (const auto &valid_msg : valid_msgs) { - int32_t message_sample_offset = + const int32_t message_sample_offset = (sample_alignment ? 0 : -1) + D_SAMPLES_PER_SYMBOL * (symbol_alignment ? -1 : 0) + D_SAMPLES_PER_SYMBOL * D_SYMBOLS_PER_BIT * valid_msg.first; - double message_sample_stamp = sample_stamp + static_cast(message_sample_offset) / 1000.0; + const double message_sample_stamp = sample_stamp + static_cast(message_sample_offset) / 1000.0; VLOG(EVENT) << "message_sample_stamp=" << message_sample_stamp << " (sample_stamp=" << sample_stamp << " sample_alignment=" << sample_alignment diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc index ae2f629a7..7a79b3746 100644 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc @@ -560,11 +560,9 @@ void dll_pll_veml_tracking::msg_handler_telemetry_to_trk(const pmt::pmt_t &msg) { try { - if (pmt::any_ref(msg).type() == typeid(int)) + if (pmt::any_ref(msg).type().hash_code() == int_type_hash_code) { - int tlm_event; - tlm_event = boost::any_cast(pmt::any_ref(msg)); - + const int tlm_event = boost::any_cast(pmt::any_ref(msg)); if (tlm_event == 1) { DLOG(INFO) << "Telemetry fault received in ch " << this->d_channel; @@ -624,7 +622,7 @@ void dll_pll_veml_tracking::start_tracking() { if (d_trk_parameters.track_pilot) { - std::array pilot_signal = {{'1', 'C', '\0'}}; + const std::array pilot_signal = {{'1', 'C', '\0'}}; galileo_e1_code_gen_sinboc11_float(d_tracking_code, pilot_signal, d_acquisition_gnss_synchro->PRN); galileo_e1_code_gen_sinboc11_float(d_data_code, Signal_, d_acquisition_gnss_synchro->PRN); d_Prompt_Data[0] = gr_complex(0.0, 0.0); @@ -638,7 +636,7 @@ void dll_pll_veml_tracking::start_tracking() else if (d_systemName == "Galileo" and d_signal_type == "5X") { volk_gnsssdr::vector aux_code(d_code_length_chips); - std::array signal_type_ = {{'5', 'X', '\0'}}; + const std::array signal_type_ = {{'5', 'X', '\0'}}; galileo_e5_a_code_gen_complex_primary(aux_code, d_acquisition_gnss_synchro->PRN, signal_type_); if (d_trk_parameters.track_pilot) { @@ -867,7 +865,7 @@ bool dll_pll_veml_tracking::cn0_and_tracking_lock_status(double coh_integration_ d_Prompt_buffer[d_cn0_estimation_counter % d_trk_parameters.cn0_samples] = d_P_accu; d_cn0_estimation_counter++; // Code lock indicator - float d_CN0_SNV_dB_Hz_raw = cn0_m2m4_estimator(d_Prompt_buffer.data(), d_trk_parameters.cn0_samples, static_cast(coh_integration_time_s)); + const float d_CN0_SNV_dB_Hz_raw = cn0_m2m4_estimator(d_Prompt_buffer.data(), d_trk_parameters.cn0_samples, static_cast(coh_integration_time_s)); d_CN0_SNV_dB_Hz = d_cn0_smoother.smooth(d_CN0_SNV_dB_Hz_raw); // Carrier lock indicator d_carrier_lock_test = d_carrier_lock_test_smoother.smooth(carrier_lock_detector(d_Prompt_buffer.data(), 1)); @@ -1360,10 +1358,10 @@ int32_t dll_pll_veml_tracking::save_matfile() const { // READ DUMP FILE std::ifstream::pos_type size; - int32_t number_of_double_vars = 1; - int32_t number_of_float_vars = 19; - int32_t epoch_size_bytes = sizeof(uint64_t) + sizeof(double) * number_of_double_vars + - sizeof(float) * number_of_float_vars + sizeof(uint32_t); + const int32_t number_of_double_vars = 1; + const int32_t number_of_float_vars = 19; + const int32_t epoch_size_bytes = sizeof(uint64_t) + sizeof(double) * number_of_double_vars + + sizeof(float) * number_of_float_vars + sizeof(uint32_t); std::ifstream dump_file; std::string dump_filename_ = d_dump_filename; // add channel number to the filename @@ -1631,21 +1629,21 @@ int dll_pll_veml_tracking::general_work(int noutput_items __attribute__((unused) case 1: // Pull-in { // Signal alignment (skip samples until the incoming signal is aligned with local replica) - int64_t acq_trk_diff_samples = static_cast(d_sample_counter) - static_cast(d_acq_sample_stamp); - double acq_trk_diff_seconds = static_cast(acq_trk_diff_samples) / d_trk_parameters.fs_in; - double delta_trk_to_acq_prn_start_samples = static_cast(acq_trk_diff_samples) - d_acq_code_phase_samples; + const int64_t acq_trk_diff_samples = static_cast(d_sample_counter) - static_cast(d_acq_sample_stamp); + const double acq_trk_diff_seconds = static_cast(acq_trk_diff_samples) / d_trk_parameters.fs_in; + const double delta_trk_to_acq_prn_start_samples = static_cast(acq_trk_diff_samples) - d_acq_code_phase_samples; d_code_freq_chips = d_code_chip_rate; d_code_phase_step_chips = d_code_freq_chips / d_trk_parameters.fs_in; d_code_phase_rate_step_chips = 0.0; - double T_chip_mod_seconds = 1.0 / d_code_freq_chips; - double T_prn_mod_seconds = T_chip_mod_seconds * static_cast(d_code_length_chips); - double T_prn_mod_samples = T_prn_mod_seconds * d_trk_parameters.fs_in; + const double T_chip_mod_seconds = 1.0 / d_code_freq_chips; + const double T_prn_mod_seconds = T_chip_mod_seconds * static_cast(d_code_length_chips); + const double T_prn_mod_samples = T_prn_mod_seconds * d_trk_parameters.fs_in; d_acq_code_phase_samples = T_prn_mod_samples - std::fmod(delta_trk_to_acq_prn_start_samples, T_prn_mod_samples); d_current_prn_length_samples = round(T_prn_mod_samples); - int32_t samples_offset = round(d_acq_code_phase_samples); + const int32_t samples_offset = round(d_acq_code_phase_samples); d_acc_carrier_phase_rad -= d_carrier_phase_step_rad * static_cast(samples_offset); d_state = 2; d_sample_counter += samples_offset; // count for the processed samples diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.h b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.h index 0d8c56185..a2f28a882 100644 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.h +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.h @@ -32,10 +32,12 @@ #include // for gr_vector_int, gr_vector... #include // for pmt_t #include // for volk_gnsssdr::vector +#include // for size_t #include // for int32_t -#include // for string, ofstream -#include -#include // for pair +#include // for ofstream +#include // for string +#include // for typeid +#include // for pair #if GNURADIO_USES_STD_POINTERS #include #else @@ -113,6 +115,8 @@ private: boost::circular_buffer> d_carr_ph_history; boost::circular_buffer d_Prompt_circular_buffer; + const size_t int_type_hash_code = typeid(int).hash_code(); + double d_signal_carrier_freq; double d_code_period; double d_code_chip_rate; diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc index 76d3c0d2b..75f1587ad 100644 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc @@ -466,9 +466,9 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & } } // create multicorrelator class - std::string device_name = d_trk_parameters.device_name; - uint32_t dev_file_num = d_trk_parameters.dev_file_num; - uint32_t num_prev_assigned_ch = d_trk_parameters.num_prev_assigned_ch; + const std::string device_name = d_trk_parameters.device_name; + const uint32_t dev_file_num = d_trk_parameters.dev_file_num; + const uint32_t num_prev_assigned_ch = d_trk_parameters.num_prev_assigned_ch; int32_t *ca_codes = d_trk_parameters.ca_codes; int32_t *data_codes = d_trk_parameters.data_codes; d_multicorrelator_fpga = std::make_shared(d_n_correlator_taps, device_name, dev_file_num, num_prev_assigned_ch, ca_codes, data_codes, d_code_length_chips, d_trk_parameters.track_pilot, d_code_samples_per_chip); @@ -489,11 +489,9 @@ void dll_pll_veml_tracking_fpga::msg_handler_telemetry_to_trk(const pmt::pmt_t & { try { - if (pmt::any_ref(msg).type() == typeid(int)) + if (pmt::any_ref(msg).type().hash_code() == int_type_hash_code) { - int tlm_event; - tlm_event = boost::any_cast(pmt::any_ref(msg)); - + const int tlm_event = boost::any_cast(pmt::any_ref(msg)); if (tlm_event == 1) { DLOG(INFO) << "Telemetry fault received in ch " << this->d_channel; @@ -623,7 +621,7 @@ bool dll_pll_veml_tracking_fpga::cn0_and_tracking_lock_status(double coh_integra d_Prompt_buffer[d_cn0_estimation_counter % d_trk_parameters.cn0_samples] = d_P_accu; d_cn0_estimation_counter++; // Code lock indicator - float d_CN0_SNV_dB_Hz_raw = cn0_m2m4_estimator(d_Prompt_buffer.data(), d_trk_parameters.cn0_samples, static_cast(coh_integration_time_s)); + const float d_CN0_SNV_dB_Hz_raw = cn0_m2m4_estimator(d_Prompt_buffer.data(), d_trk_parameters.cn0_samples, static_cast(coh_integration_time_s)); d_CN0_SNV_dB_Hz = d_cn0_smoother.smooth(d_CN0_SNV_dB_Hz_raw); // Carrier lock indicator d_carrier_lock_test = d_carrier_lock_test_smoother.smooth(carrier_lock_detector(d_Prompt_buffer.data(), 1)); @@ -765,10 +763,10 @@ void dll_pll_veml_tracking_fpga::run_dll_pll() if (d_dll_filt_history.full()) { - float avg_code_error_chips_s = static_cast(std::accumulate(d_dll_filt_history.begin(), d_dll_filt_history.end(), 0.0)) / static_cast(d_dll_filt_history.capacity()); + const float avg_code_error_chips_s = static_cast(std::accumulate(d_dll_filt_history.begin(), d_dll_filt_history.end(), 0.0)) / static_cast(d_dll_filt_history.capacity()); if (fabs(avg_code_error_chips_s) > 1.0) { - float carrier_doppler_error_hz = static_cast(d_signal_carrier_freq) * avg_code_error_chips_s / static_cast(d_code_chip_rate); + const float carrier_doppler_error_hz = static_cast(d_signal_carrier_freq) * avg_code_error_chips_s / static_cast(d_code_chip_rate); LOG(INFO) << "Detected and corrected carrier doppler error: " << carrier_doppler_error_hz << " [Hz] on sat " << Gnss_Satellite(d_systemName, d_acquisition_gnss_synchro->PRN); d_carrier_loop_filter.initialize(static_cast(d_carrier_doppler_hz) - carrier_doppler_error_hz); d_corrected_doppler = true; @@ -824,7 +822,7 @@ void dll_pll_veml_tracking_fpga::update_tracking_vars() // Compute the next buffer length based in the new period of the PRN sequence and the code phase error estimation d_T_prn_samples = d_T_prn_seconds * d_trk_parameters.fs_in; d_K_blk_samples = d_T_prn_samples * d_current_fpga_integration_period + d_rem_code_phase_samples; // initially d_rem_code_phase_samples is zero. It is updated at the end of this function - auto actual_blk_length = static_cast(std::floor(d_K_blk_samples)); + const auto actual_blk_length = static_cast(std::floor(d_K_blk_samples)); d_next_integration_length_samples = actual_blk_length; // ################## PLL COMMANDS ################################################# @@ -1119,10 +1117,10 @@ int32_t dll_pll_veml_tracking_fpga::save_matfile() const { // READ DUMP FILE std::ifstream::pos_type size; - int32_t number_of_double_vars = 1; - int32_t number_of_float_vars = 19; - int32_t epoch_size_bytes = sizeof(uint64_t) + sizeof(double) * number_of_double_vars + - sizeof(float) * number_of_float_vars + sizeof(uint32_t); + const int32_t number_of_double_vars = 1; + const int32_t number_of_float_vars = 19; + const int32_t epoch_size_bytes = sizeof(uint64_t) + sizeof(double) * number_of_double_vars + + sizeof(float) * number_of_float_vars + sizeof(uint32_t); std::ifstream dump_file; std::string dump_filename_ = d_dump_filename; // add channel number to the filename @@ -1546,7 +1544,7 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un uint64_t absolute_samples_offset; d_multicorrelator_fpga->lock_channel(); - uint64_t counter_value = d_multicorrelator_fpga->read_sample_counter(); + const uint64_t counter_value = d_multicorrelator_fpga->read_sample_counter(); if (counter_value > (d_acq_sample_stamp + d_acq_code_phase_samples)) { // Signal alignment (skip samples until the incoming signal is aligned with local replica) @@ -1554,7 +1552,7 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un acq_trk_diff_seconds = static_cast(acq_trk_diff_samples) / d_trk_parameters.fs_in; delta_trk_to_acq_prn_start_samples = static_cast(acq_trk_diff_samples) - d_acq_code_phase_samples; - uint32_t num_frames = ceil((delta_trk_to_acq_prn_start_samples) / d_current_integration_length_samples); + const uint32_t num_frames = ceil((delta_trk_to_acq_prn_start_samples) / d_current_integration_length_samples); absolute_samples_offset = static_cast(d_acq_code_phase_samples + d_acq_sample_stamp + num_frames * d_current_integration_length_samples); } else @@ -1572,14 +1570,14 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un d_sample_counter_next = d_sample_counter; // Doppler effect Fd = (C / (C + Vr)) * F - double radial_velocity = (d_signal_carrier_freq + d_acq_carrier_doppler_hz) / d_signal_carrier_freq; + const double radial_velocity = (d_signal_carrier_freq + d_acq_carrier_doppler_hz) / d_signal_carrier_freq; // new chip and PRN sequence periods based on acq Doppler d_code_freq_chips = radial_velocity * d_code_chip_rate; d_code_phase_step_chips = d_code_freq_chips / d_trk_parameters.fs_in; d_acq_code_phase_samples = absolute_samples_offset; - int32_t samples_offset = round(d_acq_code_phase_samples); + const int32_t samples_offset = round(d_acq_code_phase_samples); d_acc_carrier_phase_rad -= d_carrier_phase_step_rad * static_cast(samples_offset); d_state = 2; @@ -1893,8 +1891,8 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un // this must be computed for the secondary prn code if (d_secondary) { - uint32_t next_prn_length = d_current_integration_length_samples / d_fpga_integration_period; - uint32_t first_prn_length = d_current_integration_length_samples - next_prn_length * (d_fpga_integration_period - 1); + const uint32_t next_prn_length = d_current_integration_length_samples / d_fpga_integration_period; + const uint32_t first_prn_length = d_current_integration_length_samples - next_prn_length * (d_fpga_integration_period - 1); d_multicorrelator_fpga->update_prn_code_length(first_prn_length, next_prn_length); } @@ -1946,8 +1944,8 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un // this must be computed for the secondary prn code if (d_secondary) { - uint32_t next_prn_length = d_current_integration_length_samples / d_fpga_integration_period; - uint32_t first_prn_length = d_current_integration_length_samples - next_prn_length * (d_fpga_integration_period - 1); + const uint32_t next_prn_length = d_current_integration_length_samples / d_fpga_integration_period; + const uint32_t first_prn_length = d_current_integration_length_samples - next_prn_length * (d_fpga_integration_period - 1); d_multicorrelator_fpga->update_prn_code_length(first_prn_length, next_prn_length); } diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.h b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.h index 277d1dd5a..ca20962c8 100644 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.h +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.h @@ -31,11 +31,13 @@ #include // for gr_vector_int, gr_vector... #include // for pmt_t #include // for volk_gnsssdr::vector +#include // for size_t #include // for int32_t #include // for string, ofstream #include // for std::shared_ptr -#include -#include // for pair +#include // for string +#include // for typeid +#include // for pair #if GNURADIO_USES_STD_POINTERS #else #include @@ -153,6 +155,8 @@ private: boost::mutex d_mutex; + const size_t int_type_hash_code = typeid(int).hash_code(); + double d_signal_carrier_freq; double d_code_period; double d_code_chip_rate; diff --git a/src/core/libs/channel_status_msg_receiver.cc b/src/core/libs/channel_status_msg_receiver.cc index 339ec83b9..1b5caf44d 100644 --- a/src/core/libs/channel_status_msg_receiver.cc +++ b/src/core/libs/channel_status_msg_receiver.cc @@ -23,7 +23,9 @@ #include #include #include +#include #include +#include #include #if HAS_GENERIC_LAMBDA @@ -60,11 +62,11 @@ void channel_status_msg_receiver::msg_handler_events(const pmt::pmt_t& msg) gr::thread::scoped_lock lock(d_setlock); // require mutex with msg_handler_events function called by the scheduler try { - // ************* Gnss_Synchro received ***************** - if (pmt::any_ref(msg).type() == typeid(std::shared_ptr)) + const size_t msg_type_hash_code = pmt::any_ref(msg).type().hash_code(); + // ****************** Gnss_Synchro received ************************ + if (msg_type_hash_code == typeid(std::shared_ptr).hash_code()) { - std::shared_ptr gnss_synchro_obj; - gnss_synchro_obj = boost::any_cast>(pmt::any_ref(msg)); + const std::shared_ptr gnss_synchro_obj = boost::any_cast>(pmt::any_ref(msg)); if (gnss_synchro_obj->Flag_valid_pseudorange == true) { d_channel_status_map[gnss_synchro_obj->Channel_ID] = gnss_synchro_obj; @@ -81,11 +83,10 @@ void channel_status_msg_receiver::msg_handler_events(const pmt::pmt_t& msg) // } // std::cout << "-------- \n" << '\n'; } - else if (pmt::any_ref(msg).type() == typeid(std::shared_ptr)) + else if (msg_type_hash_code == typeid(std::shared_ptr).hash_code()) { - // ************* Monitor_Pvt received ***************** - std::shared_ptr monitor_pvt_obj; - monitor_pvt_obj = boost::any_cast>(pmt::any_ref(msg)); + // ***************** Monitor_Pvt received ****************** + const std::shared_ptr monitor_pvt_obj = boost::any_cast>(pmt::any_ref(msg)); d_pvt_status = *monitor_pvt_obj.get(); // std::cout << "-------- \n" << '\n'; diff --git a/src/core/receiver/control_thread.cc b/src/core/receiver/control_thread.cc index 8b94531e5..4d76311db 100644 --- a/src/core/receiver/control_thread.cc +++ b/src/core/receiver/control_thread.cc @@ -26,8 +26,6 @@ #endif #include "control_thread.h" -#include "channel_event.h" -#include "command_event.h" #include "concurrent_map.h" #include "configuration_interface.h" #include "file_configuration.h" @@ -128,9 +126,9 @@ void ControlThread::init() agnss_ref_location_ = Agnss_Ref_Location(); agnss_ref_time_ = Agnss_Ref_Time(); - std::string empty_string = ""; - std::string ref_location_str = configuration_->property("GNSS-SDR.AGNSS_ref_location", empty_string); - std::string ref_time_str = configuration_->property("GNSS-SDR.AGNSS_ref_utc_time", empty_string); + const std::string empty_string; + const std::string ref_location_str = configuration_->property("GNSS-SDR.AGNSS_ref_location", empty_string); + const std::string ref_time_str = configuration_->property("GNSS-SDR.AGNSS_ref_utc_time", empty_string); if (ref_location_str != empty_string) { std::vector vect; @@ -171,7 +169,9 @@ void ControlThread::init() else { // fill agnss_ref_time_ - struct tm tm = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, nullptr}; + struct tm tm + { + }; if (strptime(ref_time_str.c_str(), "%d/%m/%Y %H:%M:%S", &tm) != nullptr) { agnss_ref_time_.d_tv_sec = timegm(&tm); @@ -219,7 +219,7 @@ void ControlThread::telecommand_listener() { if (telecommand_enabled_) { - int tcp_cmd_port = configuration_->property("GNSS-SDR.telecommand_tcp_port", 3333); + const int tcp_cmd_port = configuration_->property("GNSS-SDR.telecommand_tcp_port", 3333); cmd_interface_.run_cmd_server(tcp_cmd_port); } } @@ -230,21 +230,20 @@ void ControlThread::event_dispatcher(bool &valid_event, pmt::pmt_t &msg) if (valid_event) { processed_control_messages_++; - if (pmt::any_ref(msg).type() == typeid(channel_event_sptr)) + const size_t msg_type_hash_code = pmt::any_ref(msg).type().hash_code(); + if (msg_type_hash_code == channel_event_type_hash_code_) { if (receiver_on_standby_ == false) { - channel_event_sptr new_event; - new_event = boost::any_cast(pmt::any_ref(msg)); + const channel_event_sptr new_event = boost::any_cast(pmt::any_ref(msg)); DLOG(INFO) << "New channel event rx from ch id: " << new_event->channel_id << " what: " << new_event->event_type; flowgraph_->apply_action(new_event->channel_id, new_event->event_type); } } - else if (pmt::any_ref(msg).type() == typeid(command_event_sptr)) + else if (msg_type_hash_code == command_event_type_hash_code_) { - command_event_sptr new_event; - new_event = boost::any_cast(pmt::any_ref(msg)); + const command_event_sptr new_event = boost::any_cast(pmt::any_ref(msg)); DLOG(INFO) << "New command event rx from ch id: " << new_event->command_id << " what: " << new_event->event_type; @@ -445,7 +444,7 @@ bool ControlThread::read_assistance_from_XML() gps_eph_iter++) { std::cout << "From XML file: Read NAV ephemeris for satellite " << Gnss_Satellite("GPS", gps_eph_iter->second.i_satellite_PRN) << '\n'; - std::shared_ptr tmp_obj = std::make_shared(gps_eph_iter->second); + const std::shared_ptr tmp_obj = std::make_shared(gps_eph_iter->second); flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); } ret = true; @@ -453,7 +452,7 @@ bool ControlThread::read_assistance_from_XML() if (supl_client_acquisition_.load_utc_xml(utc_xml_filename) == true) { - std::shared_ptr tmp_obj = std::make_shared(supl_client_acquisition_.gps_utc); + const std::shared_ptr tmp_obj = std::make_shared(supl_client_acquisition_.gps_utc); flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); std::cout << "From XML file: Read GPS UTC model parameters.\n"; ret = true; @@ -461,7 +460,7 @@ bool ControlThread::read_assistance_from_XML() if (supl_client_acquisition_.load_iono_xml(iono_xml_filename) == true) { - std::shared_ptr tmp_obj = std::make_shared(supl_client_acquisition_.gps_iono); + const std::shared_ptr tmp_obj = std::make_shared(supl_client_acquisition_.gps_iono); flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); std::cout << "From XML file: Read GPS ionosphere model parameters.\n"; ret = true; @@ -475,7 +474,7 @@ bool ControlThread::read_assistance_from_XML() gps_alm_iter++) { std::cout << "From XML file: Read GPS almanac for satellite " << Gnss_Satellite("GPS", gps_alm_iter->second.i_satellite_PRN) << '\n'; - std::shared_ptr tmp_obj = std::make_shared(gps_alm_iter->second); + const std::shared_ptr tmp_obj = std::make_shared(gps_alm_iter->second); flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); } ret = true; @@ -492,7 +491,7 @@ bool ControlThread::read_assistance_from_XML() gal_eph_iter++) { std::cout << "From XML file: Read ephemeris for satellite " << Gnss_Satellite("Galileo", gal_eph_iter->second.i_satellite_PRN) << '\n'; - std::shared_ptr tmp_obj = std::make_shared(gal_eph_iter->second); + const std::shared_ptr tmp_obj = std::make_shared(gal_eph_iter->second); flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); } ret = true; @@ -500,7 +499,7 @@ bool ControlThread::read_assistance_from_XML() if (supl_client_acquisition_.load_gal_iono_xml(gal_iono_xml_filename) == true) { - std::shared_ptr tmp_obj = std::make_shared(supl_client_acquisition_.gal_iono); + const std::shared_ptr tmp_obj = std::make_shared(supl_client_acquisition_.gal_iono); flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); std::cout << "From XML file: Read Galileo ionosphere model parameters.\n"; ret = true; @@ -508,7 +507,7 @@ bool ControlThread::read_assistance_from_XML() if (supl_client_acquisition_.load_gal_utc_xml(gal_utc_xml_filename) == true) { - std::shared_ptr tmp_obj = std::make_shared(supl_client_acquisition_.gal_utc); + const std::shared_ptr tmp_obj = std::make_shared(supl_client_acquisition_.gal_utc); flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); std::cout << "From XML file: Read Galileo UTC model parameters.\n"; ret = true; @@ -522,7 +521,7 @@ bool ControlThread::read_assistance_from_XML() gal_alm_iter++) { std::cout << "From XML file: Read Galileo almanac for satellite " << Gnss_Satellite("Galileo", gal_alm_iter->second.i_satellite_PRN) << '\n'; - std::shared_ptr tmp_obj = std::make_shared(gal_alm_iter->second); + const std::shared_ptr tmp_obj = std::make_shared(gal_alm_iter->second); flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); } ret = true; @@ -539,7 +538,7 @@ bool ControlThread::read_assistance_from_XML() gps_cnav_eph_iter++) { std::cout << "From XML file: Read CNAV ephemeris for satellite " << Gnss_Satellite("GPS", gps_cnav_eph_iter->second.i_satellite_PRN) << '\n'; - std::shared_ptr tmp_obj = std::make_shared(gps_cnav_eph_iter->second); + const std::shared_ptr tmp_obj = std::make_shared(gps_cnav_eph_iter->second); flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); } ret = true; @@ -547,7 +546,7 @@ bool ControlThread::read_assistance_from_XML() if (supl_client_acquisition_.load_cnav_utc_xml(cnav_utc_xml_filename) == true) { - std::shared_ptr tmp_obj = std::make_shared(supl_client_acquisition_.gps_cnav_utc); + const std::shared_ptr tmp_obj = std::make_shared(supl_client_acquisition_.gps_cnav_utc); flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); std::cout << "From XML file: Read GPS CNAV UTC model parameters.\n"; ret = true; @@ -564,7 +563,7 @@ bool ControlThread::read_assistance_from_XML() glo_gnav_eph_iter++) { std::cout << "From XML file: Read GLONASS GNAV ephemeris for satellite " << Gnss_Satellite("GLONASS", glo_gnav_eph_iter->second.i_satellite_PRN) << '\n'; - std::shared_ptr tmp_obj = std::make_shared(glo_gnav_eph_iter->second); + const std::shared_ptr tmp_obj = std::make_shared(glo_gnav_eph_iter->second); flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); } ret = true; @@ -572,7 +571,7 @@ bool ControlThread::read_assistance_from_XML() if (supl_client_acquisition_.load_glo_utc_xml(glo_utc_xml_filename) == true) { - std::shared_ptr tmp_obj = std::make_shared(supl_client_acquisition_.glo_gnav_utc); + const std::shared_ptr tmp_obj = std::make_shared(supl_client_acquisition_.glo_gnav_utc); flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); std::cout << "From XML file: Read GLONASS UTC model parameters.\n"; ret = true; @@ -586,14 +585,14 @@ bool ControlThread::read_assistance_from_XML() } // Only look for {ref time, ref location} if SUPL is enabled - bool enable_gps_supl_assistance = configuration_->property("GNSS-SDR.SUPL_gps_enabled", false); + const bool enable_gps_supl_assistance = configuration_->property("GNSS-SDR.SUPL_gps_enabled", false); if (enable_gps_supl_assistance == true) { // Try to read Ref Time from XML if (supl_client_acquisition_.load_ref_time_xml(ref_time_xml_filename) == true) { LOG(INFO) << "SUPL: Read XML Ref Time"; - std::shared_ptr tmp_obj = std::make_shared(supl_client_acquisition_.gps_time); + const std::shared_ptr tmp_obj = std::make_shared(supl_client_acquisition_.gps_time); flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); } else @@ -605,7 +604,7 @@ bool ControlThread::read_assistance_from_XML() if (supl_client_acquisition_.load_ref_location_xml(ref_location_xml_filename) == true) { LOG(INFO) << "SUPL: Read XML Ref Location"; - std::shared_ptr tmp_obj = std::make_shared(supl_client_acquisition_.gps_ref_loc); + const std::shared_ptr tmp_obj = std::make_shared(supl_client_acquisition_.gps_ref_loc); flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); } else @@ -622,13 +621,13 @@ void ControlThread::assist_GNSS() { // ######### GNSS Assistance ################################# // GNSS Assistance configuration - bool enable_gps_supl_assistance = configuration_->property("GNSS-SDR.SUPL_gps_enabled", false); - bool enable_agnss_xml = configuration_->property("GNSS-SDR.AGNSS_XML_enabled", false); + const bool enable_gps_supl_assistance = configuration_->property("GNSS-SDR.SUPL_gps_enabled", false); + const bool enable_agnss_xml = configuration_->property("GNSS-SDR.AGNSS_XML_enabled", false); if ((enable_gps_supl_assistance == true) and (enable_agnss_xml == false)) { std::cout << "SUPL RRLP GPS assistance enabled!\n"; - std::string default_acq_server = "supl.google.com"; - std::string default_eph_server = "supl.google.com"; + const std::string default_acq_server("supl.google.com"); + const std::string default_eph_server("supl.google.com"); supl_client_ephemeris_.server_name = configuration_->property("GNSS-SDR.SUPL_gps_ephemeris_server", default_acq_server); supl_client_acquisition_.server_name = configuration_->property("GNSS-SDR.SUPL_gps_acquisition_server", default_eph_server); supl_client_ephemeris_.server_port = configuration_->property("GNSS-SDR.SUPL_gps_ephemeris_port", 7275); @@ -636,10 +635,10 @@ void ControlThread::assist_GNSS() supl_mcc_ = configuration_->property("GNSS-SDR.SUPL_MCC", 244); supl_mns_ = configuration_->property("GNSS-SDR.SUPL_MNC ", 5); - std::string default_lac = "0x59e2"; - std::string default_ci = "0x31b0"; - std::string supl_lac_s = configuration_->property("GNSS-SDR.SUPL_LAC", default_lac); - std::string supl_ci_s = configuration_->property("GNSS-SDR.SUPL_CI", default_ci); + const std::string default_lac("0x59e2"); + const std::string default_ci("0x31b0"); + const std::string supl_lac_s = configuration_->property("GNSS-SDR.SUPL_LAC", default_lac); + const std::string supl_ci_s = configuration_->property("GNSS-SDR.SUPL_CI", default_ci); try { supl_lac_ = std::stoi(supl_lac_s, nullptr, 0); @@ -669,7 +668,7 @@ void ControlThread::assist_GNSS() supl_ci_ = 0x31b0; } - bool SUPL_read_gps_assistance_xml = configuration_->property("GNSS-SDR.SUPL_read_gps_assistance_xml", false); + const bool SUPL_read_gps_assistance_xml = configuration_->property("GNSS-SDR.SUPL_read_gps_assistance_xml", false); if (SUPL_read_gps_assistance_xml == true) { // Read assistance from file @@ -682,10 +681,9 @@ void ControlThread::assist_GNSS() else { // Request ephemeris from SUPL server - int error; supl_client_ephemeris_.request = 1; std::cout << "SUPL: Try to read GPS ephemeris data from SUPL server...\n"; - error = supl_client_ephemeris_.get_assistance(supl_mcc_, supl_mns_, supl_lac_, supl_ci_); + int error = supl_client_ephemeris_.get_assistance(supl_mcc_, supl_mns_, supl_lac_, supl_ci_); if (error == 0) { std::map::const_iterator gps_eph_iter; @@ -748,7 +746,7 @@ void ControlThread::assist_GNSS() flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); } // Save iono and UTC model data to xml file - std::string iono_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_iono_xml", iono_default_xml_filename_); + const std::string iono_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_iono_xml", iono_default_xml_filename_); if (supl_client_ephemeris_.save_iono_xml(iono_xml_filename, supl_client_ephemeris_.gps_iono) == true) { std::cout << "SUPL: Iono data file created\n"; @@ -757,7 +755,7 @@ void ControlThread::assist_GNSS() { std::cout << "SUPL: Failed to create Iono data file\n"; } - std::string utc_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_utc_model_xml", utc_default_xml_filename_); + const std::string utc_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_utc_model_xml", utc_default_xml_filename_); if (supl_client_ephemeris_.save_utc_xml(utc_xml_filename, supl_client_ephemeris_.gps_utc) == true) { std::cout << "SUPL: UTC model data file created\n"; @@ -909,7 +907,7 @@ void ControlThread::apply_action(unsigned int what) std::vector> ControlThread::get_visible_sats(time_t rx_utc_time, const std::array &LLH) { // 1. Compute rx ECEF position from LLH WGS84 - arma::vec LLH_rad = arma::vec{degtorad(LLH[0]), degtorad(LLH[1]), LLH[2]}; + const arma::vec LLH_rad = arma::vec{degtorad(LLH[0]), degtorad(LLH[1]), LLH[2]}; arma::mat C_tmp = arma::zeros(3, 3); arma::vec r_eb_e = arma::zeros(3, 1); arma::vec v_eb_e = arma::zeros(3, 1); @@ -927,15 +925,17 @@ std::vector> ControlThread::get_visible_sats(time std::vector visible_gps; std::vector visible_gal; std::shared_ptr pvt_ptr = flowgraph_->get_pvt(); - struct tm tstruct = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, nullptr}; + struct tm tstruct + { + }; char buf[80]; tstruct = *gmtime(&rx_utc_time); strftime(buf, sizeof(buf), "%d/%m/%Y %H:%M:%S ", &tstruct); - std::string str_time = std::string(buf); + const std::string str_time = std::string(buf); std::cout << "Get visible satellites at " << str_time << "UTC, assuming RX position " << LLH[0] << " [deg], " << LLH[1] << " [deg], " << LLH[2] << " [m]\n"; - std::map gps_eph_map = pvt_ptr->get_gps_ephemeris(); + const std::map gps_eph_map = pvt_ptr->get_gps_ephemeris(); for (auto &it : gps_eph_map) { eph_t rtklib_eph = eph_to_rtklib(it.second, pre_2009_file_); @@ -947,8 +947,8 @@ std::vector> ControlThread::get_visible_sats(time double Az; double El; double dist_m; - arma::vec r_sat_eb_e = arma::vec{r_sat[0], r_sat[1], r_sat[2]}; - arma::vec dx = r_sat_eb_e - r_eb_e; + const arma::vec r_sat_eb_e = arma::vec{r_sat[0], r_sat[1], r_sat[2]}; + const arma::vec dx = r_sat_eb_e - r_eb_e; topocent(&Az, &El, &dist_m, r_eb_e, dx); // push sat if (El > 0) @@ -960,7 +960,7 @@ std::vector> ControlThread::get_visible_sats(time } } - std::map gal_eph_map = pvt_ptr->get_galileo_ephemeris(); + const std::map gal_eph_map = pvt_ptr->get_galileo_ephemeris(); for (auto &it : gal_eph_map) { eph_t rtklib_eph = eph_to_rtklib(it.second); @@ -972,8 +972,8 @@ std::vector> ControlThread::get_visible_sats(time double Az; double El; double dist_m; - arma::vec r_sat_eb_e = arma::vec{r_sat[0], r_sat[1], r_sat[2]}; - arma::vec dx = r_sat_eb_e - r_eb_e; + const arma::vec r_sat_eb_e = arma::vec{r_sat[0], r_sat[1], r_sat[2]}; + const arma::vec dx = r_sat_eb_e - r_eb_e; topocent(&Az, &El, &dist_m, r_eb_e, dx); // push sat if (El > 0) @@ -985,7 +985,7 @@ std::vector> ControlThread::get_visible_sats(time } } - std::map gps_alm_map = pvt_ptr->get_gps_almanac(); + const std::map gps_alm_map = pvt_ptr->get_gps_almanac(); for (auto &it : gps_alm_map) { alm_t rtklib_alm = alm_to_rtklib(it.second); @@ -998,8 +998,8 @@ std::vector> ControlThread::get_visible_sats(time double Az; double El; double dist_m; - arma::vec r_sat_eb_e = arma::vec{r_sat[0], r_sat[1], r_sat[2]}; - arma::vec dx = r_sat_eb_e - r_eb_e; + const arma::vec r_sat_eb_e = arma::vec{r_sat[0], r_sat[1], r_sat[2]}; + const arma::vec dx = r_sat_eb_e - r_eb_e; topocent(&Az, &El, &dist_m, r_eb_e, dx); // push sat std::vector::iterator it2; @@ -1015,7 +1015,7 @@ std::vector> ControlThread::get_visible_sats(time } } - std::map gal_alm_map = pvt_ptr->get_galileo_almanac(); + const std::map gal_alm_map = pvt_ptr->get_galileo_almanac(); for (auto &it : gal_alm_map) { alm_t rtklib_alm = alm_to_rtklib(it.second); @@ -1028,8 +1028,8 @@ std::vector> ControlThread::get_visible_sats(time double Az; double El; double dist_m; - arma::vec r_sat_eb_e = arma::vec{r_sat[0], r_sat[1], r_sat[2]}; - arma::vec dx = r_sat_eb_e - r_eb_e; + const arma::vec r_sat_eb_e = arma::vec{r_sat[0], r_sat[1], r_sat[2]}; + const arma::vec dx = r_sat_eb_e - r_eb_e; topocent(&Az, &El, &dist_m, r_eb_e, dx); // push sat std::vector::iterator it2; diff --git a/src/core/receiver/control_thread.h b/src/core/receiver/control_thread.h index 4d87451f0..e96979f65 100644 --- a/src/core/receiver/control_thread.h +++ b/src/core/receiver/control_thread.h @@ -26,16 +26,20 @@ #include "agnss_ref_location.h" // for Agnss_Ref_Location #include "agnss_ref_time.h" // for Agnss_Ref_Time +#include "channel_event.h" // for channel_event_sptr +#include "command_event.h" // for command_event_sptr #include "concurrent_queue.h" // for Concurrent_Queue #include "gnss_sdr_supl_client.h" // for Gnss_Sdr_Supl_Client #include "tcp_cmd_interface.h" // for TcpCmdInterface #include -#include // for array -#include // for shared_ptr -#include // for string -#include // for std::thread -#include // for pair -#include // for vector +#include // for array +#include // for size_t +#include // for shared_ptr +#include // for string +#include // for std::thread +#include // for std::type_info, typeid +#include // for pair +#include // for vector #ifdef ENABLE_FPGA #include // for boost::thread @@ -162,6 +166,9 @@ private: const std::string gal_almanac_default_xml_filename_ = "./gal_almanac.xml"; const std::string gps_almanac_default_xml_filename_ = "./gps_almanac.xml"; + const size_t channel_event_type_hash_code_ = typeid(channel_event_sptr).hash_code(); + const size_t command_event_type_hash_code_ = typeid(command_event_sptr).hash_code(); + std::shared_ptr configuration_; std::shared_ptr> control_queue_; std::shared_ptr flowgraph_; diff --git a/src/tests/unit-tests/signal-processing-blocks/pvt/nmea_printer_test.cc b/src/tests/unit-tests/signal-processing-blocks/pvt/nmea_printer_test.cc index 2eefc1e2c..7748cb7e8 100644 --- a/src/tests/unit-tests/signal-processing-blocks/pvt/nmea_printer_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/pvt/nmea_printer_test.cc @@ -163,7 +163,7 @@ void NmeaPrinterTest::conf() TEST_F(NmeaPrinterTest, PrintLine) { std::string filename("nmea_test.nmea"); - std::shared_ptr pvt_solution = std::make_shared(12, "filename", false, false, rtk); + std::shared_ptr pvt_solution = std::make_shared(rtk, 12, "filename", false, false); boost::posix_time::ptime pt(boost::gregorian::date(1994, boost::date_time::Nov, 19), boost::posix_time::hours(22) + boost::posix_time::minutes(54) + boost::posix_time::seconds(46)); diff --git a/src/tests/unit-tests/signal-processing-blocks/pvt/rtklib_solver_test.cc b/src/tests/unit-tests/signal-processing-blocks/pvt/rtklib_solver_test.cc index 793b01eeb..1d686b694 100644 --- a/src/tests/unit-tests/signal-processing-blocks/pvt/rtklib_solver_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/pvt/rtklib_solver_test.cc @@ -386,7 +386,7 @@ TEST(RTKLibSolverTest, test1) bool save_to_mat = false; rtk_t rtk = configure_rtklib_options(); - auto d_ls_pvt = std::make_unique(nchannels, dump_filename, flag_dump_to_file, save_to_mat, rtk); + auto d_ls_pvt = std::make_unique(rtk, nchannels, dump_filename, flag_dump_to_file, save_to_mat); d_ls_pvt->set_averaging_depth(1); // load ephemeris