2017-06-21 04:44:44 +00:00
|
|
|
/*!
|
|
|
|
* \file code_generation_test.cc
|
2017-08-19 21:04:14 +00:00
|
|
|
* \note Code added as part of GSoC 2017 program
|
|
|
|
* \author Damian Miralles, 2017. dmiralles2009(at)gmail.com
|
|
|
|
* \see <a href="http://russianspacesystems.ru/wp-content/uploads/2016/08/ICD_GLONASS_eng_v5.1.pdf">GLONASS ICD</a>
|
2017-06-21 04:44:44 +00:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010-2015 (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.
|
|
|
|
*
|
|
|
|
* GNSS-SDR is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* GNSS-SDR is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <complex>
|
|
|
|
#include <ctime>
|
2017-08-19 21:04:14 +00:00
|
|
|
#include <iostream>
|
2017-06-21 04:44:44 +00:00
|
|
|
#include "gnss_signal_processing.h"
|
|
|
|
#include "glonass_gnav_ephemeris.h"
|
|
|
|
|
|
|
|
|
2017-08-19 21:04:14 +00:00
|
|
|
TEST(GlonassGnavEphemerisTest, ComputeGlonassTime)
|
2017-06-21 04:44:44 +00:00
|
|
|
{
|
|
|
|
Glonass_Gnav_Ephemeris gnav_eph;
|
2017-08-19 21:04:14 +00:00
|
|
|
gnav_eph.d_yr = 2016;
|
|
|
|
gnav_eph.d_N_T = 367;
|
|
|
|
boost::posix_time::time_duration t(0, 0, 7560);
|
|
|
|
boost::gregorian::date d(gnav_eph.d_yr, 1, 1);
|
|
|
|
boost::gregorian::days d2(gnav_eph.d_N_T);
|
|
|
|
d = d + d2;
|
2017-06-21 04:44:44 +00:00
|
|
|
|
2017-08-19 21:04:14 +00:00
|
|
|
boost::gregorian::date expected_gdate;
|
|
|
|
boost::posix_time::time_duration expected_gtime;
|
2017-06-21 04:44:44 +00:00
|
|
|
|
2017-08-19 21:04:14 +00:00
|
|
|
boost::posix_time::ptime gtime = gnav_eph.compute_GLONASS_time(7560);
|
|
|
|
expected_gdate = gtime.date();
|
|
|
|
expected_gtime = gtime.time_of_day();
|
|
|
|
|
|
|
|
// Perform assertions of decoded fields
|
|
|
|
ASSERT_TRUE(expected_gdate.year() - d.year() < FLT_EPSILON );
|
|
|
|
ASSERT_TRUE(expected_gdate.month() - d.month() < FLT_EPSILON );
|
|
|
|
ASSERT_TRUE(expected_gdate.day() - d.day() < FLT_EPSILON );
|
|
|
|
ASSERT_TRUE(expected_gtime.hours() - t.hours() < FLT_EPSILON );
|
|
|
|
ASSERT_TRUE(expected_gtime.minutes() - t.minutes() < FLT_EPSILON );
|
|
|
|
ASSERT_TRUE(expected_gtime.seconds() - t.seconds() < FLT_EPSILON );
|
2017-06-21 04:44:44 +00:00
|
|
|
}
|
2017-10-24 14:51:38 +00:00
|
|
|
|
2017-10-27 00:43:18 +00:00
|
|
|
// testing case where calendar
|
|
|
|
TEST(GlonassGnavEphemerisTest, ConvertGlonassT2GpsT1)
|
2017-10-24 14:51:38 +00:00
|
|
|
{
|
|
|
|
Glonass_Gnav_Ephemeris gnav_eph;
|
2017-10-27 00:43:18 +00:00
|
|
|
gnav_eph.d_yr = 2004;
|
|
|
|
gnav_eph.d_N_T = 366+28;
|
2017-10-24 14:51:38 +00:00
|
|
|
|
|
|
|
double tod = 70200;
|
|
|
|
double week = 0.0;
|
|
|
|
double tow = 0.0;
|
|
|
|
double true_leap_sec = 13;
|
|
|
|
double true_week = 1307;
|
|
|
|
double true_tow = 480600+true_leap_sec;
|
|
|
|
|
|
|
|
gnav_eph.glot_to_gpst(tod, 0.0, 0.0, &week, &tow);
|
|
|
|
|
|
|
|
// Perform assertions of decoded fields
|
|
|
|
ASSERT_TRUE(week - true_week < FLT_EPSILON );
|
|
|
|
ASSERT_TRUE(tow - true_week < FLT_EPSILON );
|
|
|
|
}
|
2017-10-27 00:43:18 +00:00
|
|
|
|
|
|
|
TEST(GlonassGnavEphemerisTest, ConvertGlonassT2GpsT2)
|
|
|
|
{
|
|
|
|
Glonass_Gnav_Ephemeris gnav_eph;
|
|
|
|
gnav_eph.d_yr = 2016;
|
|
|
|
gnav_eph.d_N_T = 268;
|
|
|
|
|
|
|
|
double tod = 7560;
|
|
|
|
double week = 0.0;
|
|
|
|
double tow = 0.0;
|
|
|
|
double true_leap_sec = 13;
|
|
|
|
double true_week = 1915;
|
|
|
|
double true_tow = 480600+true_leap_sec;
|
|
|
|
|
|
|
|
gnav_eph.glot_to_gpst(tod, 0.0, 0.0, &week, &tow);
|
|
|
|
|
|
|
|
// Perform assertions of decoded fields
|
|
|
|
ASSERT_TRUE(week - true_week < FLT_EPSILON );
|
|
|
|
ASSERT_TRUE(tow - true_week < FLT_EPSILON );
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(GlonassGnavEphemerisTest, ConvertGlonassT2GpsT3)
|
|
|
|
{
|
|
|
|
Glonass_Gnav_Ephemeris gnav_eph;
|
|
|
|
gnav_eph.d_yr = 2016;
|
|
|
|
gnav_eph.d_N_T = 62;
|
|
|
|
|
|
|
|
double tod = 7560 + 6*3600;
|
|
|
|
double week = 0.0;
|
|
|
|
double tow = 0.0;
|
|
|
|
double true_leap_sec = 13;
|
|
|
|
double true_week = 1307;
|
|
|
|
double true_tow = 480600+true_leap_sec;
|
|
|
|
|
|
|
|
gnav_eph.glot_to_gpst(tod, 0.0, 0.0, &week, &tow);
|
|
|
|
|
|
|
|
// Perform assertions of decoded fields
|
|
|
|
ASSERT_TRUE(week - true_week < FLT_EPSILON );
|
|
|
|
ASSERT_TRUE(tow - true_week < FLT_EPSILON );
|
|
|
|
}
|