mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-01-19 05:33:02 +00:00
Avoid code duplication
This commit is contained in:
parent
399903e491
commit
945c86a4c4
@ -13,7 +13,6 @@ set(SYSTEM_PARAMETERS_SOURCES
|
|||||||
gnss_signal.cc
|
gnss_signal.cc
|
||||||
gps_navigation_message.cc
|
gps_navigation_message.cc
|
||||||
gps_ephemeris.cc
|
gps_ephemeris.cc
|
||||||
gps_utc_model.cc
|
|
||||||
galileo_utc_model.cc
|
galileo_utc_model.cc
|
||||||
galileo_ephemeris.cc
|
galileo_ephemeris.cc
|
||||||
galileo_almanac_helper.cc
|
galileo_almanac_helper.cc
|
||||||
@ -24,7 +23,6 @@ set(SYSTEM_PARAMETERS_SOURCES
|
|||||||
galileo_fnav_message.cc
|
galileo_fnav_message.cc
|
||||||
gps_cnav_ephemeris.cc
|
gps_cnav_ephemeris.cc
|
||||||
gps_cnav_navigation_message.cc
|
gps_cnav_navigation_message.cc
|
||||||
gps_cnav_utc_model.cc
|
|
||||||
glonass_gnav_ephemeris.cc
|
glonass_gnav_ephemeris.cc
|
||||||
glonass_gnav_utc_model.cc
|
glonass_gnav_utc_model.cc
|
||||||
glonass_gnav_navigation_message.cc
|
glonass_gnav_navigation_message.cc
|
||||||
|
@ -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 <cmath>
|
|
||||||
|
|
||||||
|
|
||||||
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<double>(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<int32_t>(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<double>(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<double>(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;
|
|
||||||
}
|
|
@ -1,6 +1,6 @@
|
|||||||
/*!
|
/*!
|
||||||
* \file gps_cnav_utc_model.h
|
* \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
|
* \author Javier Arribas, 2013. jarribas(at)cttc.es
|
||||||
*
|
*
|
||||||
* -------------------------------------------------------------------------
|
* -------------------------------------------------------------------------
|
||||||
@ -37,12 +37,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
Gps_CNAV_Utc_Model() = default;
|
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
|
// 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_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]
|
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]
|
||||||
|
@ -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 <cmath>
|
|
||||||
|
|
||||||
|
|
||||||
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<double>(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<int32_t>(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<double>(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<double>(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;
|
|
||||||
}
|
|
@ -70,12 +70,6 @@ public:
|
|||||||
archive& make_nvp("d_DeltaT_LSF", d_DeltaT_LSF);
|
archive& make_nvp("d_DeltaT_LSF", d_DeltaT_LSF);
|
||||||
archive& make_nvp("valid", valid);
|
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
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user