GPSCNavTimeOffset_T.cpp
Go to the documentation of this file.
1 //==============================================================================
2 //
3 // This file is part of GNSSTk, the ARL:UT GNSS Toolkit.
4 //
5 // The GNSSTk is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published
7 // by the Free Software Foundation; either version 3.0 of the License, or
8 // any later version.
9 //
10 // The GNSSTk is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with GNSSTk; if not, write to the Free Software Foundation,
17 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
18 //
19 // This software was developed by Applied Research Laboratories at the
20 // University of Texas at Austin.
21 // Copyright 2004-2022, The Board of Regents of The University of Texas System
22 //
23 //==============================================================================
24 
25 
26 //==============================================================================
27 //
28 // This software was developed by Applied Research Laboratories at the
29 // University of Texas at Austin, under contract to an agency or agencies
30 // within the U.S. Department of Defense. The U.S. Government retains all
31 // rights to use, duplicate, distribute, disclose, or release this software.
32 //
33 // Pursuant to DoD Directive 523024
34 //
35 // DISTRIBUTION STATEMENT A: This software has been approved for public
36 // release, distribution is unlimited.
37 //
38 //==============================================================================
39 #include "GPSCNavTimeOffset.hpp"
40 #include "TestUtil.hpp"
41 #include "GPSWeekSecond.hpp"
42 
43 namespace gnsstk
44 {
45  std::ostream& operator<<(std::ostream& s, gnsstk::NavMessageType e)
46  {
47  s << StringUtils::asString(e);
48  return s;
49  }
50 }
51 
52 
54 {
55 public:
57  unsigned constructorTest();
58  unsigned validateTest();
59  unsigned getUserTimeTest();
60  unsigned getOffsetTest();
61  unsigned getConversionsTest();
62 };
63 
64 
67 {
68  TUDEF("GPSCNavTimeOffset", "GPSCNavTimeOffset");
71  TUASSERTFE(0.0, uut.a0);
72  TUASSERTFE(0.0, uut.a1);
73  TUASSERTFE(0.0, uut.a2);
74  TUASSERTFE(0.0, uut.deltatLS);
76  TUASSERTFE(0.0, uut.tot);
77  TUASSERTE(unsigned, 0, uut.wnot);
78  TUASSERTE(unsigned, 0, uut.wnLSF);
79  TUASSERTE(unsigned, 0, uut.dn);
80  TUASSERTFE(0.0, uut.deltatLSF);
82  uut.signal.messageType);
83  TURETURN();
84 }
85 
86 
89 {
90  TUDEF("GPSCNavTimeOffset", "validate");
92  TUASSERTE(bool, true, offs.validate());
93  offs.tot = 604784.0;
94  TUASSERTE(bool, true, offs.validate());
95  offs.dn = 7;
96  TUASSERTE(bool, true, offs.validate());
97  offs.dn = 8;
98  TUASSERTE(bool, false, offs.validate());
99  offs.dn = 7;
100  offs.tot = -0.001;
101  TUASSERTE(bool, false, offs.validate());
102  offs.tot = 604784.1;
103  TUASSERTE(bool, false, offs.validate());
104  TURETURN();
105 }
106 
107 
108 unsigned GPSCNavTimeOffset_T ::
110 {
111  TUDEF("GPSCNavTimeOffset", "getUserTime");
113  // L2 has a 12s cadence, L5 has a 6s cadence
114  gnsstk::CommonTime expL2(gnsstk::GPSWeekSecond(2100,147.0));
115  gnsstk::CommonTime expL5(gnsstk::GPSWeekSecond(2100,141.0));
116  uut.timeStamp = gnsstk::GPSWeekSecond(2100,135.0);
129  TURETURN();
130 }
131 
132 
133 unsigned GPSCNavTimeOffset_T ::
135 {
136  TUDEF("GPSCNavTimeOffset", "getOffset");
138  gnsstk::GPSWeekSecond ws1(2060, 405504.0);
139  gnsstk::GPSWeekSecond ws2(2061, 405504.0);
141  uut.a0 = 1.9790604711E-09;
142  uut.a1 = 7.5495165675E-15;
143  uut.a2 = 0;
144  uut.deltatLS = 18.0;
145  uut.tot = 21600.0;
146  uut.wnot = 2060;
147  uut.refTime = gnsstk::GPSWeekSecond(uut.wnot,uut.tot);
148  double offset;
151  offset));
152  TUASSERTFE(18.000000004877350079, offset);
154  offset));
155  TUASSERTFE(18.000000009443297699, offset);
156  TURETURN();
157 }
158 
159 
160 unsigned GPSCNavTimeOffset_T ::
162 {
163  TUDEF("GPSCNavTimeOffset", "getConversions");
164  gnsstk::TimeCvtSet convs;
166  // This looks a bit weird, but basically getConversions is
167  // expected to return a set containing one key pair for GPS to
168  // the target time system, which by default is Unknown.
173  TUCATCH(convs = offs.getConversions());
174  TUASSERTE(size_t, 2, convs.size());
175  TUASSERTE(size_t, 1, convs.count(key1));
176  TUASSERTE(size_t, 1, convs.count(key2));
177  TURETURN();
178 }
179 
180 
181 int main()
182 {
183  GPSCNavTimeOffset_T testClass;
184  unsigned errorTotal = 0;
185 
186  errorTotal += testClass.constructorTest();
187  errorTotal += testClass.validateTest();
188  errorTotal += testClass.getUserTimeTest();
189  errorTotal += testClass.getOffsetTest();
190  errorTotal += testClass.getConversionsTest();
191 
192  std::cout << "Total Failures for " << __FILE__ << ": " << errorTotal
193  << std::endl;
194 
195  return errorTotal;
196 }
gnsstk::NavMessageID
Class used to identify/categorize navigation message data.
Definition: NavMessageID.hpp:52
gnsstk::StdNavTimeOffset::deltatLSF
double deltatLSF
Current or future leap second count (UTC only).
Definition: StdNavTimeOffset.hpp:135
gnsstk::GPSCNavTimeOffset
Definition: GPSCNavTimeOffset.hpp:62
TUCATCH
#define TUCATCH(STATEMENT)
Definition: TestUtil.hpp:193
TUASSERTE
#define TUASSERTE(TYPE, EXP, GOT)
Definition: TestUtil.hpp:81
gnsstk::TimeCvtKey
std::pair< TimeSystem, TimeSystem > TimeCvtKey
Definition: TimeOffsetData.hpp:53
gnsstk::NavMessageID::messageType
NavMessageType messageType
Definition: NavMessageID.hpp:97
gnsstk::NavSatelliteID
Definition: NavSatelliteID.hpp:57
gnsstk::StdNavTimeOffset::tgt
TimeSystem tgt
Target time system.
Definition: StdNavTimeOffset.hpp:121
gnsstk::TrackingCode::L5I
@ L5I
Modernized GPS L5 civil in-phase.
gnsstk::StringUtils::asString
std::string asString(IonexStoreStrategy e)
Convert a IonexStoreStrategy to a whitespace-free string name.
Definition: IonexStoreStrategy.cpp:46
gnsstk::StdNavTimeOffset::deltatLS
double deltatLS
Current or past leap second count (UTC only).
Definition: StdNavTimeOffset.hpp:125
gnsstk::StdNavTimeOffset::wnot
unsigned wnot
Time data reference week number (storage only).
Definition: StdNavTimeOffset.hpp:129
gnsstk::NavData::signal
NavMessageID signal
Source signal identification for this navigation message data.
Definition: NavData.hpp:175
GPSCNavTimeOffset.hpp
gnsstk::StdNavTimeOffset::wnLSF
unsigned wnLSF
Leap second reference week number (UTC only).
Definition: StdNavTimeOffset.hpp:133
gnsstk::TimeSystem::Unknown
@ Unknown
unknown time frame; for legacy code compatibility
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
gnsstk::StdNavTimeOffset::a1
double a1
Drift coefficient of source time scale.
Definition: StdNavTimeOffset.hpp:123
gnsstk::CarrierBand::L2
@ L2
GPS L2, QZSS L2.
gnsstk::GPSWeekSecond
Definition: GPSWeekSecond.hpp:56
gnsstk::TimeCvtSet
std::set< TimeCvtKey > TimeCvtSet
Define a unique set of time system conversions.
Definition: TimeOffsetData.hpp:55
gnsstk::NavData::timeStamp
CommonTime timeStamp
Definition: NavData.hpp:173
GPSCNavTimeOffset_T::constructorTest
unsigned constructorTest()
Make sure constructor initializes data members correctly.
Definition: GPSCNavTimeOffset_T.cpp:66
gnsstk::StdNavTimeOffset::dn
unsigned dn
Leap second reference day number (UTC only).
Definition: StdNavTimeOffset.hpp:134
gnsstk::SatelliteSystem::GPS
@ GPS
GPSCNavTimeOffset_T::getConversionsTest
unsigned getConversionsTest()
Definition: GPSCNavTimeOffset_T.cpp:161
TUASSERT
#define TUASSERT(EXPR)
Definition: TestUtil.hpp:63
TestUtil.hpp
gnsstk::StdNavTimeOffset::a2
double a2
Drift rate coefficient of source time scale.
Definition: StdNavTimeOffset.hpp:124
TURETURN
#define TURETURN()
Definition: TestUtil.hpp:232
GPSCNavTimeOffset_T
Definition: GPSCNavTimeOffset_T.cpp:53
gnsstk::NavType::GPSCNAVL2
@ GPSCNAVL2
gnsstk::operator<<
std::ostream & operator<<(std::ostream &s, const ObsEpoch &oe) noexcept
Definition: ObsEpochMap.cpp:54
main
int main()
Definition: GPSCNavTimeOffset_T.cpp:181
gnsstk::CommonTime
Definition: CommonTime.hpp:84
gnsstk::StdNavTimeOffset::getConversions
TimeCvtSet getConversions() const override
Definition: StdNavTimeOffset.cpp:153
gnsstk::TimeSystem
TimeSystem
Definition of various time systems.
Definition: TimeSystem.hpp:51
gnsstk::StdNavTimeOffset::getOffset
bool getOffset(TimeSystem fromSys, TimeSystem toSys, const CommonTime &when, double &offset) const override
Definition: StdNavTimeOffset.cpp:56
TUDEF
#define TUDEF(CLASS, METHOD)
Definition: TestUtil.hpp:56
gnsstk::TimeSystem::UTC
@ UTC
Coordinated Universal Time (e.g., from NTP)
gnsstk::GPSCNavTimeOffset::validate
bool validate() const override
Definition: GPSCNavTimeOffset.cpp:58
gnsstk::NavMessageType::TimeOffset
@ TimeOffset
Message containing information about time system offsets.
GPSWeekSecond.hpp
gnsstk::GPSCNavTimeOffset::getUserTime
CommonTime getUserTime() const override
Definition: GPSCNavTimeOffset.cpp:69
gnsstk::TrackingCode::L2CM
@ L2CM
Modernized GPS L2 civil M code.
GPSCNavTimeOffset_T::validateTest
unsigned validateTest()
Definition: GPSCNavTimeOffset_T.cpp:88
gnsstk::TimeSystem::GPS
@ GPS
GPS system time.
gnsstk::NavMessageType
NavMessageType
Identify different types of navigation message data.
Definition: NavMessageType.hpp:59
TUASSERTFE
#define TUASSERTFE(EXP, GOT)
Definition: TestUtil.hpp:103
gnsstk::StdNavTimeOffset::a0
double a0
Bias coefficient of source time scale.
Definition: StdNavTimeOffset.hpp:122
GPSCNavTimeOffset_T::getOffsetTest
unsigned getOffsetTest()
Definition: GPSCNavTimeOffset_T.cpp:134
GPSCNavTimeOffset_T::getUserTimeTest
unsigned getUserTimeTest()
Definition: GPSCNavTimeOffset_T.cpp:109
gnsstk::StdNavTimeOffset::refTime
CommonTime refTime
Reference time for computation.
Definition: StdNavTimeOffset.hpp:126
gnsstk::NavType::GPSCNAVL5
@ GPSCNAVL5
gnsstk::StdNavTimeOffset::tot
double tot
Time data reference time of week (storage only).
Definition: StdNavTimeOffset.hpp:128
gnsstk::CarrierBand::L5
@ L5
GPS L5, Galileo E5a, SBAS L5, QZSS L5, BeiDou B2a, NavIC L5.


gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:39