diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc index 2edbd447c..34e72231b 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc @@ -355,8 +355,7 @@ int glonass_l1_ca_telemetry_decoder_cc::general_work (int noutput_items __attrib if (this->d_flag_preamble == true and d_nav.flag_TOW_new == true) //update TOW at the preamble instant { - double dummy_dtow = d_nav.get_TOW() - GLONASS_GNAV_PREAMBLE_DURATION_S; - d_TOW_at_current_symbol = d_nav.gnav_ephemeris.d_TOW - GLONASS_GNAV_PREAMBLE_DURATION_S; + d_TOW_at_current_symbol = floor((d_nav.gnav_ephemeris.d_TOW - GLONASS_GNAV_PREAMBLE_DURATION_S)*1000)/1000; d_nav.flag_TOW_new = false; } @@ -382,7 +381,7 @@ int glonass_l1_ca_telemetry_decoder_cc::general_work (int noutput_items __attrib } current_symbol.PRN = this->d_satellite.get_PRN(); - current_symbol.TOW_at_current_symbol_s = floor(d_TOW_at_current_symbol*1000.0)/1000.0; + current_symbol.TOW_at_current_symbol_s = d_TOW_at_current_symbol; current_symbol.TOW_at_current_symbol_s -=delta_t; //Galileo to GPS TOW if(d_dump == true) diff --git a/src/core/system_parameters/glonass_gnav_ephemeris.h b/src/core/system_parameters/glonass_gnav_ephemeris.h index 929fa7262..5400e890f 100644 --- a/src/core/system_parameters/glonass_gnav_ephemeris.h +++ b/src/core/system_parameters/glonass_gnav_ephemeris.h @@ -99,10 +99,10 @@ public: double d_satClkDrift; //!< GLONASS clock error double d_dtr; //!< relativistic clock correction term double d_iode; //!< Issue of data, ephemeris (Bit 0-6 of tb) - double d_tau_c; - double d_TOW; // tow of the start of frame - double d_WN; // week number of the start of frame - double d_tod; + double d_tau_c; //!< GLONASST 2 UTC correction (todo) may be eliminated + double d_TOW; //!< GLONASST IN GPST seconds of week + double d_WN; //!< GLONASST IN GPST week number of the start of frame + double d_tod; //!< Time of Day since ephemeris where decoded template @@ -161,13 +161,22 @@ public: /*! * \brief Converts from GLONASST to UTC - * \ param [I] - * \ param offset_time Is the start of day offset to compute the time - * \ returns UTC time as a boost::posix_time::ptime object + * \details The function simply adjust for the 6 hrs offset between GLONASST and UTC + * \param[in] offset_time Is the start of day offset + * \param[in] glot2utc_corr Correction from GLONASST to UTC + * \returns UTC time as a boost::posix_time::ptime object */ boost::posix_time::ptime glot_to_utc(const double offset_time, const double glot2utc_corr) const; - + /*! + * \brief Converts from GLONASST to GPST + * \details Converts from GLONASST to GPST in time of week (TOW) and week number (WN) format + * \param[in] tod_offset Is the start of day offset + * \param[in] glot2utc_corr Correction from GLONASST to UTC + * \param[in] glot2gpst_corr Correction from GLONASST to GPST + * \param[out] WN Week Number, not in mod(1024) format + * \param[out] TOW Time of Week in seconds of week + */ void glot_to_gpst(double tod_offset, double glot2utc_corr, double glot2gpst_corr, double * WN, double * TOW) const; /*! diff --git a/src/tests/unit-tests/system-parameters/glonass_gnav_ephemeris_test.cc b/src/tests/unit-tests/system-parameters/glonass_gnav_ephemeris_test.cc index 71aa40ac1..2a4917357 100644 --- a/src/tests/unit-tests/system-parameters/glonass_gnav_ephemeris_test.cc +++ b/src/tests/unit-tests/system-parameters/glonass_gnav_ephemeris_test.cc @@ -64,7 +64,10 @@ TEST(GlonassGnavEphemerisTest, ComputeGlonassTime) ASSERT_TRUE(expected_gtime.seconds() - t.seconds() < FLT_EPSILON ); } -// testing case where calendar +/*! + * \brief Testing conversion from GLONASST to GPST + * \test Tests scenario for N_T when greater than 365 days. Possible values here from 1 to 365*4 + */ TEST(GlonassGnavEphemerisTest, ConvertGlonassT2GpsT1) { Glonass_Gnav_Ephemeris gnav_eph; @@ -85,6 +88,10 @@ TEST(GlonassGnavEphemerisTest, ConvertGlonassT2GpsT1) ASSERT_TRUE(tow - true_week < FLT_EPSILON ); } +/*! + * \brief Testing conversion from GLONASST to GPST + * \test This version tests the conversion for offsets greater than 30 in a leap year + */ TEST(GlonassGnavEphemerisTest, ConvertGlonassT2GpsT2) { Glonass_Gnav_Ephemeris gnav_eph; @@ -105,6 +112,10 @@ TEST(GlonassGnavEphemerisTest, ConvertGlonassT2GpsT2) ASSERT_TRUE(tow - true_week < FLT_EPSILON ); } +/*! + * \brief Testing conversion from GLONASST to GPST + * \test This version tests the conversion around the vicinity of February 29 days when in leap year + */ TEST(GlonassGnavEphemerisTest, ConvertGlonassT2GpsT3) { Glonass_Gnav_Ephemeris gnav_eph;