GPSCNav2TimeOffset_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 "GPSCNav2TimeOffset.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("GPSCNav2TimeOffset", "GPSCNav2TimeOffset");
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("GPSCNav2TimeOffset", "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 
110 {
111  TUDEF("GPSCNav2TimeOffset", "getUserTime");
113  uut.timeStamp = gnsstk::GPSWeekSecond(2100,135.0);
114  gnsstk::CommonTime exp = uut.timeStamp + 5.48;
116  TURETURN();
117 }
118 
119 
122 {
123  TUDEF("GPSCNav2TimeOffset", "getOffset");
125  gnsstk::GPSWeekSecond ws1(2060, 405504.0);
126  gnsstk::GPSWeekSecond ws2(2061, 405504.0);
128  uut.a0 = 1.9790604711E-09;
129  uut.a1 = 7.5495165675E-15;
130  uut.a2 = 0;
131  uut.deltatLS = 18.0;
132  uut.tot = 21600.0;
133  uut.wnot = 2060;
134  uut.refTime = gnsstk::GPSWeekSecond(uut.wnot,uut.tot);
135  double offset;
138  offset));
139  TUASSERTFE(18.000000004877350079, offset);
141  offset));
142  TUASSERTFE(18.000000009443297699, offset);
143  TURETURN();
144 }
145 
146 
149 {
150  TUDEF("GPSCNav2TimeOffset", "getConversions");
151  gnsstk::TimeCvtSet convs;
153  // This looks a bit weird, but basically getConversions is
154  // expected to return a set containing one key pair for GPS to
155  // the target time system, which by default is Unknown.
160  TUCATCH(convs = offs.getConversions());
161  TUASSERTE(size_t, 2, convs.size());
162  TUASSERTE(size_t, 1, convs.count(key1));
163  TUASSERTE(size_t, 1, convs.count(key2));
164  TURETURN();
165 }
166 
167 
168 int main()
169 {
170  GPSCNav2TimeOffset_T testClass;
171  unsigned errorTotal = 0;
172 
173  errorTotal += testClass.constructorTest();
174  errorTotal += testClass.validateTest();
175  errorTotal += testClass.getUserTimeTest();
176  errorTotal += testClass.getOffsetTest();
177  errorTotal += testClass.getConversionsTest();
178 
179  std::cout << "Total Failures for " << __FILE__ << ": " << errorTotal
180  << std::endl;
181 
182  return errorTotal;
183 }
gnsstk::GPSCNav2TimeOffset::validate
bool validate() const override
Definition: GPSCNav2TimeOffset.cpp:59
gnsstk::StdNavTimeOffset::deltatLSF
double deltatLSF
Current or future leap second count (UTC only).
Definition: StdNavTimeOffset.hpp:135
gnsstk::NavData::getUserTime
virtual CommonTime getUserTime() const
Definition: NavData.hpp:110
GPSCNav2TimeOffset_T::validateTest
unsigned validateTest()
Definition: GPSCNav2TimeOffset_T.cpp:88
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::StdNavTimeOffset::tgt
TimeSystem tgt
Target time system.
Definition: StdNavTimeOffset.hpp:121
gnsstk::StringUtils::asString
std::string asString(IonexStoreStrategy e)
Convert a IonexStoreStrategy to a whitespace-free string name.
Definition: IonexStoreStrategy.cpp:46
GPSCNav2TimeOffset_T
Definition: GPSCNav2TimeOffset_T.cpp:53
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
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::GPSWeekSecond
Definition: GPSWeekSecond.hpp:56
GPSCNav2TimeOffset.hpp
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
main
int main()
Definition: GPSCNav2TimeOffset_T.cpp:168
gnsstk::StdNavTimeOffset::dn
unsigned dn
Leap second reference day number (UTC only).
Definition: StdNavTimeOffset.hpp:134
GPSCNav2TimeOffset_T::getUserTimeTest
unsigned getUserTimeTest()
Definition: GPSCNav2TimeOffset_T.cpp:109
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
gnsstk::operator<<
std::ostream & operator<<(std::ostream &s, const ObsEpoch &oe) noexcept
Definition: ObsEpochMap.cpp:54
gnsstk::CommonTime
Definition: CommonTime.hpp:84
GPSCNav2TimeOffset_T::constructorTest
unsigned constructorTest()
Make sure constructor initializes data members correctly.
Definition: GPSCNav2TimeOffset_T.cpp:66
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::GPSCNav2TimeOffset
Definition: GPSCNav2TimeOffset.hpp:62
gnsstk::NavMessageType::TimeOffset
@ TimeOffset
Message containing information about time system offsets.
GPSWeekSecond.hpp
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
GPSCNav2TimeOffset_T::getConversionsTest
unsigned getConversionsTest()
Definition: GPSCNav2TimeOffset_T.cpp:148
gnsstk::StdNavTimeOffset::a0
double a0
Bias coefficient of source time scale.
Definition: StdNavTimeOffset.hpp:122
gnsstk::StdNavTimeOffset::refTime
CommonTime refTime
Reference time for computation.
Definition: StdNavTimeOffset.hpp:126
gnsstk::StdNavTimeOffset::tot
double tot
Time data reference time of week (storage only).
Definition: StdNavTimeOffset.hpp:128
GPSCNav2TimeOffset_T::getOffsetTest
unsigned getOffsetTest()
Definition: GPSCNav2TimeOffset_T.cpp:121


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