From 945c86a4c468a72faef247dd88a9ff216ef99924 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 21 Jul 2020 13:56:01 +0200 Subject: [PATCH] Avoid code duplication --- src/core/system_parameters/CMakeLists.txt | 2 - .../system_parameters/gps_cnav_utc_model.cc | 89 ------------------- .../system_parameters/gps_cnav_utc_model.h | 8 +- src/core/system_parameters/gps_utc_model.cc | 87 ------------------ src/core/system_parameters/gps_utc_model.h | 6 -- 5 files changed, 1 insertion(+), 191 deletions(-) delete mode 100644 src/core/system_parameters/gps_cnav_utc_model.cc delete mode 100644 src/core/system_parameters/gps_utc_model.cc diff --git a/src/core/system_parameters/CMakeLists.txt b/src/core/system_parameters/CMakeLists.txt index e78425139..4634fa7f6 100644 --- a/src/core/system_parameters/CMakeLists.txt +++ b/src/core/system_parameters/CMakeLists.txt @@ -13,7 +13,6 @@ set(SYSTEM_PARAMETERS_SOURCES gnss_signal.cc gps_navigation_message.cc gps_ephemeris.cc - gps_utc_model.cc galileo_utc_model.cc galileo_ephemeris.cc galileo_almanac_helper.cc @@ -24,7 +23,6 @@ set(SYSTEM_PARAMETERS_SOURCES galileo_fnav_message.cc gps_cnav_ephemeris.cc gps_cnav_navigation_message.cc - gps_cnav_utc_model.cc glonass_gnav_ephemeris.cc glonass_gnav_utc_model.cc glonass_gnav_navigation_message.cc diff --git a/src/core/system_parameters/gps_cnav_utc_model.cc b/src/core/system_parameters/gps_cnav_utc_model.cc deleted file mode 100644 index 125baa210..000000000 --- a/src/core/system_parameters/gps_cnav_utc_model.cc +++ /dev/null @@ -1,89 +0,0 @@ -/* - * \file gps_cnav_utc_model.cc - * \brief Interface of a GPS CNAV UTC MODEL storage - * \author Javier Arribas, 2015. jarribas(at)cttc.es - * - * ------------------------------------------------------------------------- - * - * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) - * - * GNSS-SDR is a software defined Global Navigation - * Satellite Systems receiver - * - * This file is part of GNSS-SDR. - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - * ------------------------------------------------------------------------- - */ - -#include "gps_cnav_utc_model.h" -#include - - -double Gps_CNAV_Utc_Model::utc_time(double gpstime_corrected, int32_t i_GPS_week) -{ - double t_utc; - double t_utc_daytime; - double Delta_t_UTC = d_DeltaT_LS + d_A0 + d_A1 * (gpstime_corrected - d_t_OT + 604800 * static_cast(i_GPS_week - i_WN_T)); - - // Determine if the effectivity time of the leap second event is in the past - const int32_t weeksToLeapSecondEvent = i_WN_LSF - i_GPS_week; - - if (weeksToLeapSecondEvent >= 0) // is not in the past - { - // Detect if the effectivity time and user's time is within six hours = 6 * 60 *60 = 21600 s - const int32_t secondOfLeapSecondEvent = i_DN * 24 * 60 * 60; - if (weeksToLeapSecondEvent > 0) - { - t_utc_daytime = fmod(gpstime_corrected - Delta_t_UTC, 86400); - } - else // we are in the same week than the leap second event - { - if (std::abs(gpstime_corrected - secondOfLeapSecondEvent) > 21600) - { - /* 20.3.3.5.2.4a - * Whenever the effectivity time indicated by the WN_LSF and the DN values - * is not in the past (relative to the user's present time), and the user's - * present time does not fall in the time span which starts at six hours prior - * to the effectivity time and ends at six hours after the effectivity time, - * the UTC/GPS-time relationship is given by - */ - t_utc_daytime = fmod(gpstime_corrected - Delta_t_UTC, 86400); - } - else - { - /* 20.3.3.5.2.4b - * Whenever the user's current time falls within the time span of six hours - * prior to the effectivity time to six hours after the effectivity time, - * proper accommodation of the leap second event with a possible week number - * transition is provided by the following expression for UTC: - */ - const int32_t W = static_cast(fmod(gpstime_corrected - Delta_t_UTC - 43200, 86400)) + 43200; - t_utc_daytime = fmod(W, 86400 + d_DeltaT_LSF - d_DeltaT_LS); - // implement something to handle a leap second event! - } - if ((gpstime_corrected - secondOfLeapSecondEvent) > 21600) - { - Delta_t_UTC = d_DeltaT_LSF + d_A0 + d_A1 * (gpstime_corrected - d_t_OT + 604800 * static_cast(i_GPS_week - i_WN_T)); - t_utc_daytime = fmod(gpstime_corrected - Delta_t_UTC, 86400); - } - } - } - else // the effectivity time is in the past - { - /* 20.3.3.5.2.4c - * Whenever the effectivity time of the leap second event, as indicated by the - * WNLSF and DN values, is in the "past" (relative to the user's current time), - * and the user's current time does not fall in the time span as given above - * in 20.3.3.5.2.4b,*/ - /* FOR CNAV: Replace the 20.3.3.5.2.4c with 30.3.3.6.2 UTC and GPS Time as follows */ - const double tmp_d = (gpstime_corrected - d_t_OT + 604800 * static_cast(i_GPS_week - i_WN_T)); - Delta_t_UTC = d_DeltaT_LSF + d_A0 + d_A1 * tmp_d + d_A2 * tmp_d * tmp_d; - t_utc_daytime = fmod(gpstime_corrected - Delta_t_UTC, 86400); - } - - const double secondsOfWeekBeforeToday = 86400 * floor(gpstime_corrected / 86400); - t_utc = secondsOfWeekBeforeToday + t_utc_daytime; - return t_utc; -} diff --git a/src/core/system_parameters/gps_cnav_utc_model.h b/src/core/system_parameters/gps_cnav_utc_model.h index 1d37b4d36..cf363db2e 100644 --- a/src/core/system_parameters/gps_cnav_utc_model.h +++ b/src/core/system_parameters/gps_cnav_utc_model.h @@ -1,6 +1,6 @@ /*! * \file gps_cnav_utc_model.h - * \brief Interface of a GPS UTC MODEL storage + * \brief Interface of a GPS CNAV UTC MODEL storage * \author Javier Arribas, 2013. jarribas(at)cttc.es * * ------------------------------------------------------------------------- @@ -37,12 +37,6 @@ public: */ Gps_CNAV_Utc_Model() = default; - /*! - * \brief Computes the Coordinated Universal Time (UTC) and - * returns it in [s] (IS-GPS-200K, 20.3.3.5.2.4 + 30.3.3.6.2) - */ - double utc_time(double gpstime_corrected, int32_t i_GPS_week); - // UTC parameters double d_A2{}; //!< 2nd order term of a model that relates GPS and UTC time (ref. 20.3.3.5.2.4 IS-GPS-200K) [s/s] double d_A1{}; //!< 1st order term of a model that relates GPS and UTC time (ref. 20.3.3.5.2.4 IS-GPS-200K) [s/s] diff --git a/src/core/system_parameters/gps_utc_model.cc b/src/core/system_parameters/gps_utc_model.cc deleted file mode 100644 index 06545d5cf..000000000 --- a/src/core/system_parameters/gps_utc_model.cc +++ /dev/null @@ -1,87 +0,0 @@ -/* - * \file gps_utc_model.h - * \brief Interface of a GPS UTC MODEL storage - * \author Javier Arribas, 2013. jarribas(at)cttc.es - * - * ------------------------------------------------------------------------- - * - * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) - * - * GNSS-SDR is a software defined Global Navigation - * Satellite Systems receiver - * - * This file is part of GNSS-SDR. - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - * ------------------------------------------------------------------------- - */ - -#include "gps_utc_model.h" -#include - - -double Gps_Utc_Model::utc_time(double gpstime_corrected, int32_t i_GPS_week) -{ - double t_utc; - double t_utc_daytime; - double Delta_t_UTC = d_DeltaT_LS + d_A0 + d_A1 * (gpstime_corrected - d_t_OT + 604800 * static_cast(i_GPS_week - i_WN_T)); - - // Determine if the effectivity time of the leap second event is in the past - int32_t weeksToLeapSecondEvent = i_WN_LSF - i_GPS_week; - - if (weeksToLeapSecondEvent >= 0) // is not in the past - { - // Detect if the effectivity time and user's time is within six hours = 6 * 60 *60 = 21600 s - int32_t secondOfLeapSecondEvent = i_DN * 24 * 60 * 60; - if (weeksToLeapSecondEvent > 0) - { - t_utc_daytime = fmod(gpstime_corrected - Delta_t_UTC, 86400); - } - else // we are in the same week than the leap second event - { - if (std::abs(gpstime_corrected - secondOfLeapSecondEvent) > 21600) - { - /* 20.3.3.5.2.4a - * Whenever the effectivity time indicated by the WN_LSF and the DN values - * is not in the past (relative to the user's present time), and the user's - * present time does not fall in the time span which starts at six hours prior - * to the effectivity time and ends at six hours after the effectivity time, - * the UTC/GPS-time relationship is given by - */ - t_utc_daytime = fmod(gpstime_corrected - Delta_t_UTC, 86400); - } - else - { - /* 20.3.3.5.2.4b - * Whenever the user's current time falls within the time span of six hours - * prior to the effectivity time to six hours after the effectivity time, - * proper accommodation of the leap second event with a possible week number - * transition is provided by the following expression for UTC: - */ - int32_t W = static_cast(fmod(gpstime_corrected - Delta_t_UTC - 43200, 86400)) + 43200; - t_utc_daytime = fmod(W, 86400 + d_DeltaT_LSF - d_DeltaT_LS); - // implement something to handle a leap second event! - } - if ((gpstime_corrected - secondOfLeapSecondEvent) > 21600) - { - Delta_t_UTC = d_DeltaT_LSF + d_A0 + d_A1 * (gpstime_corrected - d_t_OT + 604800 * static_cast(i_GPS_week - i_WN_T)); - t_utc_daytime = fmod(gpstime_corrected - Delta_t_UTC, 86400); - } - } - } - else // the effectivity time is in the past - { - /* 20.3.3.5.2.4c - * Whenever the effectivity time of the leap second event, as indicated by the - * WNLSF and DN values, is in the "past" (relative to the user's current time), - * and the user's current time does not fall in the time span as given above - * in 20.3.3.5.2.4b,*/ - Delta_t_UTC = d_DeltaT_LSF + d_A0 + d_A1 * (gpstime_corrected - d_t_OT + 604800 * static_cast(i_GPS_week - i_WN_T)); - t_utc_daytime = fmod(gpstime_corrected - Delta_t_UTC, 86400); - } - - double secondsOfWeekBeforeToday = 86400 * floor(gpstime_corrected / 86400); - t_utc = secondsOfWeekBeforeToday + t_utc_daytime; - return t_utc; -} diff --git a/src/core/system_parameters/gps_utc_model.h b/src/core/system_parameters/gps_utc_model.h index 5f02a3923..618b082a2 100644 --- a/src/core/system_parameters/gps_utc_model.h +++ b/src/core/system_parameters/gps_utc_model.h @@ -70,12 +70,6 @@ public: archive& make_nvp("d_DeltaT_LSF", d_DeltaT_LSF); archive& make_nvp("valid", valid); } - - /*! - * \brief Computes the Coordinated Universal Time (UTC) and - * returns it in [s] (IS-GPS-200K, 20.3.3.5.2.4) - */ - double utc_time(double gpstime_corrected, int32_t i_GPS_week); }; #endif