diff --git a/CMakeLists.txt b/CMakeLists.txt index b43465dcb..4beca52e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1871,19 +1871,22 @@ if(Protobuf_FOUND AND CMAKE_VERSION VERSION_LESS 3.9) endif() endif() if(Protobuf_FOUND AND CMAKE_CROSSCOMPILING) - find_program(PROTOC_EXECUTABLE protoc - HINTS - /usr/local/bin/ - /usr/bin/ - NO_SYSTEM_ENVIRONMENT_PATH - ) + find_program(PROTOC_EXECUTABLE protoc) + if(NOT PROTOC_EXECUTABLE) + find_program(PROTOC_EXECUTABLE protoc + HINTS + /usr/bin/ + /usr/local/bin/ + ) + endif() if(PROTOC_EXECUTABLE) set_target_properties(protobuf::protoc PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" IMPORTED_LOCATION ${PROTOC_EXECUTABLE} ) + set(Protobuf_PROTOC_EXECUTABLE ${PROTOC_EXECUTABLE}) else() - message(FATAL ERROR "Please install the Protocol Buffers compiter v${Protobuf_VERSION} in the host machine") + message(FATAL_ERROR "Please install the Protocol Buffers compiler v${Protobuf_VERSION} in the host machine") endif() endif() if((NOT Protobuf_FOUND) OR (NOT Protobuf_PROTOC_EXECUTABLE) OR (${Protobuf_VERSION} VERSION_LESS ${GNSSSDR_PROTOBUF_MIN_VERSION})) diff --git a/README.md b/README.md index fe1501404..54d8a3f47 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ $ sudo apt-get install build-essential cmake git libboost-dev libboost-date-time libgtest-dev libprotobuf-dev protobuf-compiler ~~~~~~ -Please note that the required files from `libgtest-dev` were moved to `googletest` in Debian 9 "stretch" and Ubuntu 18.04 "bionic", and moved back again to `libgtest-dev` in Debian 10 "buster" and Ubuntu 18.10 "cosmic". +Please note that the required files from `libgtest-dev` were moved to `googletest` in Debian 9 "stretch" and Ubuntu 18.04 "bionic", and moved back again to `libgtest-dev` in Debian 10 "buster" and Ubuntu 18.10 "cosmic" (and above). **Note for Ubuntu 14.04 LTS "trusty" users:** you will need to build from source and install GNU Radio manually, as explained below, since GNSS-SDR requires `gnuradio-dev` >= 3.7.3, and Ubuntu 14.04 came with 3.7.2. Install all the packages above BUT EXCEPT `libuhd-dev`, `gnuradio-dev` and `gr-osmosdr` (and remove them if they are already installed in your machine), and install those dependencies using PyBOMBS. The same applies to `libmatio-dev`: Ubuntu 14.04 came with 1.5.2 and the minimum required version is 1.5.3. Please do not install the `libmatio-dev` package and install `libtool`, `automake` and `libhdf5-dev` instead. A recent version of the library will be downloaded and built automatically if CMake does not find it installed. @@ -120,7 +120,7 @@ $ sudo yum install make automake gcc gcc-c++ kernel-devel cmake git boost-devel boost-serialization log4cpp-devel gnuradio-devel gr-osmosdr-devel \ blas-devel lapack-devel matio-devel armadillo-devel gflags-devel \ glog-devel openssl-devel libpcap-devel python-mako python-six \ - pugixml-devel protobuf-devel + pugixml-devel protobuf-devel protobuf-compiler ~~~~~~ Once you have installed these packages, you can jump directly to [download the source code and build GNSS-SDR](#download-and-build-linux). @@ -130,13 +130,23 @@ Once you have installed these packages, you can jump directly to [download the s If you are using openSUSE Leap: +~~~~~~ +zypper install cmake git gcc-c++ boost-devel libboost_atomic-devel \ + libboost_system-devel libboost_filesystem-devel libboost_chrono-devel \ + libboost_thread-devel libboost_serialization-devel log4cpp-devel \ + gnuradio-devel pugixml-devel libpcap-devel armadillo-devel libtool \ + automake hdf5-devel openssl-devel python-Mako python-six protobuf-devel +~~~~~~ + +If you are using openSUSE Tumbleweed: + ~~~~~~ zypper install cmake git gcc-c++ boost-devel libboost_atomic-devel \ libboost_system-devel libboost_filesystem-devel libboost_date_time-devel \ libboost_thread-devel libboost_chrono-devel libboost_serialization-devel \ log4cpp-devel gtest gnuradio-devel pugixml-devel libpcap-devel \ - armadillo-devel libtool automake hdf5-devel libopenssl-devel python-Mako \ - python-six protobuf-devel + armadillo-devel libtool automake hdf5-devel libopenssl-devel \ + python3-Mako python3-six protobuf-devel ~~~~~~ Once you have installed these packages, you can jump directly to [download the source code and build GNSS-SDR](#download-and-build-linux). diff --git a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc index e97ce2129..14951701f 100644 --- a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc +++ b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc @@ -108,6 +108,9 @@ rtklib_pvt_gs::rtklib_pvt_gs(uint32_t nchannels, gr::io_signature::make(nchannels, nchannels, sizeof(Gnss_Synchro)), gr::io_signature::make(0, 0, 0)) { + // Send feedback message to observables block with the receiver clock offset + this->message_port_register_out(pmt::mp("pvt_to_observables")); + d_output_rate_ms = conf_.output_rate_ms; d_display_rate_ms = conf_.display_rate_ms; d_dump = conf_.dump; @@ -1435,113 +1438,121 @@ int rtklib_pvt_gs::work(int noutput_items, gr_vector_const_void_star& input_item if (d_pvt_solver->get_PVT(gnss_observables_map, false)) { - //Optional debug code: export observables snapshot for rtklib unit testing - //std::cout << "step 1: save gnss_synchro map" << std::endl; - //save_gnss_synchro_map_xml("./gnss_synchro_map.xml"); - //getchar(); //stop the execution - //end debug - if (d_display_rate_ms != 0) + double Rx_clock_offset_s = d_pvt_solver->get_time_offset_s(); + if (fabs(Rx_clock_offset_s) > 0.001) { - if (current_RX_time_ms % d_display_rate_ms == 0) + this->message_port_pub(pmt::mp("pvt_to_observables"), pmt::make_any(Rx_clock_offset_s)); + LOG(INFO) << "Sent clock offset correction to observables: " << Rx_clock_offset_s << "[s]"; + } + else + { + //Optional debug code: export observables snapshot for rtklib unit testing + //std::cout << "step 1: save gnss_synchro map" << std::endl; + //save_gnss_synchro_map_xml("./gnss_synchro_map.xml"); + //getchar(); //stop the execution + //end debug + if (d_display_rate_ms != 0) { + // if (current_RX_time_ms % d_display_rate_ms == 0) + // { flag_display_pvt = true; + // } } - } - if (d_rtcm_MT1019_rate_ms != 0) // allows deactivating messages by setting rate = 0 - { - if (current_RX_time_ms % d_rtcm_MT1019_rate_ms == 0) + if (d_rtcm_MT1019_rate_ms != 0) // allows deactivating messages by setting rate = 0 { - flag_write_RTCM_1019_output = true; + if (current_RX_time_ms % d_rtcm_MT1019_rate_ms == 0) + { + flag_write_RTCM_1019_output = true; + } } - } - if (d_rtcm_MT1020_rate_ms != 0) // allows deactivating messages by setting rate = 0 - { - if (current_RX_time_ms % d_rtcm_MT1020_rate_ms == 0) + if (d_rtcm_MT1020_rate_ms != 0) // allows deactivating messages by setting rate = 0 { - flag_write_RTCM_1020_output = true; + if (current_RX_time_ms % d_rtcm_MT1020_rate_ms == 0) + { + flag_write_RTCM_1020_output = true; + } } - } - if (d_rtcm_MT1045_rate_ms != 0) - { - if (current_RX_time_ms % d_rtcm_MT1045_rate_ms == 0) + if (d_rtcm_MT1045_rate_ms != 0) { - flag_write_RTCM_1045_output = true; + if (current_RX_time_ms % d_rtcm_MT1045_rate_ms == 0) + { + flag_write_RTCM_1045_output = true; + } } - } - // TODO: RTCM 1077, 1087 and 1097 are not used, so, disable the output rates - // if (current_RX_time_ms % d_rtcm_MT1077_rate_ms==0 and d_rtcm_MT1077_rate_ms != 0) - // { - // last_RTCM_1077_output_time = current_RX_time; - // } - // if (current_RX_time_ms % d_rtcm_MT1087_rate_ms==0 and d_rtcm_MT1087_rate_ms != 0) - // { - // last_RTCM_1087_output_time = current_RX_time; - // } - // if (current_RX_time_ms % d_rtcm_MT1097_rate_ms==0 and d_rtcm_MT1097_rate_ms != 0) - // { - // last_RTCM_1097_output_time = current_RX_time; - // } - if (d_rtcm_MSM_rate_ms != 0) - { - if (current_RX_time_ms % d_rtcm_MSM_rate_ms == 0) + // TODO: RTCM 1077, 1087 and 1097 are not used, so, disable the output rates + // if (current_RX_time_ms % d_rtcm_MT1077_rate_ms==0 and d_rtcm_MT1077_rate_ms != 0) + // { + // last_RTCM_1077_output_time = current_RX_time; + // } + // if (current_RX_time_ms % d_rtcm_MT1087_rate_ms==0 and d_rtcm_MT1087_rate_ms != 0) + // { + // last_RTCM_1087_output_time = current_RX_time; + // } + // if (current_RX_time_ms % d_rtcm_MT1097_rate_ms==0 and d_rtcm_MT1097_rate_ms != 0) + // { + // last_RTCM_1097_output_time = current_RX_time; + // } + if (d_rtcm_MSM_rate_ms != 0) { - flag_write_RTCM_MSM_output = true; + if (current_RX_time_ms % d_rtcm_MSM_rate_ms == 0) + { + flag_write_RTCM_MSM_output = true; + } } - } - if (d_rinexobs_rate_ms != 0) - { - if (current_RX_time_ms % static_cast(d_rinexobs_rate_ms) == 0) + if (d_rinexobs_rate_ms != 0) { - flag_write_RINEX_obs_output = true; + if (current_RX_time_ms % static_cast(d_rinexobs_rate_ms) == 0) + { + flag_write_RINEX_obs_output = true; + } } - } - if (d_rinexnav_rate_ms != 0) - { - if (current_RX_time_ms % static_cast(d_rinexnav_rate_ms) == 0) + if (d_rinexnav_rate_ms != 0) { - flag_write_RINEX_nav_output = true; + if (current_RX_time_ms % static_cast(d_rinexnav_rate_ms) == 0) + { + flag_write_RINEX_nav_output = true; + } } - } - if (first_fix == true) - { - if (d_show_local_time_zone) + if (first_fix == true) { - boost::posix_time::ptime time_first_solution = d_pvt_solver->get_position_UTC_time() + d_utc_diff_time; - std::cout << "First position fix at " << time_first_solution << d_local_time_str; + if (d_show_local_time_zone) + { + boost::posix_time::ptime time_first_solution = d_pvt_solver->get_position_UTC_time() + d_utc_diff_time; + std::cout << "First position fix at " << time_first_solution << d_local_time_str; + } + else + { + std::cout << "First position fix at " << d_pvt_solver->get_position_UTC_time() << " UTC"; + } + std::cout << " is Lat = " << d_pvt_solver->get_latitude() << " [deg], Long = " << d_pvt_solver->get_longitude() + << " [deg], Height= " << d_pvt_solver->get_height() << " [m]" << std::endl; + ttff_msgbuf ttff; + ttff.mtype = 1; + end = std::chrono::system_clock::now(); + std::chrono::duration elapsed_seconds = end - start; + ttff.ttff = elapsed_seconds.count(); + send_sys_v_ttff_msg(ttff); + first_fix = false; } - else + if (d_kml_output_enabled) { - std::cout << "First position fix at " << d_pvt_solver->get_position_UTC_time() << " UTC"; + d_kml_dump->print_position(d_pvt_solver, false); + } + if (d_gpx_output_enabled) + { + d_gpx_dump->print_position(d_pvt_solver, false); + } + if (d_geojson_output_enabled) + { + d_geojson_printer->print_position(d_pvt_solver, false); + } + if (d_nmea_output_file_enabled) + { + d_nmea_printer->Print_Nmea_Line(d_pvt_solver, false); } - std::cout << " is Lat = " << d_pvt_solver->get_latitude() << " [deg], Long = " << d_pvt_solver->get_longitude() - << " [deg], Height= " << d_pvt_solver->get_height() << " [m]" << std::endl; - ttff_msgbuf ttff; - ttff.mtype = 1; - end = std::chrono::system_clock::now(); - std::chrono::duration elapsed_seconds = end - start; - ttff.ttff = elapsed_seconds.count(); - send_sys_v_ttff_msg(ttff); - first_fix = false; - } - if (d_kml_output_enabled) - { - d_kml_dump->print_position(d_pvt_solver, false); - } - if (d_gpx_output_enabled) - { - d_gpx_dump->print_position(d_pvt_solver, false); - } - if (d_geojson_output_enabled) - { - d_geojson_printer->print_position(d_pvt_solver, false); - } - if (d_nmea_output_file_enabled) - { - d_nmea_printer->Print_Nmea_Line(d_pvt_solver, false); - } - /* + /* * TYPE | RECEIVER * 0 | Unknown * 1 | GPS L1 C/A @@ -1578,1766 +1589,1767 @@ int rtklib_pvt_gs::work(int noutput_items, gr_vector_const_void_star& input_item * 32 | GPS L1 C/A + Galileo E1B + GPS L5 + Galileo E5a */ - // ####################### RINEX FILES ################# - if (b_rinex_output_enabled) - { - std::map::const_iterator galileo_ephemeris_iter; - std::map::const_iterator gps_ephemeris_iter; - std::map::const_iterator gps_cnav_ephemeris_iter; - std::map::const_iterator glonass_gnav_ephemeris_iter; - std::map::const_iterator beidou_dnav_ephemeris_iter; - if (!b_rinex_header_written) // & we have utc data in nav message! + // ####################### RINEX FILES ################# + if (b_rinex_output_enabled) { - galileo_ephemeris_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); - gps_ephemeris_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); - gps_cnav_ephemeris_iter = d_pvt_solver->gps_cnav_ephemeris_map.cbegin(); - glonass_gnav_ephemeris_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); - beidou_dnav_ephemeris_iter = d_pvt_solver->beidou_dnav_ephemeris_map.cbegin(); - switch (type_of_rx) - { - case 1: // GPS L1 C/A only - if (gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend()) - { - rp->rinex_obs_header(rp->obsFile, gps_ephemeris_iter->second, d_rx_time); - rp->rinex_nav_header(rp->navFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model); - b_rinex_header_written = true; // do not write header anymore - } - break; - case 2: // GPS L2C only - if (gps_cnav_ephemeris_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend()) - { - std::string signal("2S"); - rp->rinex_obs_header(rp->obsFile, gps_cnav_ephemeris_iter->second, d_rx_time, signal); - rp->rinex_nav_header(rp->navFile, d_pvt_solver->gps_cnav_iono, d_pvt_solver->gps_cnav_utc_model); - b_rinex_header_written = true; // do not write header anymore - } - break; - case 3: // GPS L5 only - if (gps_cnav_ephemeris_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend()) - { - std::string signal("L5"); - rp->rinex_obs_header(rp->obsFile, gps_cnav_ephemeris_iter->second, d_rx_time, signal); - rp->rinex_nav_header(rp->navFile, d_pvt_solver->gps_cnav_iono, d_pvt_solver->gps_cnav_utc_model); - b_rinex_header_written = true; // do not write header anymore - } - break; - case 4: // Galileo E1B only - if (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend()) - { - rp->rinex_obs_header(rp->obsFile, galileo_ephemeris_iter->second, d_rx_time); - rp->rinex_nav_header(rp->navGalFile, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); - b_rinex_header_written = true; // do not write header anymore - } - break; - case 5: // Galileo E5a only - if (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend()) - { - std::string signal("5X"); - rp->rinex_obs_header(rp->obsFile, galileo_ephemeris_iter->second, d_rx_time, signal); - rp->rinex_nav_header(rp->navGalFile, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); - b_rinex_header_written = true; // do not write header anymore - } - break; - case 6: // Galileo E5b only - if (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend()) - { - std::string signal("7X"); - rp->rinex_obs_header(rp->obsFile, galileo_ephemeris_iter->second, d_rx_time, signal); - rp->rinex_nav_header(rp->navGalFile, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); - b_rinex_header_written = true; // do not write header anymore - } - break; - case 7: // GPS L1 C/A + GPS L2C - if ((gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend()) and (gps_cnav_ephemeris_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend())) - { - std::string signal("1C 2S"); - rp->rinex_obs_header(rp->obsFile, gps_ephemeris_iter->second, gps_cnav_ephemeris_iter->second, d_rx_time, signal); - rp->rinex_nav_header(rp->navFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model); - b_rinex_header_written = true; // do not write header anymore - } - break; - case 8: // GPS L1 + GPS L5 - if ((gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend()) and (gps_cnav_ephemeris_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend())) - { - std::string signal("1C L5"); - rp->rinex_obs_header(rp->obsFile, gps_ephemeris_iter->second, gps_cnav_ephemeris_iter->second, d_rx_time, signal); - rp->rinex_nav_header(rp->navFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model); - b_rinex_header_written = true; // do not write header anymore - } - break; - case 9: // GPS L1 C/A + Galileo E1B - if ((galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend()) and (gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend())) - { - std::string gal_signal("1B"); - rp->rinex_obs_header(rp->obsFile, gps_ephemeris_iter->second, galileo_ephemeris_iter->second, d_rx_time, gal_signal); - rp->rinex_nav_header(rp->navMixFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); - b_rinex_header_written = true; // do not write header anymore - } - break; - case 10: // GPS L1 C/A + Galileo E5a - if ((galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend()) and (gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend())) - { - std::string gal_signal("5X"); - rp->rinex_obs_header(rp->obsFile, gps_ephemeris_iter->second, galileo_ephemeris_iter->second, d_rx_time, gal_signal); - rp->rinex_nav_header(rp->navMixFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); - b_rinex_header_written = true; // do not write header anymore - } - break; - case 11: // GPS L1 C/A + Galileo E5b - if ((galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend()) and (gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend())) - { - std::string gal_signal("7X"); - rp->rinex_obs_header(rp->obsFile, gps_ephemeris_iter->second, galileo_ephemeris_iter->second, d_rx_time, gal_signal); - rp->rinex_nav_header(rp->navMixFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); - b_rinex_header_written = true; // do not write header anymore - } - break; - case 13: // L5+E5a - if ((galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend()) and (gps_cnav_ephemeris_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend())) - { - std::string gal_signal("5X"); - std::string gps_signal("L5"); - rp->rinex_obs_header(rp->obsFile, gps_cnav_ephemeris_iter->second, galileo_ephemeris_iter->second, d_rx_time, gps_signal, gal_signal); - rp->rinex_nav_header(rp->navMixFile, d_pvt_solver->gps_cnav_iono, d_pvt_solver->gps_cnav_utc_model, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); - b_rinex_header_written = true; // do not write header anymore - } - break; - case 14: // Galileo E1B + Galileo E5a - if ((galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend())) - { - std::string gal_signal("1B 5X"); - rp->rinex_obs_header(rp->obsFile, galileo_ephemeris_iter->second, d_rx_time, gal_signal); - rp->rinex_nav_header(rp->navGalFile, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); - b_rinex_header_written = true; // do not write header anymore - } - break; - case 15: // Galileo E1B + Galileo E5b - if ((galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend())) - { - std::string gal_signal("1B 7X"); - rp->rinex_obs_header(rp->obsFile, galileo_ephemeris_iter->second, d_rx_time, gal_signal); - rp->rinex_nav_header(rp->navGalFile, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); - b_rinex_header_written = true; // do not write header anymore - } - break; - case 23: // GLONASS L1 C/A only - if (glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) - { - std::string signal("1G"); - rp->rinex_obs_header(rp->obsFile, glonass_gnav_ephemeris_iter->second, d_rx_time, signal); - rp->rinex_nav_header(rp->navGloFile, d_pvt_solver->glonass_gnav_utc_model, glonass_gnav_ephemeris_iter->second); - b_rinex_header_written = true; // do not write header anymore - } - break; - case 24: // GLONASS L2 C/A only - if (glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) - { - std::string signal("2G"); - rp->rinex_obs_header(rp->obsFile, glonass_gnav_ephemeris_iter->second, d_rx_time, signal); - rp->rinex_nav_header(rp->navGloFile, d_pvt_solver->glonass_gnav_utc_model, glonass_gnav_ephemeris_iter->second); - b_rinex_header_written = true; // do not write header anymore - } - break; - case 25: // GLONASS L1 C/A + GLONASS L2 C/A - if (glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) - { - std::string signal("1G 2G"); - rp->rinex_obs_header(rp->obsFile, glonass_gnav_ephemeris_iter->second, d_rx_time, signal); - rp->rinex_nav_header(rp->navGloFile, d_pvt_solver->glonass_gnav_utc_model, glonass_gnav_ephemeris_iter->second); - b_rinex_header_written = true; // do not write header anymore - } - break; - case 26: // GPS L1 C/A + GLONASS L1 C/A - if ((glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) and (gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend())) - { - std::string glo_signal("1G"); - rp->rinex_obs_header(rp->obsFile, gps_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, glo_signal); - if (d_rinex_version == 3) - { - rp->rinex_nav_header(rp->navMixFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); - } - if (d_rinex_version == 2) - { - rp->rinex_nav_header(rp->navFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model); - rp->rinex_nav_header(rp->navGloFile, d_pvt_solver->glonass_gnav_utc_model, glonass_gnav_ephemeris_iter->second); - } - b_rinex_header_written = true; // do not write header anymore - } - break; - case 27: // Galileo E1B + GLONASS L1 C/A - if ((glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) and (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend())) - { - std::string glo_signal("1G"); - std::string gal_signal("1B"); - rp->rinex_obs_header(rp->obsFile, galileo_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, glo_signal, gal_signal); - rp->rinex_nav_header(rp->navMixFile, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); - b_rinex_header_written = true; // do not write header anymore - } - break; - case 28: // GPS L2C + GLONASS L1 C/A - if ((glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) and (gps_cnav_ephemeris_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend())) - { - std::string glo_signal("1G"); - rp->rinex_obs_header(rp->obsFile, gps_cnav_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, glo_signal); - rp->rinex_nav_header(rp->navMixFile, d_pvt_solver->gps_cnav_iono, d_pvt_solver->gps_cnav_utc_model, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); - b_rinex_header_written = true; // do not write header anymore - } - break; - case 29: // GPS L1 C/A + GLONASS L2 C/A - if ((glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) and (gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend())) - { - std::string glo_signal("2G"); - rp->rinex_obs_header(rp->obsFile, gps_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, glo_signal); - if (d_rinex_version == 3) - { - rp->rinex_nav_header(rp->navMixFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); - } - if (d_rinex_version == 2) - { - rp->rinex_nav_header(rp->navFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model); - rp->rinex_nav_header(rp->navGloFile, d_pvt_solver->glonass_gnav_utc_model, glonass_gnav_ephemeris_iter->second); - } - b_rinex_header_written = true; // do not write header anymore - } - break; - case 30: // Galileo E1B + GLONASS L2 C/A - if ((glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) and (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend())) - { - std::string glo_signal("2G"); - std::string gal_signal("1B"); - rp->rinex_obs_header(rp->obsFile, galileo_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, glo_signal, gal_signal); - rp->rinex_nav_header(rp->navMixFile, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); - b_rinex_header_written = true; // do not write header anymore - } - break; - case 31: // GPS L2C + GLONASS L2 C/A - if ((glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) and (gps_cnav_ephemeris_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend())) - { - std::string glo_signal("2G"); - rp->rinex_obs_header(rp->obsFile, gps_cnav_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, glo_signal); - rp->rinex_nav_header(rp->navMixFile, d_pvt_solver->gps_cnav_iono, d_pvt_solver->gps_cnav_utc_model, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); - b_rinex_header_written = true; // do not write header anymore - } - break; - case 32: // L1+E1+L5+E5a - if ((gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend()) and - (gps_cnav_ephemeris_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend()) and - (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend())) - { - std::string gal_signal("1B 5X"); - std::string gps_signal("1C L5"); - rp->rinex_obs_header(rp->obsFile, gps_ephemeris_iter->second, gps_cnav_ephemeris_iter->second, galileo_ephemeris_iter->second, d_rx_time, gps_signal, gal_signal); - rp->rinex_nav_header(rp->navMixFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); - b_rinex_header_written = true; // do not write header anymore - } - break; - case 33: // L1+E1+E5a - if ((gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend()) and - (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend())) - { - std::string gal_signal("1B 5X"); - rp->rinex_obs_header(rp->obsFile, gps_ephemeris_iter->second, galileo_ephemeris_iter->second, d_rx_time, gal_signal); - rp->rinex_nav_header(rp->navMixFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); - b_rinex_header_written = true; // do not write header anymore - } - break; - case 50: // BDS B1I only - if (beidou_dnav_ephemeris_iter != d_pvt_solver->beidou_dnav_ephemeris_map.cend()) - { - rp->rinex_obs_header(rp->obsFile, beidou_dnav_ephemeris_iter->second, d_rx_time, "B1"); - rp->rinex_nav_header(rp->navFile, d_pvt_solver->beidou_dnav_iono, d_pvt_solver->beidou_dnav_utc_model); - b_rinex_header_written = true; // do not write header anymore - } - - break; - case 60: // BDS B1I only - if (beidou_dnav_ephemeris_iter != d_pvt_solver->beidou_dnav_ephemeris_map.cend()) - { - rp->rinex_obs_header(rp->obsFile, beidou_dnav_ephemeris_iter->second, d_rx_time, "B3"); - rp->rinex_nav_header(rp->navFile, d_pvt_solver->beidou_dnav_iono, d_pvt_solver->beidou_dnav_utc_model); - b_rinex_header_written = true; // do not write header anymore - } - - break; - default: - break; - } - } - if (b_rinex_header_written) // The header is already written, we can now log the navigation message data - { - if (flag_write_RINEX_nav_output) - { - switch (type_of_rx) - { - case 1: // GPS L1 C/A only - rp->log_rinex_nav(rp->navFile, d_pvt_solver->gps_ephemeris_map); - break; - case 2: // GPS L2C only - rp->log_rinex_nav(rp->navFile, d_pvt_solver->gps_cnav_ephemeris_map); - break; - case 3: // GPS L5 only - rp->log_rinex_nav(rp->navFile, d_pvt_solver->gps_cnav_ephemeris_map); - break; - case 4: - case 5: - case 6: - rp->log_rinex_nav(rp->navGalFile, d_pvt_solver->galileo_ephemeris_map); - break; - case 7: // GPS L1 C/A + GPS L2C - rp->log_rinex_nav(rp->navFile, d_pvt_solver->gps_cnav_ephemeris_map); - break; - case 8: // L1+L5 - rp->log_rinex_nav(rp->navFile, d_pvt_solver->gps_ephemeris_map); - break; - case 9: - case 10: - case 11: - rp->log_rinex_nav(rp->navMixFile, d_pvt_solver->gps_ephemeris_map, d_pvt_solver->galileo_ephemeris_map); - break; - case 13: // L5+E5a - rp->log_rinex_nav(rp->navFile, d_pvt_solver->gps_cnav_ephemeris_map, d_pvt_solver->galileo_ephemeris_map); - break; - case 14: - case 15: - rp->log_rinex_nav(rp->navGalFile, d_pvt_solver->galileo_ephemeris_map); - break; - case 23: - case 24: - case 25: - rp->log_rinex_nav(rp->navGloFile, d_pvt_solver->glonass_gnav_ephemeris_map); - break; - case 26: // GPS L1 C/A + GLONASS L1 C/A - if (d_rinex_version == 3) - { - rp->log_rinex_nav(rp->navMixFile, d_pvt_solver->gps_ephemeris_map, d_pvt_solver->glonass_gnav_ephemeris_map); - } - if (d_rinex_version == 2) - { - rp->log_rinex_nav(rp->navFile, d_pvt_solver->gps_ephemeris_map); - rp->log_rinex_nav(rp->navGloFile, d_pvt_solver->glonass_gnav_ephemeris_map); - } - break; - case 27: // Galileo E1B + GLONASS L1 C/A - rp->log_rinex_nav(rp->navMixFile, d_pvt_solver->galileo_ephemeris_map, d_pvt_solver->glonass_gnav_ephemeris_map); - break; - case 28: // GPS L2C + GLONASS L1 C/A - rp->log_rinex_nav(rp->navMixFile, d_pvt_solver->gps_cnav_ephemeris_map, d_pvt_solver->glonass_gnav_ephemeris_map); - break; - case 29: // GPS L1 C/A + GLONASS L2 C/A - if (d_rinex_version == 3) - { - rp->log_rinex_nav(rp->navMixFile, d_pvt_solver->gps_ephemeris_map, d_pvt_solver->glonass_gnav_ephemeris_map); - } - if (d_rinex_version == 2) - { - rp->log_rinex_nav(rp->navFile, d_pvt_solver->gps_ephemeris_map); - rp->log_rinex_nav(rp->navGloFile, d_pvt_solver->glonass_gnav_ephemeris_map); - } - break; - case 30: // Galileo E1B + GLONASS L2 C/A - rp->log_rinex_nav(rp->navMixFile, d_pvt_solver->galileo_ephemeris_map, d_pvt_solver->glonass_gnav_ephemeris_map); - break; - case 31: // GPS L2C + GLONASS L2 C/A - rp->log_rinex_nav(rp->navMixFile, d_pvt_solver->gps_cnav_ephemeris_map, d_pvt_solver->glonass_gnav_ephemeris_map); - break; - case 32: // L1+E1+L5+E5a - rp->log_rinex_nav(rp->navMixFile, d_pvt_solver->gps_ephemeris_map, d_pvt_solver->galileo_ephemeris_map); - break; - case 33: // L1+E1+E5a - rp->log_rinex_nav(rp->navMixFile, d_pvt_solver->gps_ephemeris_map, d_pvt_solver->galileo_ephemeris_map); - break; - case 50: // BDS B1I only - rp->log_rinex_nav(rp->navFile, d_pvt_solver->beidou_dnav_ephemeris_map); - break; - default: - break; - } - } - galileo_ephemeris_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); - gps_ephemeris_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); - gps_cnav_ephemeris_iter = d_pvt_solver->gps_cnav_ephemeris_map.cbegin(); - glonass_gnav_ephemeris_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); - beidou_dnav_ephemeris_iter = d_pvt_solver->beidou_dnav_ephemeris_map.cbegin(); - - // Log observables into the RINEX file - if (flag_write_RINEX_obs_output) + std::map::const_iterator galileo_ephemeris_iter; + std::map::const_iterator gps_ephemeris_iter; + std::map::const_iterator gps_cnav_ephemeris_iter; + std::map::const_iterator glonass_gnav_ephemeris_iter; + std::map::const_iterator beidou_dnav_ephemeris_iter; + if (!b_rinex_header_written) // & we have utc data in nav message! { + galileo_ephemeris_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); + gps_ephemeris_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); + gps_cnav_ephemeris_iter = d_pvt_solver->gps_cnav_ephemeris_map.cbegin(); + glonass_gnav_ephemeris_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); + beidou_dnav_ephemeris_iter = d_pvt_solver->beidou_dnav_ephemeris_map.cbegin(); switch (type_of_rx) { case 1: // GPS L1 C/A only if (gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend()) { - rp->log_rinex_obs(rp->obsFile, gps_ephemeris_iter->second, d_rx_time, gnss_observables_map); - } - if (!b_rinex_header_updated and (d_pvt_solver->gps_utc_model.d_A0 != 0)) - { - rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_utc_model); - rp->update_nav_header(rp->navFile, d_pvt_solver->gps_utc_model, d_pvt_solver->gps_iono); - b_rinex_header_updated = true; + rp->rinex_obs_header(rp->obsFile, gps_ephemeris_iter->second, d_rx_time); + rp->rinex_nav_header(rp->navFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model); + b_rinex_header_written = true; // do not write header anymore } break; case 2: // GPS L2C only if (gps_cnav_ephemeris_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend()) { - rp->log_rinex_obs(rp->obsFile, gps_cnav_ephemeris_iter->second, d_rx_time, gnss_observables_map); - } - if (!b_rinex_header_updated and (d_pvt_solver->gps_cnav_utc_model.d_A0 != 0)) - { - rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_cnav_utc_model); - rp->update_nav_header(rp->navFile, d_pvt_solver->gps_cnav_utc_model, d_pvt_solver->gps_cnav_iono); - b_rinex_header_updated = true; + std::string signal("2S"); + rp->rinex_obs_header(rp->obsFile, gps_cnav_ephemeris_iter->second, d_rx_time, signal); + rp->rinex_nav_header(rp->navFile, d_pvt_solver->gps_cnav_iono, d_pvt_solver->gps_cnav_utc_model); + b_rinex_header_written = true; // do not write header anymore } break; - case 3: // GPS L5 + case 3: // GPS L5 only if (gps_cnav_ephemeris_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend()) { - rp->log_rinex_obs(rp->obsFile, gps_cnav_ephemeris_iter->second, d_rx_time, gnss_observables_map); - } - if (!b_rinex_header_updated and (d_pvt_solver->gps_cnav_utc_model.d_A0 != 0)) - { - rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_cnav_utc_model); - rp->update_nav_header(rp->navFile, d_pvt_solver->gps_cnav_utc_model, d_pvt_solver->gps_cnav_iono); - b_rinex_header_updated = true; + std::string signal("L5"); + rp->rinex_obs_header(rp->obsFile, gps_cnav_ephemeris_iter->second, d_rx_time, signal); + rp->rinex_nav_header(rp->navFile, d_pvt_solver->gps_cnav_iono, d_pvt_solver->gps_cnav_utc_model); + b_rinex_header_written = true; // do not write header anymore } break; case 4: // Galileo E1B only if (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend()) { - rp->log_rinex_obs(rp->obsFile, galileo_ephemeris_iter->second, d_rx_time, gnss_observables_map, "1B"); - } - if (!b_rinex_header_updated and (d_pvt_solver->galileo_utc_model.A0_6 != 0)) - { - rp->update_nav_header(rp->navGalFile, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); - rp->update_obs_header(rp->obsFile, d_pvt_solver->galileo_utc_model); - b_rinex_header_updated = true; + rp->rinex_obs_header(rp->obsFile, galileo_ephemeris_iter->second, d_rx_time); + rp->rinex_nav_header(rp->navGalFile, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); + b_rinex_header_written = true; // do not write header anymore } break; case 5: // Galileo E5a only if (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend()) { - rp->log_rinex_obs(rp->obsFile, galileo_ephemeris_iter->second, d_rx_time, gnss_observables_map, "5X"); - } - if (!b_rinex_header_updated and (d_pvt_solver->galileo_utc_model.A0_6 != 0)) - { - rp->update_nav_header(rp->navGalFile, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); - rp->update_obs_header(rp->obsFile, d_pvt_solver->galileo_utc_model); - b_rinex_header_updated = true; + std::string signal("5X"); + rp->rinex_obs_header(rp->obsFile, galileo_ephemeris_iter->second, d_rx_time, signal); + rp->rinex_nav_header(rp->navGalFile, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); + b_rinex_header_written = true; // do not write header anymore } break; case 6: // Galileo E5b only if (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend()) { - rp->log_rinex_obs(rp->obsFile, galileo_ephemeris_iter->second, d_rx_time, gnss_observables_map, "7X"); - } - if (!b_rinex_header_updated and (d_pvt_solver->galileo_utc_model.A0_6 != 0)) - { - rp->update_nav_header(rp->navGalFile, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); - rp->update_obs_header(rp->obsFile, d_pvt_solver->galileo_utc_model); - b_rinex_header_updated = true; + std::string signal("7X"); + rp->rinex_obs_header(rp->obsFile, galileo_ephemeris_iter->second, d_rx_time, signal); + rp->rinex_nav_header(rp->navGalFile, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); + b_rinex_header_written = true; // do not write header anymore } break; case 7: // GPS L1 C/A + GPS L2C if ((gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend()) and (gps_cnav_ephemeris_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend())) { - rp->log_rinex_obs(rp->obsFile, gps_ephemeris_iter->second, gps_cnav_ephemeris_iter->second, d_rx_time, gnss_observables_map); - } - if (!b_rinex_header_updated and (d_pvt_solver->gps_utc_model.d_A0 != 0)) - { - rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_utc_model); - rp->update_nav_header(rp->navFile, d_pvt_solver->gps_utc_model, d_pvt_solver->gps_iono); - b_rinex_header_updated = true; + std::string signal("1C 2S"); + rp->rinex_obs_header(rp->obsFile, gps_ephemeris_iter->second, gps_cnav_ephemeris_iter->second, d_rx_time, signal); + rp->rinex_nav_header(rp->navFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model); + b_rinex_header_written = true; // do not write header anymore } break; - case 8: // L1+L5 + case 8: // GPS L1 + GPS L5 if ((gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend()) and (gps_cnav_ephemeris_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend())) { - rp->log_rinex_obs(rp->obsFile, gps_ephemeris_iter->second, gps_cnav_ephemeris_iter->second, d_rx_time, gnss_observables_map); - } - if (!b_rinex_header_updated and ((d_pvt_solver->gps_cnav_utc_model.d_A0 != 0) or (d_pvt_solver->gps_utc_model.d_A0 != 0))) - { - if (d_pvt_solver->gps_cnav_utc_model.d_A0 != 0) - { - rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_cnav_utc_model); - rp->update_nav_header(rp->navFile, d_pvt_solver->gps_cnav_utc_model, d_pvt_solver->gps_cnav_iono); - } - else - { - rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_utc_model); - rp->update_nav_header(rp->navFile, d_pvt_solver->gps_utc_model, d_pvt_solver->gps_iono); - } - b_rinex_header_updated = true; + std::string signal("1C L5"); + rp->rinex_obs_header(rp->obsFile, gps_ephemeris_iter->second, gps_cnav_ephemeris_iter->second, d_rx_time, signal); + rp->rinex_nav_header(rp->navFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model); + b_rinex_header_written = true; // do not write header anymore } break; case 9: // GPS L1 C/A + Galileo E1B if ((galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend()) and (gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend())) { - rp->log_rinex_obs(rp->obsFile, gps_ephemeris_iter->second, galileo_ephemeris_iter->second, d_rx_time, gnss_observables_map); + std::string gal_signal("1B"); + rp->rinex_obs_header(rp->obsFile, gps_ephemeris_iter->second, galileo_ephemeris_iter->second, d_rx_time, gal_signal); + rp->rinex_nav_header(rp->navMixFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); + b_rinex_header_written = true; // do not write header anymore } - if (!b_rinex_header_updated and (d_pvt_solver->gps_utc_model.d_A0 != 0)) + break; + case 10: // GPS L1 C/A + Galileo E5a + if ((galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend()) and (gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend())) { - rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_utc_model); - rp->update_nav_header(rp->navMixFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); - b_rinex_header_updated = true; + std::string gal_signal("5X"); + rp->rinex_obs_header(rp->obsFile, gps_ephemeris_iter->second, galileo_ephemeris_iter->second, d_rx_time, gal_signal); + rp->rinex_nav_header(rp->navMixFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); + b_rinex_header_written = true; // do not write header anymore + } + break; + case 11: // GPS L1 C/A + Galileo E5b + if ((galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend()) and (gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend())) + { + std::string gal_signal("7X"); + rp->rinex_obs_header(rp->obsFile, gps_ephemeris_iter->second, galileo_ephemeris_iter->second, d_rx_time, gal_signal); + rp->rinex_nav_header(rp->navMixFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); + b_rinex_header_written = true; // do not write header anymore } break; case 13: // L5+E5a - if ((gps_cnav_ephemeris_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend()) and (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend())) + if ((galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend()) and (gps_cnav_ephemeris_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend())) { - rp->log_rinex_obs(rp->obsFile, gps_cnav_ephemeris_iter->second, galileo_ephemeris_iter->second, d_rx_time, gnss_observables_map); - } - if (!b_rinex_header_updated and (d_pvt_solver->gps_cnav_utc_model.d_A0 != 0) and (d_pvt_solver->galileo_utc_model.A0_6 != 0)) - { - rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_cnav_utc_model); - rp->update_nav_header(rp->navMixFile, d_pvt_solver->gps_cnav_utc_model, d_pvt_solver->gps_cnav_iono, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); - b_rinex_header_updated = true; // do not write header anymore + std::string gal_signal("5X"); + std::string gps_signal("L5"); + rp->rinex_obs_header(rp->obsFile, gps_cnav_ephemeris_iter->second, galileo_ephemeris_iter->second, d_rx_time, gps_signal, gal_signal); + rp->rinex_nav_header(rp->navMixFile, d_pvt_solver->gps_cnav_iono, d_pvt_solver->gps_cnav_utc_model, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); + b_rinex_header_written = true; // do not write header anymore } break; - case 14: // Galileo E1B + Galileo E5a - if (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + case 14: // Galileo E1B + Galileo E5a + if ((galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend())) { - rp->log_rinex_obs(rp->obsFile, galileo_ephemeris_iter->second, d_rx_time, gnss_observables_map, "1B 5X"); - } - if (!b_rinex_header_updated and (d_pvt_solver->galileo_utc_model.A0_6 != 0)) - { - rp->update_nav_header(rp->navGalFile, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); - rp->update_obs_header(rp->obsFile, d_pvt_solver->galileo_utc_model); - b_rinex_header_updated = true; + std::string gal_signal("1B 5X"); + rp->rinex_obs_header(rp->obsFile, galileo_ephemeris_iter->second, d_rx_time, gal_signal); + rp->rinex_nav_header(rp->navGalFile, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); + b_rinex_header_written = true; // do not write header anymore } break; - case 15: // Galileo E1B + Galileo E5b - if (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + case 15: // Galileo E1B + Galileo E5b + if ((galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend())) { - rp->log_rinex_obs(rp->obsFile, galileo_ephemeris_iter->second, d_rx_time, gnss_observables_map, "1B 7X"); - } - if (!b_rinex_header_updated and (d_pvt_solver->galileo_utc_model.A0_6 != 0)) - { - rp->update_nav_header(rp->navGalFile, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); - rp->update_obs_header(rp->obsFile, d_pvt_solver->galileo_utc_model); - b_rinex_header_updated = true; + std::string gal_signal("1B 7X"); + rp->rinex_obs_header(rp->obsFile, galileo_ephemeris_iter->second, d_rx_time, gal_signal); + rp->rinex_nav_header(rp->navGalFile, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); + b_rinex_header_written = true; // do not write header anymore } break; case 23: // GLONASS L1 C/A only if (glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) { - rp->log_rinex_obs(rp->obsFile, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, "1C"); - } - if (!b_rinex_header_updated and (d_pvt_solver->glonass_gnav_utc_model.d_tau_c != 0)) - { - rp->update_nav_header(rp->navGloFile, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); - rp->update_obs_header(rp->obsFile, d_pvt_solver->glonass_gnav_utc_model); - b_rinex_header_updated = true; + std::string signal("1G"); + rp->rinex_obs_header(rp->obsFile, glonass_gnav_ephemeris_iter->second, d_rx_time, signal); + rp->rinex_nav_header(rp->navGloFile, d_pvt_solver->glonass_gnav_utc_model, glonass_gnav_ephemeris_iter->second); + b_rinex_header_written = true; // do not write header anymore } break; case 24: // GLONASS L2 C/A only if (glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) { - rp->log_rinex_obs(rp->obsFile, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, "2C"); - } - if (!b_rinex_header_updated and (d_pvt_solver->glonass_gnav_utc_model.d_tau_c != 0)) - { - rp->update_nav_header(rp->navGloFile, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); - rp->update_obs_header(rp->obsFile, d_pvt_solver->glonass_gnav_utc_model); - b_rinex_header_updated = true; + std::string signal("2G"); + rp->rinex_obs_header(rp->obsFile, glonass_gnav_ephemeris_iter->second, d_rx_time, signal); + rp->rinex_nav_header(rp->navGloFile, d_pvt_solver->glonass_gnav_utc_model, glonass_gnav_ephemeris_iter->second); + b_rinex_header_written = true; // do not write header anymore } break; case 25: // GLONASS L1 C/A + GLONASS L2 C/A if (glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) { - rp->log_rinex_obs(rp->obsFile, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, "1C 2C"); - } - if (!b_rinex_header_updated and (d_pvt_solver->glonass_gnav_utc_model.d_tau_c != 0)) - { - rp->update_nav_header(rp->navMixFile, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); - rp->update_obs_header(rp->obsFile, d_pvt_solver->glonass_gnav_utc_model); - b_rinex_header_updated = true; + std::string signal("1G 2G"); + rp->rinex_obs_header(rp->obsFile, glonass_gnav_ephemeris_iter->second, d_rx_time, signal); + rp->rinex_nav_header(rp->navGloFile, d_pvt_solver->glonass_gnav_utc_model, glonass_gnav_ephemeris_iter->second); + b_rinex_header_written = true; // do not write header anymore } break; case 26: // GPS L1 C/A + GLONASS L1 C/A if ((glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) and (gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend())) { - rp->log_rinex_obs(rp->obsFile, gps_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map); - } - if (!b_rinex_header_updated and (d_pvt_solver->gps_utc_model.d_A0 != 0)) - { - rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_utc_model); - rp->update_nav_header(rp->navMixFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); - b_rinex_header_updated = true; // do not write header anymore + std::string glo_signal("1G"); + rp->rinex_obs_header(rp->obsFile, gps_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, glo_signal); + if (d_rinex_version == 3) + { + rp->rinex_nav_header(rp->navMixFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); + } + if (d_rinex_version == 2) + { + rp->rinex_nav_header(rp->navFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model); + rp->rinex_nav_header(rp->navGloFile, d_pvt_solver->glonass_gnav_utc_model, glonass_gnav_ephemeris_iter->second); + } + b_rinex_header_written = true; // do not write header anymore } break; - case 27: // Galileo E1B + GLONASS L1 C/A + case 27: // Galileo E1B + GLONASS L1 C/A if ((glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) and (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend())) { - rp->log_rinex_obs(rp->obsFile, galileo_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map); - } - if (!b_rinex_header_updated and (d_pvt_solver->galileo_utc_model.A0_6 != 0)) - { - rp->update_obs_header(rp->obsFile, d_pvt_solver->galileo_utc_model); - rp->update_nav_header(rp->navMixFile, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); - b_rinex_header_updated = true; // do not write header anymore + std::string glo_signal("1G"); + std::string gal_signal("1B"); + rp->rinex_obs_header(rp->obsFile, galileo_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, glo_signal, gal_signal); + rp->rinex_nav_header(rp->navMixFile, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); + b_rinex_header_written = true; // do not write header anymore } break; case 28: // GPS L2C + GLONASS L1 C/A if ((glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) and (gps_cnav_ephemeris_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend())) { - rp->log_rinex_obs(rp->obsFile, gps_cnav_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map); - } - if (!b_rinex_header_updated and (d_pvt_solver->gps_cnav_utc_model.d_A0 != 0)) - { - rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_cnav_utc_model); - rp->update_nav_header(rp->navMixFile, d_pvt_solver->gps_cnav_iono, d_pvt_solver->gps_cnav_utc_model, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); - b_rinex_header_updated = true; // do not write header anymore + std::string glo_signal("1G"); + rp->rinex_obs_header(rp->obsFile, gps_cnav_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, glo_signal); + rp->rinex_nav_header(rp->navMixFile, d_pvt_solver->gps_cnav_iono, d_pvt_solver->gps_cnav_utc_model, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); + b_rinex_header_written = true; // do not write header anymore } break; case 29: // GPS L1 C/A + GLONASS L2 C/A if ((glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) and (gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend())) { - rp->log_rinex_obs(rp->obsFile, gps_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map); - } - if (!b_rinex_header_updated and (d_pvt_solver->gps_utc_model.d_A0 != 0)) - { - rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_utc_model); - rp->update_nav_header(rp->navMixFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); - b_rinex_header_updated = true; // do not write header anymore + std::string glo_signal("2G"); + rp->rinex_obs_header(rp->obsFile, gps_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, glo_signal); + if (d_rinex_version == 3) + { + rp->rinex_nav_header(rp->navMixFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); + } + if (d_rinex_version == 2) + { + rp->rinex_nav_header(rp->navFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model); + rp->rinex_nav_header(rp->navGloFile, d_pvt_solver->glonass_gnav_utc_model, glonass_gnav_ephemeris_iter->second); + } + b_rinex_header_written = true; // do not write header anymore } break; - case 30: // Galileo E1B + GLONASS L2 C/A + case 30: // Galileo E1B + GLONASS L2 C/A if ((glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) and (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend())) { - rp->log_rinex_obs(rp->obsFile, galileo_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map); - } - if (!b_rinex_header_updated and (d_pvt_solver->galileo_utc_model.A0_6 != 0)) - { - rp->update_obs_header(rp->obsFile, d_pvt_solver->galileo_utc_model); - rp->update_nav_header(rp->navMixFile, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); - b_rinex_header_updated = true; // do not write header anymore + std::string glo_signal("2G"); + std::string gal_signal("1B"); + rp->rinex_obs_header(rp->obsFile, galileo_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, glo_signal, gal_signal); + rp->rinex_nav_header(rp->navMixFile, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); + b_rinex_header_written = true; // do not write header anymore } break; case 31: // GPS L2C + GLONASS L2 C/A if ((glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) and (gps_cnav_ephemeris_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend())) { - rp->log_rinex_obs(rp->obsFile, gps_cnav_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map); - } - if (!b_rinex_header_updated and (d_pvt_solver->gps_cnav_utc_model.d_A0 != 0)) - { - rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_cnav_utc_model); - rp->update_nav_header(rp->navMixFile, d_pvt_solver->gps_cnav_iono, d_pvt_solver->gps_cnav_utc_model, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); - b_rinex_header_updated = true; // do not write header anymore + std::string glo_signal("2G"); + rp->rinex_obs_header(rp->obsFile, gps_cnav_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, glo_signal); + rp->rinex_nav_header(rp->navMixFile, d_pvt_solver->gps_cnav_iono, d_pvt_solver->gps_cnav_utc_model, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); + b_rinex_header_written = true; // do not write header anymore } break; case 32: // L1+E1+L5+E5a - if ((gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend()) and (gps_cnav_ephemeris_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend()) and (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend())) + if ((gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend()) and + (gps_cnav_ephemeris_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend()) and + (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend())) { - rp->log_rinex_obs(rp->obsFile, gps_ephemeris_iter->second, gps_cnav_ephemeris_iter->second, galileo_ephemeris_iter->second, d_rx_time, gnss_observables_map); - } - if (!b_rinex_header_updated and ((d_pvt_solver->gps_cnav_utc_model.d_A0 != 0) or (d_pvt_solver->gps_utc_model.d_A0 != 0)) and (d_pvt_solver->galileo_utc_model.A0_6 != 0)) - { - if (d_pvt_solver->gps_cnav_utc_model.d_A0 != 0) - { - rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_cnav_utc_model); - rp->update_nav_header(rp->navMixFile, d_pvt_solver->gps_cnav_utc_model, d_pvt_solver->gps_cnav_iono, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); - } - else - { - rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_utc_model); - rp->update_nav_header(rp->navMixFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); - } - b_rinex_header_updated = true; // do not write header anymore + std::string gal_signal("1B 5X"); + std::string gps_signal("1C L5"); + rp->rinex_obs_header(rp->obsFile, gps_ephemeris_iter->second, gps_cnav_ephemeris_iter->second, galileo_ephemeris_iter->second, d_rx_time, gps_signal, gal_signal); + rp->rinex_nav_header(rp->navMixFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); + b_rinex_header_written = true; // do not write header anymore } break; case 33: // L1+E1+E5a - if ((gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend()) and (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend())) + if ((gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend()) and + (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend())) { - rp->log_rinex_obs(rp->obsFile, gps_ephemeris_iter->second, galileo_ephemeris_iter->second, d_rx_time, gnss_observables_map); - } - if (!b_rinex_header_updated and (d_pvt_solver->gps_utc_model.d_A0 != 0) and (d_pvt_solver->galileo_utc_model.A0_6 != 0)) - { - rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_utc_model); - rp->update_nav_header(rp->navMixFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); - b_rinex_header_updated = true; // do not write header anymore + std::string gal_signal("1B 5X"); + rp->rinex_obs_header(rp->obsFile, gps_ephemeris_iter->second, galileo_ephemeris_iter->second, d_rx_time, gal_signal); + rp->rinex_nav_header(rp->navMixFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); + b_rinex_header_written = true; // do not write header anymore } break; case 50: // BDS B1I only if (beidou_dnav_ephemeris_iter != d_pvt_solver->beidou_dnav_ephemeris_map.cend()) { - rp->log_rinex_obs(rp->obsFile, beidou_dnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, "B1"); + rp->rinex_obs_header(rp->obsFile, beidou_dnav_ephemeris_iter->second, d_rx_time, "B1"); + rp->rinex_nav_header(rp->navFile, d_pvt_solver->beidou_dnav_iono, d_pvt_solver->beidou_dnav_utc_model); + b_rinex_header_written = true; // do not write header anymore } - if (!b_rinex_header_updated and (d_pvt_solver->beidou_dnav_utc_model.d_A0_UTC != 0)) + + break; + case 60: // BDS B1I only + if (beidou_dnav_ephemeris_iter != d_pvt_solver->beidou_dnav_ephemeris_map.cend()) { - rp->update_obs_header(rp->obsFile, d_pvt_solver->beidou_dnav_utc_model); - rp->update_nav_header(rp->navFile, d_pvt_solver->beidou_dnav_utc_model, d_pvt_solver->beidou_dnav_iono); - b_rinex_header_updated = true; + rp->rinex_obs_header(rp->obsFile, beidou_dnav_ephemeris_iter->second, d_rx_time, "B3"); + rp->rinex_nav_header(rp->navFile, d_pvt_solver->beidou_dnav_iono, d_pvt_solver->beidou_dnav_utc_model); + b_rinex_header_written = true; // do not write header anymore + } + + break; + default: + break; + } + } + if (b_rinex_header_written) // The header is already written, we can now log the navigation message data + { + if (flag_write_RINEX_nav_output) + { + switch (type_of_rx) + { + case 1: // GPS L1 C/A only + rp->log_rinex_nav(rp->navFile, d_pvt_solver->gps_ephemeris_map); + break; + case 2: // GPS L2C only + rp->log_rinex_nav(rp->navFile, d_pvt_solver->gps_cnav_ephemeris_map); + break; + case 3: // GPS L5 only + rp->log_rinex_nav(rp->navFile, d_pvt_solver->gps_cnav_ephemeris_map); + break; + case 4: + case 5: + case 6: + rp->log_rinex_nav(rp->navGalFile, d_pvt_solver->galileo_ephemeris_map); + break; + case 7: // GPS L1 C/A + GPS L2C + rp->log_rinex_nav(rp->navFile, d_pvt_solver->gps_cnav_ephemeris_map); + break; + case 8: // L1+L5 + rp->log_rinex_nav(rp->navFile, d_pvt_solver->gps_ephemeris_map); + break; + case 9: + case 10: + case 11: + rp->log_rinex_nav(rp->navMixFile, d_pvt_solver->gps_ephemeris_map, d_pvt_solver->galileo_ephemeris_map); + break; + case 13: // L5+E5a + rp->log_rinex_nav(rp->navFile, d_pvt_solver->gps_cnav_ephemeris_map, d_pvt_solver->galileo_ephemeris_map); + break; + case 14: + case 15: + rp->log_rinex_nav(rp->navGalFile, d_pvt_solver->galileo_ephemeris_map); + break; + case 23: + case 24: + case 25: + rp->log_rinex_nav(rp->navGloFile, d_pvt_solver->glonass_gnav_ephemeris_map); + break; + case 26: // GPS L1 C/A + GLONASS L1 C/A + if (d_rinex_version == 3) + { + rp->log_rinex_nav(rp->navMixFile, d_pvt_solver->gps_ephemeris_map, d_pvt_solver->glonass_gnav_ephemeris_map); + } + if (d_rinex_version == 2) + { + rp->log_rinex_nav(rp->navFile, d_pvt_solver->gps_ephemeris_map); + rp->log_rinex_nav(rp->navGloFile, d_pvt_solver->glonass_gnav_ephemeris_map); + } + break; + case 27: // Galileo E1B + GLONASS L1 C/A + rp->log_rinex_nav(rp->navMixFile, d_pvt_solver->galileo_ephemeris_map, d_pvt_solver->glonass_gnav_ephemeris_map); + break; + case 28: // GPS L2C + GLONASS L1 C/A + rp->log_rinex_nav(rp->navMixFile, d_pvt_solver->gps_cnav_ephemeris_map, d_pvt_solver->glonass_gnav_ephemeris_map); + break; + case 29: // GPS L1 C/A + GLONASS L2 C/A + if (d_rinex_version == 3) + { + rp->log_rinex_nav(rp->navMixFile, d_pvt_solver->gps_ephemeris_map, d_pvt_solver->glonass_gnav_ephemeris_map); + } + if (d_rinex_version == 2) + { + rp->log_rinex_nav(rp->navFile, d_pvt_solver->gps_ephemeris_map); + rp->log_rinex_nav(rp->navGloFile, d_pvt_solver->glonass_gnav_ephemeris_map); + } + break; + case 30: // Galileo E1B + GLONASS L2 C/A + rp->log_rinex_nav(rp->navMixFile, d_pvt_solver->galileo_ephemeris_map, d_pvt_solver->glonass_gnav_ephemeris_map); + break; + case 31: // GPS L2C + GLONASS L2 C/A + rp->log_rinex_nav(rp->navMixFile, d_pvt_solver->gps_cnav_ephemeris_map, d_pvt_solver->glonass_gnav_ephemeris_map); + break; + case 32: // L1+E1+L5+E5a + rp->log_rinex_nav(rp->navMixFile, d_pvt_solver->gps_ephemeris_map, d_pvt_solver->galileo_ephemeris_map); + break; + case 33: // L1+E1+E5a + rp->log_rinex_nav(rp->navMixFile, d_pvt_solver->gps_ephemeris_map, d_pvt_solver->galileo_ephemeris_map); + break; + case 50: // BDS B1I only + rp->log_rinex_nav(rp->navFile, d_pvt_solver->beidou_dnav_ephemeris_map); + break; + default: + break; + } + } + galileo_ephemeris_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); + gps_ephemeris_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); + gps_cnav_ephemeris_iter = d_pvt_solver->gps_cnav_ephemeris_map.cbegin(); + glonass_gnav_ephemeris_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); + beidou_dnav_ephemeris_iter = d_pvt_solver->beidou_dnav_ephemeris_map.cbegin(); + + // Log observables into the RINEX file + if (flag_write_RINEX_obs_output) + { + switch (type_of_rx) + { + case 1: // GPS L1 C/A only + if (gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend()) + { + rp->log_rinex_obs(rp->obsFile, gps_ephemeris_iter->second, d_rx_time, gnss_observables_map); + } + if (!b_rinex_header_updated and (d_pvt_solver->gps_utc_model.d_A0 != 0)) + { + rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_utc_model); + rp->update_nav_header(rp->navFile, d_pvt_solver->gps_utc_model, d_pvt_solver->gps_iono); + b_rinex_header_updated = true; + } + break; + case 2: // GPS L2C only + if (gps_cnav_ephemeris_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend()) + { + rp->log_rinex_obs(rp->obsFile, gps_cnav_ephemeris_iter->second, d_rx_time, gnss_observables_map); + } + if (!b_rinex_header_updated and (d_pvt_solver->gps_cnav_utc_model.d_A0 != 0)) + { + rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_cnav_utc_model); + rp->update_nav_header(rp->navFile, d_pvt_solver->gps_cnav_utc_model, d_pvt_solver->gps_cnav_iono); + b_rinex_header_updated = true; + } + break; + case 3: // GPS L5 + if (gps_cnav_ephemeris_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend()) + { + rp->log_rinex_obs(rp->obsFile, gps_cnav_ephemeris_iter->second, d_rx_time, gnss_observables_map); + } + if (!b_rinex_header_updated and (d_pvt_solver->gps_cnav_utc_model.d_A0 != 0)) + { + rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_cnav_utc_model); + rp->update_nav_header(rp->navFile, d_pvt_solver->gps_cnav_utc_model, d_pvt_solver->gps_cnav_iono); + b_rinex_header_updated = true; + } + break; + case 4: // Galileo E1B only + if (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + rp->log_rinex_obs(rp->obsFile, galileo_ephemeris_iter->second, d_rx_time, gnss_observables_map, "1B"); + } + if (!b_rinex_header_updated and (d_pvt_solver->galileo_utc_model.A0_6 != 0)) + { + rp->update_nav_header(rp->navGalFile, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); + rp->update_obs_header(rp->obsFile, d_pvt_solver->galileo_utc_model); + b_rinex_header_updated = true; + } + break; + case 5: // Galileo E5a only + if (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + rp->log_rinex_obs(rp->obsFile, galileo_ephemeris_iter->second, d_rx_time, gnss_observables_map, "5X"); + } + if (!b_rinex_header_updated and (d_pvt_solver->galileo_utc_model.A0_6 != 0)) + { + rp->update_nav_header(rp->navGalFile, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); + rp->update_obs_header(rp->obsFile, d_pvt_solver->galileo_utc_model); + b_rinex_header_updated = true; + } + break; + case 6: // Galileo E5b only + if (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + rp->log_rinex_obs(rp->obsFile, galileo_ephemeris_iter->second, d_rx_time, gnss_observables_map, "7X"); + } + if (!b_rinex_header_updated and (d_pvt_solver->galileo_utc_model.A0_6 != 0)) + { + rp->update_nav_header(rp->navGalFile, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); + rp->update_obs_header(rp->obsFile, d_pvt_solver->galileo_utc_model); + b_rinex_header_updated = true; + } + break; + case 7: // GPS L1 C/A + GPS L2C + if ((gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend()) and (gps_cnav_ephemeris_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend())) + { + rp->log_rinex_obs(rp->obsFile, gps_ephemeris_iter->second, gps_cnav_ephemeris_iter->second, d_rx_time, gnss_observables_map); + } + if (!b_rinex_header_updated and (d_pvt_solver->gps_utc_model.d_A0 != 0)) + { + rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_utc_model); + rp->update_nav_header(rp->navFile, d_pvt_solver->gps_utc_model, d_pvt_solver->gps_iono); + b_rinex_header_updated = true; + } + break; + case 8: // L1+L5 + if ((gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend()) and (gps_cnav_ephemeris_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend())) + { + rp->log_rinex_obs(rp->obsFile, gps_ephemeris_iter->second, gps_cnav_ephemeris_iter->second, d_rx_time, gnss_observables_map); + } + if (!b_rinex_header_updated and ((d_pvt_solver->gps_cnav_utc_model.d_A0 != 0) or (d_pvt_solver->gps_utc_model.d_A0 != 0))) + { + if (d_pvt_solver->gps_cnav_utc_model.d_A0 != 0) + { + rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_cnav_utc_model); + rp->update_nav_header(rp->navFile, d_pvt_solver->gps_cnav_utc_model, d_pvt_solver->gps_cnav_iono); + } + else + { + rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_utc_model); + rp->update_nav_header(rp->navFile, d_pvt_solver->gps_utc_model, d_pvt_solver->gps_iono); + } + b_rinex_header_updated = true; + } + break; + case 9: // GPS L1 C/A + Galileo E1B + if ((galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend()) and (gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend())) + { + rp->log_rinex_obs(rp->obsFile, gps_ephemeris_iter->second, galileo_ephemeris_iter->second, d_rx_time, gnss_observables_map); + } + if (!b_rinex_header_updated and (d_pvt_solver->gps_utc_model.d_A0 != 0)) + { + rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_utc_model); + rp->update_nav_header(rp->navMixFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); + b_rinex_header_updated = true; + } + break; + case 13: // L5+E5a + if ((gps_cnav_ephemeris_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend()) and (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend())) + { + rp->log_rinex_obs(rp->obsFile, gps_cnav_ephemeris_iter->second, galileo_ephemeris_iter->second, d_rx_time, gnss_observables_map); + } + if (!b_rinex_header_updated and (d_pvt_solver->gps_cnav_utc_model.d_A0 != 0) and (d_pvt_solver->galileo_utc_model.A0_6 != 0)) + { + rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_cnav_utc_model); + rp->update_nav_header(rp->navMixFile, d_pvt_solver->gps_cnav_utc_model, d_pvt_solver->gps_cnav_iono, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); + b_rinex_header_updated = true; // do not write header anymore + } + break; + case 14: // Galileo E1B + Galileo E5a + if (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + rp->log_rinex_obs(rp->obsFile, galileo_ephemeris_iter->second, d_rx_time, gnss_observables_map, "1B 5X"); + } + if (!b_rinex_header_updated and (d_pvt_solver->galileo_utc_model.A0_6 != 0)) + { + rp->update_nav_header(rp->navGalFile, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); + rp->update_obs_header(rp->obsFile, d_pvt_solver->galileo_utc_model); + b_rinex_header_updated = true; + } + break; + case 15: // Galileo E1B + Galileo E5b + if (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + rp->log_rinex_obs(rp->obsFile, galileo_ephemeris_iter->second, d_rx_time, gnss_observables_map, "1B 7X"); + } + if (!b_rinex_header_updated and (d_pvt_solver->galileo_utc_model.A0_6 != 0)) + { + rp->update_nav_header(rp->navGalFile, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); + rp->update_obs_header(rp->obsFile, d_pvt_solver->galileo_utc_model); + b_rinex_header_updated = true; + } + break; + case 23: // GLONASS L1 C/A only + if (glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) + { + rp->log_rinex_obs(rp->obsFile, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, "1C"); + } + if (!b_rinex_header_updated and (d_pvt_solver->glonass_gnav_utc_model.d_tau_c != 0)) + { + rp->update_nav_header(rp->navGloFile, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); + rp->update_obs_header(rp->obsFile, d_pvt_solver->glonass_gnav_utc_model); + b_rinex_header_updated = true; + } + break; + case 24: // GLONASS L2 C/A only + if (glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) + { + rp->log_rinex_obs(rp->obsFile, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, "2C"); + } + if (!b_rinex_header_updated and (d_pvt_solver->glonass_gnav_utc_model.d_tau_c != 0)) + { + rp->update_nav_header(rp->navGloFile, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); + rp->update_obs_header(rp->obsFile, d_pvt_solver->glonass_gnav_utc_model); + b_rinex_header_updated = true; + } + break; + case 25: // GLONASS L1 C/A + GLONASS L2 C/A + if (glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) + { + rp->log_rinex_obs(rp->obsFile, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, "1C 2C"); + } + if (!b_rinex_header_updated and (d_pvt_solver->glonass_gnav_utc_model.d_tau_c != 0)) + { + rp->update_nav_header(rp->navMixFile, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); + rp->update_obs_header(rp->obsFile, d_pvt_solver->glonass_gnav_utc_model); + b_rinex_header_updated = true; + } + break; + case 26: // GPS L1 C/A + GLONASS L1 C/A + if ((glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) and (gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend())) + { + rp->log_rinex_obs(rp->obsFile, gps_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map); + } + if (!b_rinex_header_updated and (d_pvt_solver->gps_utc_model.d_A0 != 0)) + { + rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_utc_model); + rp->update_nav_header(rp->navMixFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); + b_rinex_header_updated = true; // do not write header anymore + } + break; + case 27: // Galileo E1B + GLONASS L1 C/A + if ((glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) and (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend())) + { + rp->log_rinex_obs(rp->obsFile, galileo_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map); + } + if (!b_rinex_header_updated and (d_pvt_solver->galileo_utc_model.A0_6 != 0)) + { + rp->update_obs_header(rp->obsFile, d_pvt_solver->galileo_utc_model); + rp->update_nav_header(rp->navMixFile, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); + b_rinex_header_updated = true; // do not write header anymore + } + break; + case 28: // GPS L2C + GLONASS L1 C/A + if ((glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) and (gps_cnav_ephemeris_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend())) + { + rp->log_rinex_obs(rp->obsFile, gps_cnav_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map); + } + if (!b_rinex_header_updated and (d_pvt_solver->gps_cnav_utc_model.d_A0 != 0)) + { + rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_cnav_utc_model); + rp->update_nav_header(rp->navMixFile, d_pvt_solver->gps_cnav_iono, d_pvt_solver->gps_cnav_utc_model, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); + b_rinex_header_updated = true; // do not write header anymore + } + break; + case 29: // GPS L1 C/A + GLONASS L2 C/A + if ((glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) and (gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend())) + { + rp->log_rinex_obs(rp->obsFile, gps_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map); + } + if (!b_rinex_header_updated and (d_pvt_solver->gps_utc_model.d_A0 != 0)) + { + rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_utc_model); + rp->update_nav_header(rp->navMixFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); + b_rinex_header_updated = true; // do not write header anymore + } + break; + case 30: // Galileo E1B + GLONASS L2 C/A + if ((glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) and (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend())) + { + rp->log_rinex_obs(rp->obsFile, galileo_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map); + } + if (!b_rinex_header_updated and (d_pvt_solver->galileo_utc_model.A0_6 != 0)) + { + rp->update_obs_header(rp->obsFile, d_pvt_solver->galileo_utc_model); + rp->update_nav_header(rp->navMixFile, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); + b_rinex_header_updated = true; // do not write header anymore + } + break; + case 31: // GPS L2C + GLONASS L2 C/A + if ((glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) and (gps_cnav_ephemeris_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend())) + { + rp->log_rinex_obs(rp->obsFile, gps_cnav_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map); + } + if (!b_rinex_header_updated and (d_pvt_solver->gps_cnav_utc_model.d_A0 != 0)) + { + rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_cnav_utc_model); + rp->update_nav_header(rp->navMixFile, d_pvt_solver->gps_cnav_iono, d_pvt_solver->gps_cnav_utc_model, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); + b_rinex_header_updated = true; // do not write header anymore + } + break; + case 32: // L1+E1+L5+E5a + if ((gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend()) and (gps_cnav_ephemeris_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend()) and (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend())) + { + rp->log_rinex_obs(rp->obsFile, gps_ephemeris_iter->second, gps_cnav_ephemeris_iter->second, galileo_ephemeris_iter->second, d_rx_time, gnss_observables_map); + } + if (!b_rinex_header_updated and ((d_pvt_solver->gps_cnav_utc_model.d_A0 != 0) or (d_pvt_solver->gps_utc_model.d_A0 != 0)) and (d_pvt_solver->galileo_utc_model.A0_6 != 0)) + { + if (d_pvt_solver->gps_cnav_utc_model.d_A0 != 0) + { + rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_cnav_utc_model); + rp->update_nav_header(rp->navMixFile, d_pvt_solver->gps_cnav_utc_model, d_pvt_solver->gps_cnav_iono, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); + } + else + { + rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_utc_model); + rp->update_nav_header(rp->navMixFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); + } + b_rinex_header_updated = true; // do not write header anymore + } + break; + case 33: // L1+E1+E5a + if ((gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend()) and (galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend())) + { + rp->log_rinex_obs(rp->obsFile, gps_ephemeris_iter->second, galileo_ephemeris_iter->second, d_rx_time, gnss_observables_map); + } + if (!b_rinex_header_updated and (d_pvt_solver->gps_utc_model.d_A0 != 0) and (d_pvt_solver->galileo_utc_model.A0_6 != 0)) + { + rp->update_obs_header(rp->obsFile, d_pvt_solver->gps_utc_model); + rp->update_nav_header(rp->navMixFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model); + b_rinex_header_updated = true; // do not write header anymore + } + break; + case 50: // BDS B1I only + if (beidou_dnav_ephemeris_iter != d_pvt_solver->beidou_dnav_ephemeris_map.cend()) + { + rp->log_rinex_obs(rp->obsFile, beidou_dnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, "B1"); + } + if (!b_rinex_header_updated and (d_pvt_solver->beidou_dnav_utc_model.d_A0_UTC != 0)) + { + rp->update_obs_header(rp->obsFile, d_pvt_solver->beidou_dnav_utc_model); + rp->update_nav_header(rp->navFile, d_pvt_solver->beidou_dnav_utc_model, d_pvt_solver->beidou_dnav_iono); + b_rinex_header_updated = true; + } + break; + default: + break; + } + } + } + } + + // ####################### RTCM MESSAGES ################# + try + { + if (b_rtcm_writing_started and b_rtcm_enabled) + { + switch (type_of_rx) + { + case 1: // GPS L1 C/A + if (flag_write_RTCM_1019_output == true) + { + for (const auto& gps_eph_iter : d_pvt_solver->gps_ephemeris_map) + { + d_rtcm_printer->Print_Rtcm_MT1019(gps_eph_iter.second); + } + } + if (flag_write_RTCM_MSM_output == true) + { + auto gps_eph_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); + if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, gps_eph_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + } + break; + case 4: + case 5: + case 6: + if (flag_write_RTCM_1045_output == true) + { + for (const auto& gal_eph_iter : d_pvt_solver->galileo_ephemeris_map) + { + d_rtcm_printer->Print_Rtcm_MT1045(gal_eph_iter.second); + } + } + if (flag_write_RTCM_MSM_output == true) + { + auto gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_eph_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + } + break; + case 7: // GPS L1 C/A + GPS L2C + if (flag_write_RTCM_1019_output == true) + { + for (const auto& gps_eph_iter : d_pvt_solver->gps_ephemeris_map) + { + d_rtcm_printer->Print_Rtcm_MT1019(gps_eph_iter.second); + } + } + if (flag_write_RTCM_MSM_output == true) + { + auto gps_eph_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); + auto gps_cnav_eph_iter = d_pvt_solver->gps_cnav_ephemeris_map.cbegin(); + if ((gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) and (gps_cnav_eph_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend())) + { + d_rtcm_printer->Print_Rtcm_MSM(7, gps_eph_iter->second, gps_cnav_eph_iter->second, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + } + break; + case 8: // L1+L5 + if (flag_write_RTCM_1019_output == true) + { + for (const auto& gps_eph_iter : d_pvt_solver->gps_ephemeris_map) + { + d_rtcm_printer->Print_Rtcm_MT1019(gps_eph_iter.second); + } + } + if (flag_write_RTCM_MSM_output == true) + { + auto gps_eph_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); + auto gps_cnav_eph_iter = d_pvt_solver->gps_cnav_ephemeris_map.cbegin(); + if ((gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) and (gps_cnav_eph_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend())) + { + d_rtcm_printer->Print_Rtcm_MSM(7, gps_eph_iter->second, gps_cnav_eph_iter->second, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + } + break; + case 9: // GPS L1 C/A + Galileo E1B + if (flag_write_RTCM_1019_output == true) + { + for (const auto& gps_eph_iter : d_pvt_solver->gps_ephemeris_map) + { + d_rtcm_printer->Print_Rtcm_MT1019(gps_eph_iter.second); + } + } + if (flag_write_RTCM_1045_output == true) + { + for (const auto& gal_eph_iter : d_pvt_solver->galileo_ephemeris_map) + { + d_rtcm_printer->Print_Rtcm_MT1045(gal_eph_iter.second); + } + } + if (flag_write_RTCM_MSM_output == true) + { + std::map::const_iterator gnss_observables_iter; + auto gps_eph_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); + auto gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); + int gps_channel = 0; + int gal_channel = 0; + for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) + { + std::string system(&gnss_observables_iter->second.System, 1); + if (gps_channel == 0) + { + if (system == "G") + { + // This is a channel with valid GPS signal + gps_eph_iter = d_pvt_solver->gps_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) + { + gps_channel = 1; + } + } + } + if (gal_channel == 0) + { + if (system == "E") + { + gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + gal_channel = 1; + } + } + } + } + if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, gps_eph_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_eph_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + } + break; + case 13: // L5+E5a + if (flag_write_RTCM_1045_output == true) + { + for (const auto& gal_eph_iter : d_pvt_solver->galileo_ephemeris_map) + { + d_rtcm_printer->Print_Rtcm_MT1045(gal_eph_iter.second); + } + } + + if (flag_write_RTCM_MSM_output and d_rtcm_MSM_rate_ms != 0) + { + std::map::const_iterator gnss_observables_iter; + auto gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); + auto gps_cnav_eph_iter = d_pvt_solver->gps_cnav_ephemeris_map.cbegin(); + int gal_channel = 0; + int gps_channel = 0; + for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) + { + std::string system(&gnss_observables_iter->second.System, 1); + if (gps_channel == 0) + { + if (system == "G") + { + // This is a channel with valid GPS signal + gps_cnav_eph_iter = d_pvt_solver->gps_cnav_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (gps_cnav_eph_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend()) + { + gps_channel = 1; + } + } + } + if (gal_channel == 0) + { + if (system == "E") + { + gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + gal_channel = 1; + } + } + } + } + + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend() and (d_rtcm_MT1097_rate_ms != 0)) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_eph_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + if (gps_cnav_eph_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend() and (d_rtcm_MT1077_rate_ms != 0)) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, gps_cnav_eph_iter->second, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + } + break; + case 14: + case 15: + if (flag_write_RTCM_1045_output == true) + { + for (const auto& gal_eph_iter : d_pvt_solver->galileo_ephemeris_map) + { + d_rtcm_printer->Print_Rtcm_MT1045(gal_eph_iter.second); + } + } + if (flag_write_RTCM_MSM_output == true) + { + auto gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_eph_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + } + break; + case 23: + case 24: + case 25: + if (flag_write_RTCM_1020_output == true) + { + for (auto glonass_gnav_ephemeris_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend(); glonass_gnav_ephemeris_iter++) + { + d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_ephemeris_iter->second, d_pvt_solver->glonass_gnav_utc_model); + } + } + if (flag_write_RTCM_MSM_output == true) + { + auto glo_gnav_ephemeris_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); + if (glo_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glo_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + } + b_rtcm_writing_started = true; + break; + case 26: // GPS L1 C/A + GLONASS L1 C/A + if (flag_write_RTCM_1019_output == true) + { + for (const auto& gps_eph_iter : d_pvt_solver->gps_ephemeris_map) + { + d_rtcm_printer->Print_Rtcm_MT1019(gps_eph_iter.second); + } + } + if (flag_write_RTCM_1020_output == true) + { + for (auto glonass_gnav_ephemeris_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend(); glonass_gnav_ephemeris_iter++) + { + d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_ephemeris_iter->second, d_pvt_solver->glonass_gnav_utc_model); + } + } + if (flag_write_RTCM_MSM_output == true) + { + std::map::const_iterator gnss_observables_iter; + auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); + auto gps_eph_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); + int gps_channel = 0; + int glo_channel = 0; + for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) + { + std::string system(&gnss_observables_iter->second.System, 1); + if (gps_channel == 0) + { + if (system == "G") + { + // This is a channel with valid GPS signal + gps_eph_iter = d_pvt_solver->gps_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) + { + gps_channel = 1; + } + } + } + if (glo_channel == 0) + { + if (system == "R") + { + glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) + { + glo_channel = 1; + } + } + } + } + + if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glonass_gnav_eph_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, gps_eph_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + } + break; + case 27: // GLONASS L1 C/A + Galileo E1B + if (flag_write_RTCM_1020_output == true) + { + for (auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend(); glonass_gnav_eph_iter++) + { + d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_eph_iter->second, d_pvt_solver->glonass_gnav_utc_model); + } + } + if (flag_write_RTCM_1045_output == true) + { + for (const auto& gal_eph_iter : d_pvt_solver->galileo_ephemeris_map) + { + d_rtcm_printer->Print_Rtcm_MT1045(gal_eph_iter.second); + } + } + if (flag_write_RTCM_MSM_output == true) + { + std::map::const_iterator gnss_observables_iter; + auto gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); + auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); + int gal_channel = 0; + int glo_channel = 0; + for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) + { + std::string system(&gnss_observables_iter->second.System, 1); + if (gal_channel == 0) + { + if (system == "E") + { + // This is a channel with valid GPS signal + gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + gal_channel = 1; + } + } + } + if (glo_channel == 0) + { + if (system == "R") + { + glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) + { + glo_channel = 1; + } + } + } + } + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_eph_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glonass_gnav_eph_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + } + break; + case 29: // GPS L1 C/A + GLONASS L2 C/A + if (flag_write_RTCM_1019_output == true) + { + for (const auto& gps_eph_iter : d_pvt_solver->gps_ephemeris_map) + { + d_rtcm_printer->Print_Rtcm_MT1019(gps_eph_iter.second); + } + } + if (flag_write_RTCM_1020_output == true) + { + for (auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend(); glonass_gnav_eph_iter++) + { + d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_eph_iter->second, d_pvt_solver->glonass_gnav_utc_model); + } + } + if (flag_write_RTCM_MSM_output == true) + { + std::map::const_iterator gnss_observables_iter; + auto gps_eph_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); + auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); + int gps_channel = 0; + int glo_channel = 0; + for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) + { + std::string system(&gnss_observables_iter->second.System, 1); + if (gps_channel == 0) + { + if (system == "G") + { + // This is a channel with valid GPS signal + gps_eph_iter = d_pvt_solver->gps_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) + { + gps_channel = 1; + } + } + } + if (glo_channel == 0) + { + if (system == "R") + { + glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) + { + glo_channel = 1; + } + } + } + } + if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glonass_gnav_eph_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, gps_eph_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + } + break; + case 30: // GLONASS L2 C/A + Galileo E1B + if (flag_write_RTCM_1020_output == true) + { + for (auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend(); glonass_gnav_eph_iter++) + { + d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_eph_iter->second, d_pvt_solver->glonass_gnav_utc_model); + } + } + if (flag_write_RTCM_1045_output == true) + { + for (const auto& gal_eph_iter : d_pvt_solver->galileo_ephemeris_map) + { + d_rtcm_printer->Print_Rtcm_MT1045(gal_eph_iter.second); + } + } + if (flag_write_RTCM_MSM_output == true) + { + std::map::const_iterator gnss_observables_iter; + auto gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); + auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); + int gal_channel = 0; + int glo_channel = 0; + for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) + { + std::string system(&gnss_observables_iter->second.System, 1); + if (gal_channel == 0) + { + if (system == "E") + { + // This is a channel with valid GPS signal + gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + gal_channel = 1; + } + } + } + if (glo_channel == 0) + { + if (system == "R") + { + glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) + { + glo_channel = 1; + } + } + } + } + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_eph_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glonass_gnav_eph_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + } + break; + case 32: // L1+E1+L5+E5a + if (flag_write_RTCM_1019_output == true) + { + for (const auto& gps_eph_iter : d_pvt_solver->gps_ephemeris_map) + { + d_rtcm_printer->Print_Rtcm_MT1019(gps_eph_iter.second); + } + } + if (flag_write_RTCM_1045_output == true) + { + for (const auto& gal_eph_iter : d_pvt_solver->galileo_ephemeris_map) + { + d_rtcm_printer->Print_Rtcm_MT1045(gal_eph_iter.second); + } + } + if (flag_write_RTCM_MSM_output == true) + { + std::map::const_iterator gnss_observables_iter; + auto gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); + auto gps_eph_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); + int gal_channel = 0; + int gps_channel = 0; + for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) + { + std::string system(&gnss_observables_iter->second.System, 1); + if (gal_channel == 0) + { + if (system == "E") + { + // This is a channel with valid GPS signal + gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + gal_channel = 1; + } + } + } + if (gps_channel == 0) + { + if (system == "G") + { + gps_eph_iter = d_pvt_solver->gps_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) + { + gps_channel = 1; + } + } + } + } + if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, gps_eph_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_eph_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } } break; default: break; } } - } - } - // ####################### RTCM MESSAGES ################# - try - { - if (b_rtcm_writing_started and b_rtcm_enabled) - { - switch (type_of_rx) + if (!b_rtcm_writing_started and b_rtcm_enabled) // the first time { - case 1: // GPS L1 C/A - if (flag_write_RTCM_1019_output == true) + switch (type_of_rx) { - for (const auto& gps_eph_iter : d_pvt_solver->gps_ephemeris_map) + case 1: // GPS L1 C/A + if (d_rtcm_MT1019_rate_ms != 0) // allows deactivating messages by setting rate = 0 { - d_rtcm_printer->Print_Rtcm_MT1019(gps_eph_iter.second); - } - } - if (flag_write_RTCM_MSM_output == true) - { - auto gps_eph_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); - if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, gps_eph_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); - } - } - break; - case 4: - case 5: - case 6: - if (flag_write_RTCM_1045_output == true) - { - for (const auto& gal_eph_iter : d_pvt_solver->galileo_ephemeris_map) - { - d_rtcm_printer->Print_Rtcm_MT1045(gal_eph_iter.second); - } - } - if (flag_write_RTCM_MSM_output == true) - { - auto gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); - if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_eph_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); - } - } - break; - case 7: // GPS L1 C/A + GPS L2C - if (flag_write_RTCM_1019_output == true) - { - for (const auto& gps_eph_iter : d_pvt_solver->gps_ephemeris_map) - { - d_rtcm_printer->Print_Rtcm_MT1019(gps_eph_iter.second); - } - } - if (flag_write_RTCM_MSM_output == true) - { - auto gps_eph_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); - auto gps_cnav_eph_iter = d_pvt_solver->gps_cnav_ephemeris_map.cbegin(); - if ((gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) and (gps_cnav_eph_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend())) - { - d_rtcm_printer->Print_Rtcm_MSM(7, gps_eph_iter->second, gps_cnav_eph_iter->second, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); - } - } - break; - case 8: // L1+L5 - if (flag_write_RTCM_1019_output == true) - { - for (const auto& gps_eph_iter : d_pvt_solver->gps_ephemeris_map) - { - d_rtcm_printer->Print_Rtcm_MT1019(gps_eph_iter.second); - } - } - if (flag_write_RTCM_MSM_output == true) - { - auto gps_eph_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); - auto gps_cnav_eph_iter = d_pvt_solver->gps_cnav_ephemeris_map.cbegin(); - if ((gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) and (gps_cnav_eph_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend())) - { - d_rtcm_printer->Print_Rtcm_MSM(7, gps_eph_iter->second, gps_cnav_eph_iter->second, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); - } - } - break; - case 9: // GPS L1 C/A + Galileo E1B - if (flag_write_RTCM_1019_output == true) - { - for (const auto& gps_eph_iter : d_pvt_solver->gps_ephemeris_map) - { - d_rtcm_printer->Print_Rtcm_MT1019(gps_eph_iter.second); - } - } - if (flag_write_RTCM_1045_output == true) - { - for (const auto& gal_eph_iter : d_pvt_solver->galileo_ephemeris_map) - { - d_rtcm_printer->Print_Rtcm_MT1045(gal_eph_iter.second); - } - } - if (flag_write_RTCM_MSM_output == true) - { - std::map::const_iterator gnss_observables_iter; - auto gps_eph_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); - auto gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); - int gps_channel = 0; - int gal_channel = 0; - for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) - { - std::string system(&gnss_observables_iter->second.System, 1); - if (gps_channel == 0) + for (const auto& gps_eph_iter : d_pvt_solver->gps_ephemeris_map) { - if (system == "G") - { - // This is a channel with valid GPS signal - gps_eph_iter = d_pvt_solver->gps_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) - { - gps_channel = 1; - } - } - } - if (gal_channel == 0) - { - if (system == "E") - { - gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) - { - gal_channel = 1; - } - } + d_rtcm_printer->Print_Rtcm_MT1019(gps_eph_iter.second); } } - if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) + if (d_rtcm_MSM_rate_ms != 0) // allows deactivating messages by setting rate = 0 { - d_rtcm_printer->Print_Rtcm_MSM(7, gps_eph_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); - } - if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_eph_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); - } - } - break; - case 13: // L5+E5a - if (flag_write_RTCM_1045_output == true) - { - for (const auto& gal_eph_iter : d_pvt_solver->galileo_ephemeris_map) - { - d_rtcm_printer->Print_Rtcm_MT1045(gal_eph_iter.second); - } - } + auto gps_eph_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); - if (flag_write_RTCM_MSM_output and d_rtcm_MSM_rate_ms != 0) - { - std::map::const_iterator gnss_observables_iter; - auto gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); - auto gps_cnav_eph_iter = d_pvt_solver->gps_cnav_ephemeris_map.cbegin(); - int gal_channel = 0; - int gps_channel = 0; - for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) - { - std::string system(&gnss_observables_iter->second.System, 1); - if (gps_channel == 0) + if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) { - if (system == "G") - { - // This is a channel with valid GPS signal - gps_cnav_eph_iter = d_pvt_solver->gps_cnav_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (gps_cnav_eph_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend()) - { - gps_channel = 1; - } - } - } - if (gal_channel == 0) - { - if (system == "E") - { - gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) - { - gal_channel = 1; - } - } + d_rtcm_printer->Print_Rtcm_MSM(7, gps_eph_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); } } + b_rtcm_writing_started = true; + break; + case 4: + case 5: + case 6: + if (d_rtcm_MT1045_rate_ms != 0) // allows deactivating messages by setting rate = 0 + { + for (const auto& gal_eph_iter : d_pvt_solver->galileo_ephemeris_map) + { + d_rtcm_printer->Print_Rtcm_MT1045(gal_eph_iter.second); + } + } + if (d_rtcm_MSM_rate_ms != 0) + { + auto gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_eph_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + } + b_rtcm_writing_started = true; + break; + case 7: // GPS L1 C/A + GPS L2C + if (d_rtcm_MT1019_rate_ms != 0) // allows deactivating messages by setting rate = 0 + { + for (const auto& gps_eph_iter : d_pvt_solver->gps_ephemeris_map) + { + d_rtcm_printer->Print_Rtcm_MT1019(gps_eph_iter.second); + } + } + if (d_rtcm_MSM_rate_ms != 0) + { + auto gps_eph_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); + auto gps_cnav_eph_iter = d_pvt_solver->gps_cnav_ephemeris_map.cbegin(); + if ((gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) and (gps_cnav_eph_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend())) + { + d_rtcm_printer->Print_Rtcm_MSM(7, gps_eph_iter->second, gps_cnav_eph_iter->second, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + } + b_rtcm_writing_started = true; + break; + case 8: // L1+L5 + if (d_rtcm_MT1019_rate_ms != 0) // allows deactivating messages by setting rate = 0 + { + for (const auto& gps_eph_iter : d_pvt_solver->gps_ephemeris_map) + { + d_rtcm_printer->Print_Rtcm_MT1019(gps_eph_iter.second); + } + } + if (d_rtcm_MSM_rate_ms != 0) + { + auto gps_eph_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); + auto gps_cnav_eph_iter = d_pvt_solver->gps_cnav_ephemeris_map.cbegin(); + if ((gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) and (gps_cnav_eph_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend())) + { + d_rtcm_printer->Print_Rtcm_MSM(7, gps_eph_iter->second, gps_cnav_eph_iter->second, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + } + b_rtcm_writing_started = true; + break; + case 9: // GPS L1 C/A + Galileo E1B + if (d_rtcm_MT1019_rate_ms != 0) // allows deactivating messages by setting rate = 0 + { + for (const auto& gps_eph_iter : d_pvt_solver->gps_ephemeris_map) + { + d_rtcm_printer->Print_Rtcm_MT1019(gps_eph_iter.second); + } + } + if (d_rtcm_MT1045_rate_ms != 0) + { + for (const auto& gal_eph_iter : d_pvt_solver->galileo_ephemeris_map) + { + d_rtcm_printer->Print_Rtcm_MT1045(gal_eph_iter.second); + } + } + if (d_rtcm_MSM_rate_ms != 0) + { + std::map::const_iterator gnss_observables_iter; + auto gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); + auto gps_eph_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); + int gps_channel = 0; + int gal_channel = 0; + for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) + { + std::string system(&gnss_observables_iter->second.System, 1); + if (gps_channel == 0) + { + if (system == "G") + { + // This is a channel with valid GPS signal + gps_eph_iter = d_pvt_solver->gps_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) + { + gps_channel = 1; + } + } + } + if (gal_channel == 0) + { + if (system == "E") + { + gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + gal_channel = 1; + } + } + } + } + if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, gps_eph_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_eph_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + } + b_rtcm_writing_started = true; + break; - if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend() and (d_rtcm_MT1097_rate_ms != 0)) + case 13: // L5+E5a + if (d_rtcm_MT1045_rate_ms != 0) { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_eph_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); - } - if (gps_cnav_eph_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend() and (d_rtcm_MT1077_rate_ms != 0)) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, gps_cnav_eph_iter->second, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); - } - } - break; - case 14: - case 15: - if (flag_write_RTCM_1045_output == true) - { - for (const auto& gal_eph_iter : d_pvt_solver->galileo_ephemeris_map) - { - d_rtcm_printer->Print_Rtcm_MT1045(gal_eph_iter.second); - } - } - if (flag_write_RTCM_MSM_output == true) - { - auto gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); - if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_eph_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); - } - } - break; - case 23: - case 24: - case 25: - if (flag_write_RTCM_1020_output == true) - { - for (auto glonass_gnav_ephemeris_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend(); glonass_gnav_ephemeris_iter++) - { - d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_ephemeris_iter->second, d_pvt_solver->glonass_gnav_utc_model); - } - } - if (flag_write_RTCM_MSM_output == true) - { - auto glo_gnav_ephemeris_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); - if (glo_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glo_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); - } - } - b_rtcm_writing_started = true; - break; - case 26: // GPS L1 C/A + GLONASS L1 C/A - if (flag_write_RTCM_1019_output == true) - { - for (const auto& gps_eph_iter : d_pvt_solver->gps_ephemeris_map) - { - d_rtcm_printer->Print_Rtcm_MT1019(gps_eph_iter.second); - } - } - if (flag_write_RTCM_1020_output == true) - { - for (auto glonass_gnav_ephemeris_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend(); glonass_gnav_ephemeris_iter++) - { - d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_ephemeris_iter->second, d_pvt_solver->glonass_gnav_utc_model); - } - } - if (flag_write_RTCM_MSM_output == true) - { - std::map::const_iterator gnss_observables_iter; - auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); - auto gps_eph_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); - int gps_channel = 0; - int glo_channel = 0; - for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) - { - std::string system(&gnss_observables_iter->second.System, 1); - if (gps_channel == 0) + for (const auto& gal_eph_iter : d_pvt_solver->galileo_ephemeris_map) { - if (system == "G") + d_rtcm_printer->Print_Rtcm_MT1045(gal_eph_iter.second); + } + } + if (d_rtcm_MSM_rate_ms != 0) + { + std::map::const_iterator gnss_observables_iter; + auto gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); + int gal_channel = 0; + for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) + { + std::string system(&gnss_observables_iter->second.System, 1); + if (gal_channel == 0) { - // This is a channel with valid GPS signal - gps_eph_iter = d_pvt_solver->gps_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) + if (system == "E") { - gps_channel = 1; + gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + gal_channel = 1; + } } } } - if (glo_channel == 0) - { - if (system == "R") - { - glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) - { - glo_channel = 1; - } - } - } - } - if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glonass_gnav_eph_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); - } - if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, gps_eph_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); - } - } - break; - case 27: // GLONASS L1 C/A + Galileo E1B - if (flag_write_RTCM_1020_output == true) - { - for (auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend(); glonass_gnav_eph_iter++) - { - d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_eph_iter->second, d_pvt_solver->glonass_gnav_utc_model); - } - } - if (flag_write_RTCM_1045_output == true) - { - for (const auto& gal_eph_iter : d_pvt_solver->galileo_ephemeris_map) - { - d_rtcm_printer->Print_Rtcm_MT1045(gal_eph_iter.second); - } - } - if (flag_write_RTCM_MSM_output == true) - { - std::map::const_iterator gnss_observables_iter; - auto gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); - auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); - int gal_channel = 0; - int glo_channel = 0; - for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) - { - std::string system(&gnss_observables_iter->second.System, 1); - if (gal_channel == 0) + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend() and (d_rtcm_MT1097_rate_ms != 0)) { - if (system == "E") + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_eph_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + } + b_rtcm_writing_started = true; + break; + case 14: + case 15: + if (d_rtcm_MT1045_rate_ms != 0) // allows deactivating messages by setting rate = 0 + { + for (const auto& gal_eph_iter : d_pvt_solver->galileo_ephemeris_map) + { + d_rtcm_printer->Print_Rtcm_MT1045(gal_eph_iter.second); + } + } + if (d_rtcm_MSM_rate_ms != 0) + { + auto gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_eph_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + } + b_rtcm_writing_started = true; + break; + case 23: + case 24: + case 25: + if (d_rtcm_MT1020_rate_ms != 0) // allows deactivating messages by setting rate = 0 + { + for (auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend(); glonass_gnav_eph_iter++) + { + d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_eph_iter->second, d_pvt_solver->glonass_gnav_utc_model); + } + } + if (d_rtcm_MSM_rate_ms != 0) + { + auto glo_gnav_ephemeris_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); + if (glo_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glo_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + } + b_rtcm_writing_started = true; + break; + case 26: // GPS L1 C/A + GLONASS L1 C/A + if (d_rtcm_MT1019_rate_ms != 0) // allows deactivating messages by setting rate = 0 + { + for (const auto& gps_eph_iter : d_pvt_solver->gps_ephemeris_map) + { + d_rtcm_printer->Print_Rtcm_MT1019(gps_eph_iter.second); + } + } + if (d_rtcm_MT1020_rate_ms != 0) // allows deactivating messages by setting rate = 0 + { + for (auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend(); glonass_gnav_eph_iter++) + { + d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_eph_iter->second, d_pvt_solver->glonass_gnav_utc_model); + } + } + if (d_rtcm_MSM_rate_ms != 0) + { + std::map::const_iterator gnss_observables_iter; + auto gps_eph_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); + auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); + int gps_channel = 0; + int glo_channel = 0; + for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) + { + std::string system(&gnss_observables_iter->second.System, 1); + if (gps_channel == 0) { - // This is a channel with valid GPS signal - gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + if (system == "G") { - gal_channel = 1; + // This is a channel with valid GPS signal + gps_eph_iter = d_pvt_solver->gps_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) + { + gps_channel = 1; + } + } + } + if (glo_channel == 0) + { + if (system == "R") + { + glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) + { + glo_channel = 1; + } } } } - if (glo_channel == 0) + if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) { - if (system == "R") + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glonass_gnav_eph_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, gps_eph_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + } + b_rtcm_writing_started = true; + break; + case 27: // GLONASS L1 C/A + Galileo E1B + if (d_rtcm_MT1020_rate_ms != 0) // allows deactivating messages by setting rate = 0 + { + for (auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend(); glonass_gnav_eph_iter++) + { + d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_eph_iter->second, d_pvt_solver->glonass_gnav_utc_model); + } + } + if (d_rtcm_MT1045_rate_ms != 0) // allows deactivating messages by setting rate = 0 + { + for (const auto& gal_eph_iter : d_pvt_solver->galileo_ephemeris_map) + { + d_rtcm_printer->Print_Rtcm_MT1045(gal_eph_iter.second); + } + } + if (d_rtcm_MSM_rate_ms != 0) + { + int gal_channel = 0; + int glo_channel = 0; + std::map::const_iterator gnss_observables_iter; + auto gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); + auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); + for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) + { + std::string system(&gnss_observables_iter->second.System, 1); + if (gal_channel == 0) { - glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) + if (system == "E") { - glo_channel = 1; + // This is a channel with valid GPS signal + gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + gal_channel = 1; + } + } + } + if (glo_channel == 0) + { + if (system == "R") + { + glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) + { + glo_channel = 1; + } } } } - } - if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_eph_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); - } - if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glonass_gnav_eph_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); - } - } - break; - case 29: // GPS L1 C/A + GLONASS L2 C/A - if (flag_write_RTCM_1019_output == true) - { - for (const auto& gps_eph_iter : d_pvt_solver->gps_ephemeris_map) - { - d_rtcm_printer->Print_Rtcm_MT1019(gps_eph_iter.second); - } - } - if (flag_write_RTCM_1020_output == true) - { - for (auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend(); glonass_gnav_eph_iter++) - { - d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_eph_iter->second, d_pvt_solver->glonass_gnav_utc_model); - } - } - if (flag_write_RTCM_MSM_output == true) - { - std::map::const_iterator gnss_observables_iter; - auto gps_eph_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); - auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); - int gps_channel = 0; - int glo_channel = 0; - for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) - { - std::string system(&gnss_observables_iter->second.System, 1); - if (gps_channel == 0) + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) { - if (system == "G") + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_eph_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glonass_gnav_eph_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + } + b_rtcm_writing_started = true; + break; + case 29: // GPS L1 C/A + GLONASS L2 C/A + if (d_rtcm_MT1019_rate_ms != 0) // allows deactivating messages by setting rate = 0 + { + for (const auto& gps_eph_iter : d_pvt_solver->gps_ephemeris_map) + { + d_rtcm_printer->Print_Rtcm_MT1019(gps_eph_iter.second); + } + } + if (d_rtcm_MT1020_rate_ms != 0) // allows deactivating messages by setting rate = 0 + { + for (auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend(); glonass_gnav_eph_iter++) + { + d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_eph_iter->second, d_pvt_solver->glonass_gnav_utc_model); + } + } + if (d_rtcm_MSM_rate_ms != 0) + { + auto gps_eph_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); + auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); + std::map::const_iterator gnss_observables_iter; + int gps_channel = 0; + int glo_channel = 0; + for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) + { + std::string system(&gnss_observables_iter->second.System, 1); + if (gps_channel == 0) { - // This is a channel with valid GPS signal - gps_eph_iter = d_pvt_solver->gps_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) + if (system == "G") { - gps_channel = 1; + // This is a channel with valid GPS signal + gps_eph_iter = d_pvt_solver->gps_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) + { + gps_channel = 1; + } + } + } + if (glo_channel == 0) + { + if (system == "R") + { + glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) + { + glo_channel = 1; + } } } } - if (glo_channel == 0) + if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) { - if (system == "R") + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glonass_gnav_eph_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + + if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, gps_eph_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + } + b_rtcm_writing_started = true; + break; + case 30: // GLONASS L2 C/A + Galileo E1B + if (d_rtcm_MT1020_rate_ms != 0) // allows deactivating messages by setting rate = 0 + { + for (auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend(); glonass_gnav_eph_iter++) + { + d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_eph_iter->second, d_pvt_solver->glonass_gnav_utc_model); + } + } + if (d_rtcm_MT1045_rate_ms != 0) // allows deactivating messages by setting rate = 0 + { + for (const auto& gal_eph_iter : d_pvt_solver->galileo_ephemeris_map) + { + d_rtcm_printer->Print_Rtcm_MT1045(gal_eph_iter.second); + } + } + if (d_rtcm_MSM_rate_ms != 0) + { + int gal_channel = 0; + int glo_channel = 0; + std::map::const_iterator gnss_observables_iter; + auto gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); + auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); + for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) + { + std::string system(&gnss_observables_iter->second.System, 1); + if (gal_channel == 0) { - glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) + if (system == "E") { - glo_channel = 1; + // This is a channel with valid GPS signal + gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + gal_channel = 1; + } + } + } + if (glo_channel == 0) + { + if (system == "R") + { + glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) + { + glo_channel = 1; + } } } } - } - if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glonass_gnav_eph_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); - } - if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, gps_eph_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); - } - } - break; - case 30: // GLONASS L2 C/A + Galileo E1B - if (flag_write_RTCM_1020_output == true) - { - for (auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend(); glonass_gnav_eph_iter++) - { - d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_eph_iter->second, d_pvt_solver->glonass_gnav_utc_model); - } - } - if (flag_write_RTCM_1045_output == true) - { - for (const auto& gal_eph_iter : d_pvt_solver->galileo_ephemeris_map) - { - d_rtcm_printer->Print_Rtcm_MT1045(gal_eph_iter.second); - } - } - if (flag_write_RTCM_MSM_output == true) - { - std::map::const_iterator gnss_observables_iter; - auto gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); - auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); - int gal_channel = 0; - int glo_channel = 0; - for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) - { - std::string system(&gnss_observables_iter->second.System, 1); - if (gal_channel == 0) + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) { - if (system == "E") + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_eph_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glonass_gnav_eph_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + } + b_rtcm_writing_started = true; + break; + case 32: // L1+E1+L5+E5a + if (d_rtcm_MT1019_rate_ms != 0) // allows deactivating messages by setting rate = 0 + { + for (const auto& gps_eph_iter : d_pvt_solver->gps_ephemeris_map) + { + d_rtcm_printer->Print_Rtcm_MT1019(gps_eph_iter.second); + } + } + if (d_rtcm_MT1045_rate_ms != 0) // allows deactivating messages by setting rate = 0 + { + for (const auto& gal_eph_iter : d_pvt_solver->galileo_ephemeris_map) + { + d_rtcm_printer->Print_Rtcm_MT1045(gal_eph_iter.second); + } + } + if (d_rtcm_MSM_rate_ms != 0) + { + std::map::const_iterator gnss_observables_iter; + auto gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); + auto gps_eph_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); + int gps_channel = 0; + int gal_channel = 0; + for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) + { + std::string system(&gnss_observables_iter->second.System, 1); + if (gps_channel == 0) { - // This is a channel with valid GPS signal - gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + if (system == "G") { - gal_channel = 1; + // This is a channel with valid GPS signal + gps_eph_iter = d_pvt_solver->gps_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) + { + gps_channel = 1; + } + } + } + if (gal_channel == 0) + { + if (system == "E") + { + gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + gal_channel = 1; + } } } } - if (glo_channel == 0) + if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) { - if (system == "R") - { - glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) - { - glo_channel = 1; - } - } + d_rtcm_printer->Print_Rtcm_MSM(7, gps_eph_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); + } + if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_eph_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); } } - if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_eph_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); - } - if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glonass_gnav_eph_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); - } + b_rtcm_writing_started = true; + break; + default: + break; } - break; - case 32: // L1+E1+L5+E5a - if (flag_write_RTCM_1019_output == true) - { - for (const auto& gps_eph_iter : d_pvt_solver->gps_ephemeris_map) - { - d_rtcm_printer->Print_Rtcm_MT1019(gps_eph_iter.second); - } - } - if (flag_write_RTCM_1045_output == true) - { - for (const auto& gal_eph_iter : d_pvt_solver->galileo_ephemeris_map) - { - d_rtcm_printer->Print_Rtcm_MT1045(gal_eph_iter.second); - } - } - if (flag_write_RTCM_MSM_output == true) - { - std::map::const_iterator gnss_observables_iter; - auto gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); - auto gps_eph_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); - int gal_channel = 0; - int gps_channel = 0; - for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) - { - std::string system(&gnss_observables_iter->second.System, 1); - if (gal_channel == 0) - { - if (system == "E") - { - // This is a channel with valid GPS signal - gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) - { - gal_channel = 1; - } - } - } - if (gps_channel == 0) - { - if (system == "G") - { - gps_eph_iter = d_pvt_solver->gps_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) - { - gps_channel = 1; - } - } - } - } - if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, gps_eph_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); - } - if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_eph_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); - } - } - break; - default: - break; } } - - if (!b_rtcm_writing_started and b_rtcm_enabled) // the first time + catch (const boost::exception& ex) { - switch (type_of_rx) - { - case 1: // GPS L1 C/A - if (d_rtcm_MT1019_rate_ms != 0) // allows deactivating messages by setting rate = 0 - { - for (const auto& gps_eph_iter : d_pvt_solver->gps_ephemeris_map) - { - d_rtcm_printer->Print_Rtcm_MT1019(gps_eph_iter.second); - } - } - if (d_rtcm_MSM_rate_ms != 0) // allows deactivating messages by setting rate = 0 - { - auto gps_eph_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); - - if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, gps_eph_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); - } - } - b_rtcm_writing_started = true; - break; - case 4: - case 5: - case 6: - if (d_rtcm_MT1045_rate_ms != 0) // allows deactivating messages by setting rate = 0 - { - for (const auto& gal_eph_iter : d_pvt_solver->galileo_ephemeris_map) - { - d_rtcm_printer->Print_Rtcm_MT1045(gal_eph_iter.second); - } - } - if (d_rtcm_MSM_rate_ms != 0) - { - auto gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); - if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_eph_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); - } - } - b_rtcm_writing_started = true; - break; - case 7: // GPS L1 C/A + GPS L2C - if (d_rtcm_MT1019_rate_ms != 0) // allows deactivating messages by setting rate = 0 - { - for (const auto& gps_eph_iter : d_pvt_solver->gps_ephemeris_map) - { - d_rtcm_printer->Print_Rtcm_MT1019(gps_eph_iter.second); - } - } - if (d_rtcm_MSM_rate_ms != 0) - { - auto gps_eph_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); - auto gps_cnav_eph_iter = d_pvt_solver->gps_cnav_ephemeris_map.cbegin(); - if ((gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) and (gps_cnav_eph_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend())) - { - d_rtcm_printer->Print_Rtcm_MSM(7, gps_eph_iter->second, gps_cnav_eph_iter->second, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); - } - } - b_rtcm_writing_started = true; - break; - case 8: // L1+L5 - if (d_rtcm_MT1019_rate_ms != 0) // allows deactivating messages by setting rate = 0 - { - for (const auto& gps_eph_iter : d_pvt_solver->gps_ephemeris_map) - { - d_rtcm_printer->Print_Rtcm_MT1019(gps_eph_iter.second); - } - } - if (d_rtcm_MSM_rate_ms != 0) - { - auto gps_eph_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); - auto gps_cnav_eph_iter = d_pvt_solver->gps_cnav_ephemeris_map.cbegin(); - if ((gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) and (gps_cnav_eph_iter != d_pvt_solver->gps_cnav_ephemeris_map.cend())) - { - d_rtcm_printer->Print_Rtcm_MSM(7, gps_eph_iter->second, gps_cnav_eph_iter->second, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); - } - } - b_rtcm_writing_started = true; - break; - case 9: // GPS L1 C/A + Galileo E1B - if (d_rtcm_MT1019_rate_ms != 0) // allows deactivating messages by setting rate = 0 - { - for (const auto& gps_eph_iter : d_pvt_solver->gps_ephemeris_map) - { - d_rtcm_printer->Print_Rtcm_MT1019(gps_eph_iter.second); - } - } - if (d_rtcm_MT1045_rate_ms != 0) - { - for (const auto& gal_eph_iter : d_pvt_solver->galileo_ephemeris_map) - { - d_rtcm_printer->Print_Rtcm_MT1045(gal_eph_iter.second); - } - } - if (d_rtcm_MSM_rate_ms != 0) - { - std::map::const_iterator gnss_observables_iter; - auto gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); - auto gps_eph_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); - int gps_channel = 0; - int gal_channel = 0; - for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) - { - std::string system(&gnss_observables_iter->second.System, 1); - if (gps_channel == 0) - { - if (system == "G") - { - // This is a channel with valid GPS signal - gps_eph_iter = d_pvt_solver->gps_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) - { - gps_channel = 1; - } - } - } - if (gal_channel == 0) - { - if (system == "E") - { - gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) - { - gal_channel = 1; - } - } - } - } - if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, gps_eph_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); - } - if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_eph_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); - } - } - b_rtcm_writing_started = true; - break; - - case 13: // L5+E5a - if (d_rtcm_MT1045_rate_ms != 0) - { - for (const auto& gal_eph_iter : d_pvt_solver->galileo_ephemeris_map) - { - d_rtcm_printer->Print_Rtcm_MT1045(gal_eph_iter.second); - } - } - if (d_rtcm_MSM_rate_ms != 0) - { - std::map::const_iterator gnss_observables_iter; - auto gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); - int gal_channel = 0; - for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) - { - std::string system(&gnss_observables_iter->second.System, 1); - if (gal_channel == 0) - { - if (system == "E") - { - gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) - { - gal_channel = 1; - } - } - } - } - - if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend() and (d_rtcm_MT1097_rate_ms != 0)) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_eph_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); - } - } - b_rtcm_writing_started = true; - break; - case 14: - case 15: - if (d_rtcm_MT1045_rate_ms != 0) // allows deactivating messages by setting rate = 0 - { - for (const auto& gal_eph_iter : d_pvt_solver->galileo_ephemeris_map) - { - d_rtcm_printer->Print_Rtcm_MT1045(gal_eph_iter.second); - } - } - if (d_rtcm_MSM_rate_ms != 0) - { - auto gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); - if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_eph_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); - } - } - b_rtcm_writing_started = true; - break; - case 23: - case 24: - case 25: - if (d_rtcm_MT1020_rate_ms != 0) // allows deactivating messages by setting rate = 0 - { - for (auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend(); glonass_gnav_eph_iter++) - { - d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_eph_iter->second, d_pvt_solver->glonass_gnav_utc_model); - } - } - if (d_rtcm_MSM_rate_ms != 0) - { - auto glo_gnav_ephemeris_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); - if (glo_gnav_ephemeris_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glo_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); - } - } - b_rtcm_writing_started = true; - break; - case 26: // GPS L1 C/A + GLONASS L1 C/A - if (d_rtcm_MT1019_rate_ms != 0) // allows deactivating messages by setting rate = 0 - { - for (const auto& gps_eph_iter : d_pvt_solver->gps_ephemeris_map) - { - d_rtcm_printer->Print_Rtcm_MT1019(gps_eph_iter.second); - } - } - if (d_rtcm_MT1020_rate_ms != 0) // allows deactivating messages by setting rate = 0 - { - for (auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend(); glonass_gnav_eph_iter++) - { - d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_eph_iter->second, d_pvt_solver->glonass_gnav_utc_model); - } - } - if (d_rtcm_MSM_rate_ms != 0) - { - std::map::const_iterator gnss_observables_iter; - auto gps_eph_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); - auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); - int gps_channel = 0; - int glo_channel = 0; - for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) - { - std::string system(&gnss_observables_iter->second.System, 1); - if (gps_channel == 0) - { - if (system == "G") - { - // This is a channel with valid GPS signal - gps_eph_iter = d_pvt_solver->gps_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) - { - gps_channel = 1; - } - } - } - if (glo_channel == 0) - { - if (system == "R") - { - glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) - { - glo_channel = 1; - } - } - } - } - if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glonass_gnav_eph_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); - } - if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, gps_eph_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); - } - } - b_rtcm_writing_started = true; - break; - case 27: // GLONASS L1 C/A + Galileo E1B - if (d_rtcm_MT1020_rate_ms != 0) // allows deactivating messages by setting rate = 0 - { - for (auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend(); glonass_gnav_eph_iter++) - { - d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_eph_iter->second, d_pvt_solver->glonass_gnav_utc_model); - } - } - if (d_rtcm_MT1045_rate_ms != 0) // allows deactivating messages by setting rate = 0 - { - for (const auto& gal_eph_iter : d_pvt_solver->galileo_ephemeris_map) - { - d_rtcm_printer->Print_Rtcm_MT1045(gal_eph_iter.second); - } - } - if (d_rtcm_MSM_rate_ms != 0) - { - int gal_channel = 0; - int glo_channel = 0; - std::map::const_iterator gnss_observables_iter; - auto gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); - auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); - for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) - { - std::string system(&gnss_observables_iter->second.System, 1); - if (gal_channel == 0) - { - if (system == "E") - { - // This is a channel with valid GPS signal - gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) - { - gal_channel = 1; - } - } - } - if (glo_channel == 0) - { - if (system == "R") - { - glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) - { - glo_channel = 1; - } - } - } - } - if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_eph_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); - } - if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glonass_gnav_eph_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); - } - } - b_rtcm_writing_started = true; - break; - case 29: // GPS L1 C/A + GLONASS L2 C/A - if (d_rtcm_MT1019_rate_ms != 0) // allows deactivating messages by setting rate = 0 - { - for (const auto& gps_eph_iter : d_pvt_solver->gps_ephemeris_map) - { - d_rtcm_printer->Print_Rtcm_MT1019(gps_eph_iter.second); - } - } - if (d_rtcm_MT1020_rate_ms != 0) // allows deactivating messages by setting rate = 0 - { - for (auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend(); glonass_gnav_eph_iter++) - { - d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_eph_iter->second, d_pvt_solver->glonass_gnav_utc_model); - } - } - if (d_rtcm_MSM_rate_ms != 0) - { - auto gps_eph_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); - auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); - std::map::const_iterator gnss_observables_iter; - int gps_channel = 0; - int glo_channel = 0; - for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) - { - std::string system(&gnss_observables_iter->second.System, 1); - if (gps_channel == 0) - { - if (system == "G") - { - // This is a channel with valid GPS signal - gps_eph_iter = d_pvt_solver->gps_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) - { - gps_channel = 1; - } - } - } - if (glo_channel == 0) - { - if (system == "R") - { - glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) - { - glo_channel = 1; - } - } - } - } - if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glonass_gnav_eph_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); - } - - if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, gps_eph_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); - } - } - b_rtcm_writing_started = true; - break; - case 30: // GLONASS L2 C/A + Galileo E1B - if (d_rtcm_MT1020_rate_ms != 0) // allows deactivating messages by setting rate = 0 - { - for (auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend(); glonass_gnav_eph_iter++) - { - d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_eph_iter->second, d_pvt_solver->glonass_gnav_utc_model); - } - } - if (d_rtcm_MT1045_rate_ms != 0) // allows deactivating messages by setting rate = 0 - { - for (const auto& gal_eph_iter : d_pvt_solver->galileo_ephemeris_map) - { - d_rtcm_printer->Print_Rtcm_MT1045(gal_eph_iter.second); - } - } - if (d_rtcm_MSM_rate_ms != 0) - { - int gal_channel = 0; - int glo_channel = 0; - std::map::const_iterator gnss_observables_iter; - auto gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); - auto glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.cbegin(); - for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) - { - std::string system(&gnss_observables_iter->second.System, 1); - if (gal_channel == 0) - { - if (system == "E") - { - // This is a channel with valid GPS signal - gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) - { - gal_channel = 1; - } - } - } - if (glo_channel == 0) - { - if (system == "R") - { - glonass_gnav_eph_iter = d_pvt_solver->glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) - { - glo_channel = 1; - } - } - } - } - if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_eph_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); - } - if (glonass_gnav_eph_iter != d_pvt_solver->glonass_gnav_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glonass_gnav_eph_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); - } - } - b_rtcm_writing_started = true; - break; - case 32: // L1+E1+L5+E5a - if (d_rtcm_MT1019_rate_ms != 0) // allows deactivating messages by setting rate = 0 - { - for (const auto& gps_eph_iter : d_pvt_solver->gps_ephemeris_map) - { - d_rtcm_printer->Print_Rtcm_MT1019(gps_eph_iter.second); - } - } - if (d_rtcm_MT1045_rate_ms != 0) // allows deactivating messages by setting rate = 0 - { - for (const auto& gal_eph_iter : d_pvt_solver->galileo_ephemeris_map) - { - d_rtcm_printer->Print_Rtcm_MT1045(gal_eph_iter.second); - } - } - if (d_rtcm_MSM_rate_ms != 0) - { - std::map::const_iterator gnss_observables_iter; - auto gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.cbegin(); - auto gps_eph_iter = d_pvt_solver->gps_ephemeris_map.cbegin(); - int gps_channel = 0; - int gal_channel = 0; - for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) - { - std::string system(&gnss_observables_iter->second.System, 1); - if (gps_channel == 0) - { - if (system == "G") - { - // This is a channel with valid GPS signal - gps_eph_iter = d_pvt_solver->gps_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) - { - gps_channel = 1; - } - } - } - if (gal_channel == 0) - { - if (system == "E") - { - gal_eph_iter = d_pvt_solver->galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) - { - gal_channel = 1; - } - } - } - } - if (gps_eph_iter != d_pvt_solver->gps_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, gps_eph_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); - } - if (gal_eph_iter != d_pvt_solver->galileo_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_eph_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, false, false); - } - } - b_rtcm_writing_started = true; - break; - default: - break; - } + std::cout << "RTCM boost exception: " << boost::diagnostic_information(ex) << std::endl; + LOG(ERROR) << "RTCM boost exception: " << boost::diagnostic_information(ex); + } + catch (const std::exception& ex) + { + std::cout << "RTCM std exception: " << ex.what() << std::endl; + LOG(ERROR) << "RTCM std exception: " << ex.what(); } - } - catch (const boost::exception& ex) - { - std::cout << "RTCM boost exception: " << boost::diagnostic_information(ex) << std::endl; - LOG(ERROR) << "RTCM boost exception: " << boost::diagnostic_information(ex); - } - catch (const std::exception& ex) - { - std::cout << "RTCM std exception: " << ex.what() << std::endl; - LOG(ERROR) << "RTCM std exception: " << ex.what(); } } } diff --git a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.cc b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.cc index 822d4b642..0945bd1e6 100644 --- a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.cc +++ b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.cc @@ -52,6 +52,33 @@ hybrid_observables_gs_sptr hybrid_observables_gs_make(unsigned int nchannels_in, return hybrid_observables_gs_sptr(new hybrid_observables_gs(nchannels_in, nchannels_out, dump, dump_mat, std::move(dump_filename))); } +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)) + { + double new_rx_clock_offset_s; + new_rx_clock_offset_s = boost::any_cast(pmt::any_ref(msg)); + T_rx_offset_ms = new_rx_clock_offset_s * 1000.0; + T_rx_TOW_ms = T_rx_TOW_ms - static_cast(round(T_rx_offset_ms)); + T_rx_remnant_to_20ms = (T_rx_TOW_ms % 20); + //d_Rx_clock_buffer.clear(); // Clear all the elements in the buffer + for (uint32_t n = 0; n < d_nchannels_out; n++) + { + d_gnss_synchro_history->clear(n); + } + + LOG(INFO) << "Corrected new RX Time offset: " << T_rx_offset_ms << "[ms]"; + } + } + catch (boost::bad_any_cast &e) + { + LOG(WARNING) << "msg_handler_pvt_to_observables Bad any cast!"; + } +} + hybrid_observables_gs::hybrid_observables_gs(uint32_t nchannels_in, uint32_t nchannels_out, @@ -61,12 +88,16 @@ hybrid_observables_gs::hybrid_observables_gs(uint32_t nchannels_in, gr::io_signature::make(nchannels_in, nchannels_in, sizeof(Gnss_Synchro)), gr::io_signature::make(nchannels_out, nchannels_out, sizeof(Gnss_Synchro))) { + // PVT input message port + this->message_port_register_in(pmt::mp("pvt_to_observables")); + this->set_msg_handler(pmt::mp("pvt_to_observables"), boost::bind(&hybrid_observables_gs::msg_handler_pvt_to_observables, this, _1)); + d_dump = dump; d_dump_mat = dump_mat and d_dump; d_dump_filename = std::move(dump_filename); d_nchannels_out = nchannels_out; d_nchannels_in = nchannels_in; - T_rx_clock_step_samples = 0U; + T_rx_offset_ms = 0; d_gnss_synchro_history = new Gnss_circular_deque(500, d_nchannels_out); // ############# ENABLE DATA FILE LOG ################# @@ -114,6 +145,7 @@ hybrid_observables_gs::hybrid_observables_gs(uint32_t nchannels_in, } } T_rx_TOW_ms = 0U; + T_rx_remnant_to_20ms = 0; T_rx_step_ms = 20; //read from config at the adapter GNSS-SDR.observable_interval_ms!! T_rx_TOW_set = false; @@ -410,6 +442,17 @@ bool hybrid_observables_gs::interp_trk_obs(Gnss_Synchro &interpolated_obs, const interpolated_obs.Carrier_Doppler_hz = d_gnss_synchro_history->at(ch, t1_idx).Carrier_Doppler_hz + (d_gnss_synchro_history->at(ch, t2_idx).Carrier_Doppler_hz - d_gnss_synchro_history->at(ch, t1_idx).Carrier_Doppler_hz) * time_factor; // TOW INTERPOLATION interpolated_obs.interp_TOW_ms = static_cast(d_gnss_synchro_history->at(ch, t1_idx).TOW_at_current_symbol_ms) + (static_cast(d_gnss_synchro_history->at(ch, t2_idx).TOW_at_current_symbol_ms) - static_cast(d_gnss_synchro_history->at(ch, t1_idx).TOW_at_current_symbol_ms)) * time_factor; + + + // LOG(INFO) << "Channel " << ch << " int idx: " << t1_idx << " TOW Int: " << interpolated_obs.interp_TOW_ms + // << " TOW p1 : " << d_gnss_synchro_history->at(ch, t1_idx).TOW_at_current_symbol_ms + // << " TOW p2: " + // << d_gnss_synchro_history->at(ch, t2_idx).TOW_at_current_symbol_ms + // << " t2-t1: " + // << d_gnss_synchro_history->at(ch, t2_idx).RX_time - d_gnss_synchro_history->at(ch, t1_idx).RX_time + // << " trx - t1: " + // << T_rx_s - d_gnss_synchro_history->at(ch, t1_idx).RX_time; + // // std::cout << "Rx samplestamp: " << T_rx_s << " Channel " << ch << " interp buff idx " << nearest_element // << " ,diff: " << old_abs_diff << " samples (" << static_cast(old_abs_diff) / static_cast(d_gnss_synchro_history->at(ch, nearest_element).fs) << " s)\n"; @@ -459,6 +502,7 @@ void hybrid_observables_gs::update_TOW(const std::vector &data) } } T_rx_TOW_ms = TOW_ref - (TOW_ref % 20); + T_rx_remnant_to_20ms = 0; } else { @@ -477,13 +521,14 @@ void hybrid_observables_gs::compute_pranges(std::vector &data) // std::cout.precision(17); // std::cout << " T_rx_TOW_ms: " << static_cast(T_rx_TOW_ms) << std::endl; std::vector::iterator it; + double current_T_rx_TOW_s = (static_cast(T_rx_TOW_ms - T_rx_remnant_to_20ms) + GPS_STARTOFFSET_MS) / 1000.0; for (it = data.begin(); it != data.end(); it++) { if (it->Flag_valid_word) { - double traveltime_s = (static_cast(T_rx_TOW_ms) - it->interp_TOW_ms + GPS_STARTOFFSET_MS) / 1000.0; - //todo: check what happens during the week rollover (TOW rollover at 604800000s) - it->RX_time = (static_cast(T_rx_TOW_ms) + GPS_STARTOFFSET_MS) / 1000.0; + double traveltime_s = current_T_rx_TOW_s - it->interp_TOW_ms / 1000.0; + //todo: check what happens during the week rollover (TOW rollover at 604800000ms) + it->RX_time = current_T_rx_TOW_s; it->Pseudorange_m = traveltime_s * SPEED_OF_LIGHT; it->Flag_valid_pseudorange = true; // debug code @@ -491,17 +536,11 @@ void hybrid_observables_gs::compute_pranges(std::vector &data) // std::cout << "[" << it->Channel_ID << "] interp_TOW_ms: " << it->interp_TOW_ms << std::endl; // std::cout << "[" << it->Channel_ID << "] Diff T_rx_TOW_ms - interp_TOW_ms: " << static_cast(T_rx_TOW_ms) - it->interp_TOW_ms << std::endl; } + else + { + it->RX_time = current_T_rx_TOW_s; + } } - - // for (it = data.begin(); it != data.end(); it++) - // { - // if (it->Flag_valid_word) - // { - // std::cout << "[" << it->Channel_ID << "] Pseudorange_m: " << it->Pseudorange_m << std::endl; - // } - // } - // std::cout << std::endl; - // usleep(1000); } @@ -517,12 +556,6 @@ int hybrid_observables_gs::general_work(int noutput_items __attribute__((unused) if (ninput_items[d_nchannels_in - 1] > 0) { d_Rx_clock_buffer.push_back(in[d_nchannels_in - 1][0].Tracking_sample_counter); - if (T_rx_clock_step_samples == 0) - { - T_rx_clock_step_samples = std::round(static_cast(in[d_nchannels_in - 1][0].fs) * 1e-3); // 1 ms - LOG(INFO) << "Observables clock step samples set to " << T_rx_clock_step_samples; - } - // Consume one item from the clock channel (last of the input channels) consume(d_nchannels_in - 1, 1); } @@ -541,6 +574,7 @@ int hybrid_observables_gs::general_work(int noutput_items __attribute__((unused) if (d_gnss_synchro_history->front(n).PRN != in[n][m].PRN) { d_gnss_synchro_history->clear(n); + // LOG(INFO) << "Channel " << d_gnss_synchro_history->front(n).Channel_ID << " changed satellite to PRN " << in[n][m].PRN; } } d_gnss_synchro_history->push_back(n, in[n][m]); @@ -557,7 +591,9 @@ int hybrid_observables_gs::general_work(int noutput_items __attribute__((unused) for (uint32_t n = 0; n < d_nchannels_out; n++) { Gnss_Synchro interpolated_gnss_synchro{}; - if (!interp_trk_obs(interpolated_gnss_synchro, n, d_Rx_clock_buffer.front())) + + uint32_t T_rx_remnant_to_20ms_samples = T_rx_remnant_to_20ms * in[d_nchannels_in - 1][0].fs / 1000; + if (!interp_trk_obs(interpolated_gnss_synchro, n, d_Rx_clock_buffer.front() - T_rx_remnant_to_20ms_samples)) { // Produce an empty observation interpolated_gnss_synchro = Gnss_Synchro(); @@ -574,9 +610,20 @@ int hybrid_observables_gs::general_work(int noutput_items __attribute__((unused) epoch_data.push_back(interpolated_gnss_synchro); } - if (n_valid > 0) + if (T_rx_TOW_set) { update_TOW(epoch_data); + } + else + { + if (n_valid > 0) + { + update_TOW(epoch_data); + } + } + + if (n_valid > 0) + { compute_pranges(epoch_data); } diff --git a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.h b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.h index 04443ef72..b40beada9 100644 --- a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.h +++ b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.h @@ -68,6 +68,7 @@ private: friend hybrid_observables_gs_sptr hybrid_observables_gs_make(uint32_t nchannels_in, uint32_t nchannels_out, bool dump, bool dump_mat, std::string dump_filename); hybrid_observables_gs(uint32_t nchannels_in, uint32_t nchannels_out, bool dump, bool dump_mat, std::string dump_filename); + void msg_handler_pvt_to_observables(const pmt::pmt_t& msg); bool interpolate_data(Gnss_Synchro& out, const uint32_t& ch, const double& ti); bool interp_trk_obs(Gnss_Synchro& interpolated_obs, const uint32_t& ch, const uint64_t& rx_clock); double compute_T_rx_s(const Gnss_Synchro& a); @@ -79,11 +80,12 @@ private: boost::circular_buffer d_Rx_clock_buffer; //Tracking observable history Gnss_circular_deque* d_gnss_synchro_history; - uint32_t T_rx_clock_step_samples; //rx time follow GPST bool T_rx_TOW_set; uint32_t T_rx_TOW_ms; + uint32_t T_rx_remnant_to_20ms; uint32_t T_rx_step_ms; + double T_rx_offset_ms; bool d_dump; bool d_dump_mat; uint32_t d_nchannels_in; diff --git a/src/algorithms/signal_source/gnuradio_blocks/labsat23_source.cc b/src/algorithms/signal_source/gnuradio_blocks/labsat23_source.cc index fb70c2775..894e30cae 100644 --- a/src/algorithms/signal_source/gnuradio_blocks/labsat23_source.cc +++ b/src/algorithms/signal_source/gnuradio_blocks/labsat23_source.cc @@ -147,24 +147,28 @@ void labsat23_source::decode_samples_one_channel(int16_t input_short, gr_complex // bits per sample, 4 samples per int16 for (int i = 0; i < 4; i++) { - out[i] = gr_complex(0.0, 0.0); + //out[i] = gr_complex(0.0, 0.0); // In-Phase if (bs[15 - 4 * i]) { if (bs[13 - 4 * i]) // 11 { - out[i] += gr_complex(-1, 0); + out[i] = gr_complex(-1, 0); } else // 10 { - out[i] += gr_complex(-2, 0); + out[i] = gr_complex(-2, 0); } } else { if (bs[13 - 4 * i]) // 01 { - out[i] += gr_complex(1, 0); + out[i] = gr_complex(2, 0); + } + else + { + out[i] = gr_complex(1, 0); } } @@ -183,11 +187,15 @@ void labsat23_source::decode_samples_one_channel(int16_t input_short, gr_complex else { if (bs[12 - 4 * i]) // 01 + { + out[i] += gr_complex(0, 2); + } + else { out[i] += gr_complex(0, 1); } } - out[i] += gr_complex(0.5, 0.5); + //out[i] += gr_complex(0.5, 0.5); } break; } @@ -412,6 +420,7 @@ int labsat23_source::general_work(int noutput_items, { case 0: // dual channel 2 bits per complex sample + //todo: implement dual channel reader break; default: // single channel 2 bits per complex sample (1 bit I + 1 bit Q, 8 samples per int16) @@ -473,6 +482,7 @@ int labsat23_source::general_work(int noutput_items, { case 0: // dual channel + //todo: implement dual channel reader break; default: // single channel 4 bits per complex sample (2 bit I + 2 bit Q, 4 samples per int16) diff --git a/src/algorithms/tracking/libs/tracking_2nd_PLL_filter.cc b/src/algorithms/tracking/libs/tracking_2nd_PLL_filter.cc index bf0b0841b..e2da9d943 100644 --- a/src/algorithms/tracking/libs/tracking_2nd_PLL_filter.cc +++ b/src/algorithms/tracking/libs/tracking_2nd_PLL_filter.cc @@ -49,7 +49,7 @@ void Tracking_2nd_PLL_filter::calculate_lopp_coef(float* tau1, float* tau2, floa void Tracking_2nd_PLL_filter::set_PLL_BW(float pll_bw_hz) { - //Calculate filter coefficient values + // Calculate filter coefficient values d_pllnoisebandwidth = pll_bw_hz; calculate_lopp_coef(&d_tau1_carr, &d_tau2_carr, d_pllnoisebandwidth, d_plldampingratio, 0.25); // Calculate filter coefficient values } @@ -64,14 +64,13 @@ void Tracking_2nd_PLL_filter::initialize() /* - * PLL second order FIR filter + * PLL second order IIR filter * Req Input in [Hz/Ti] * The output is in [Hz/s]. */ float Tracking_2nd_PLL_filter::get_carrier_nco(float PLL_discriminator) { float carr_nco = d_old_carr_nco + (d_tau2_carr / d_tau1_carr) * (PLL_discriminator - d_old_carr_error) + (PLL_discriminator + d_old_carr_error) * (d_pdi_carr / (2.0 * d_tau1_carr)); - //carr_nco = d_old_carr_nco + (d_tau2_carr/d_tau1_carr)*(PLL_discriminator - d_old_carr_error) + PLL_discriminator * (d_pdi_carr/d_tau1_carr); d_old_carr_nco = carr_nco; d_old_carr_error = PLL_discriminator; return carr_nco; @@ -80,16 +79,15 @@ float Tracking_2nd_PLL_filter::get_carrier_nco(float PLL_discriminator) Tracking_2nd_PLL_filter::Tracking_2nd_PLL_filter(float pdi_carr) { - //--- PLL variables -------------------------------------------------------- + // PLL variables d_pdi_carr = pdi_carr; // Summation interval for carrier - //d_plldampingratio = 0.65; d_plldampingratio = 0.7; } Tracking_2nd_PLL_filter::Tracking_2nd_PLL_filter() { - //--- PLL variables -------------------------------------------------------- + // PLL variables d_pdi_carr = 0.001; // Summation interval for carrier d_plldampingratio = 0.7; } diff --git a/src/core/receiver/gnss_flowgraph.cc b/src/core/receiver/gnss_flowgraph.cc index 33ae8ca26..4282d26ee 100644 --- a/src/core/receiver/gnss_flowgraph.cc +++ b/src/core/receiver/gnss_flowgraph.cc @@ -677,6 +677,7 @@ void GNSSFlowgraph::connect() top_block_->connect(observables_->get_right_block(), i, pvt_->get_left_block(), i); top_block_->msg_connect(channels_.at(i)->get_right_block(), pmt::mp("telemetry"), pvt_->get_left_block(), pmt::mp("telemetry")); } + top_block_->msg_connect(pvt_->get_left_block(), pmt::mp("pvt_to_observables"), observables_->get_right_block(), pmt::mp("pvt_to_observables")); } catch (const std::exception& e) { @@ -948,6 +949,7 @@ void GNSSFlowgraph::disconnect() } top_block_->msg_disconnect(channels_.at(i)->get_right_block(), pmt::mp("telemetry"), pvt_->get_left_block(), pmt::mp("telemetry")); } + top_block_->msg_disconnect(pvt_->get_left_block(), pmt::mp("pvt_to_observables"), observables_->get_right_block(), pmt::mp("pvt_to_observables")); } catch (const std::exception& e) {