StdNavTimeOffset_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 "StdNavTimeOffset.hpp"
40 #include "TestUtil.hpp"
41 #include "GPSWeekSecond.hpp"
42 #include "TimeString.hpp"
43 using namespace std;
44 namespace gnsstk
45 {
46  std::ostream& operator<<(std::ostream& s, gnsstk::NavMessageType e)
47  {
48  s << StringUtils::asString(e);
49  return s;
50  }
51 }
52 
53 
56 {
57 public:
58  bool validate() const override
59  { return true; }
60  gnsstk::NavDataPtr clone() const override
61  { return std::make_shared<TestClass>(*this); }
62 };
63 
65 {
66 public:
68  unsigned constructorTest();
69  unsigned getOffsetTest();
70  unsigned getConversionsTest();
71 };
72 
73 
74 unsigned StdNavTimeOffset_T ::
76 {
77  TUDEF("StdNavTimeOffset", "StdNavTimeOffset");
78  TestClass uut;
81  TUASSERTFE(0.0, uut.a0);
82  TUASSERTFE(0.0, uut.a1);
83  TUASSERTFE(0.0, uut.a2);
84  TUASSERTFE(0.0, uut.deltatLS);
86  TUASSERTFE(0.0, uut.tot);
87  TUASSERTE(unsigned, 0, uut.wnot);
88  TUASSERTE(unsigned, 0, uut.wnLSF);
89  TUASSERTE(unsigned, 0, uut.dn);
90  TUASSERTFE(0.0, uut.deltatLSF);
92  uut.signal.messageType);
93  TURETURN();
94 }
95 
96 
97 unsigned StdNavTimeOffset_T ::
99 {
100  TUDEF("StdNavTimeOffset", "getOffset");
101  TestClass uut;
102  gnsstk::GPSWeekSecond ws1(2060, 405504.0);
103  gnsstk::GPSWeekSecond ws2(2061, 405504.0);
104  uut.src = gnsstk::TimeSystem::GPS;
105  uut.tgt = gnsstk::TimeSystem::UTC;
106  uut.a0 = 1.9790604711E-09;
107  uut.a1 = 7.5495165675E-15;
108  uut.a2 = 0;
109  uut.deltatLS = 18.0;
110  uut.tot = 21600.0;
111  uut.wnot = 2060;
112  uut.refTime = gnsstk::GPSWeekSecond(uut.wnot,uut.tot);
113  double offset;
116  offset));
117  TUASSERTFE(18.000000004877350079, offset);
119  offset));
120  TUASSERTFE(18.000000009443297699, offset);
121  gnsstk::CommonTime utc2(ws2);
124  offset));
125  TUASSERTFE(-18.000000009443297699, offset);
126  gnsstk::CommonTime failTime(utc2);
128  try
129  {
131  offset);
132  TUFAIL("Did not throw an exception when expected");
133  }
134  catch (gnsstk::AssertionFailure)
135  {
136  TUPASS("");
137  }
138  catch (gnsstk::Exception& exc)
139  {
140  std::cerr << exc << std::endl;
141  TUFAIL("Not the expected exception");
142  }
143  // Test using real data and exercise the scheduled leap second
144  TestClass uut2;
145  uut2.src = gnsstk::TimeSystem::GPS;
146  uut2.tgt = gnsstk::TimeSystem::UTC;
147  uut2.a0 = -3.72529030E-09;
148  uut2.a1 = -9.76996262E-15;
149  uut2.a2 = 0;
150  uut2.deltatLS = 17.0;
151  uut2.tot = 147456.0;
152  uut2.wnot = 1929;
153  uut2.refTime = gnsstk::GPSWeekSecond(uut2.wnot,uut2.tot);
154  uut2.wnLSF = 1929;
155  uut2.dn = 7;
156  uut2.deltatLSF = 18.0;
157  uut2.effTime = gnsstk::GPSWeekSecond(uut2.wnLSF, (uut2.dn-1)*86400);
158  // WNLSF/DN is not in the past relative to user time and not
159  // within 6 hours
160  gnsstk::CommonTime test2time1(gnsstk::GPSWeekSecond(1929,496799));
161  TUASSERTE(bool, true, uut2.getOffset(uut2.src,uut2.tgt,test2time1,offset));
162  // verified by hand
163  TUASSERTFE(16.99999999286164253931, offset);
164  // WNLSF/DN is within 6 hours
165  gnsstk::CommonTime test2time2(gnsstk::GPSWeekSecond(1929,496800));
166  TUASSERTE(bool, true, uut2.getOffset(uut2.src,uut2.tgt,test2time2,offset));
167  // tE == WNLSF/DN
168  gnsstk::CommonTime test2time3(gnsstk::GPSWeekSecond(1929,518400));
169  TUASSERTE(bool, true, uut2.getOffset(uut2.src,uut2.tgt,test2time3,offset));
170  // verified by hand
171  TUASSERTFE(17.99999999265060068865, offset);
172  // Not testing uut2 with a time > 6 hours after the effectivity
173  // time because it would yield invalid results (offset of ~17
174  // seconds).
175  TURETURN();
176 }
177 
178 
179 unsigned StdNavTimeOffset_T ::
181 {
182  TUDEF("StdNavTimeOffset", "getConversions");
183  gnsstk::TimeCvtSet convs;
184  TestClass offs;
185  offs.src = gnsstk::TimeSystem::GAL;
186  offs.tgt = gnsstk::TimeSystem::GPS;
189  TUCATCH(convs = offs.getConversions());
190  TUASSERTE(size_t, 2, convs.size());
191  TUASSERTE(size_t, 1, convs.count(key1));
192  TUASSERTE(size_t, 1, convs.count(key2));
193  TURETURN();
194 }
195 
196 
197 int main()
198 {
199  StdNavTimeOffset_T testClass;
200  unsigned errorTotal = 0;
201 
202  errorTotal += testClass.constructorTest();
203  errorTotal += testClass.getOffsetTest();
204  errorTotal += testClass.getConversionsTest();
205 
206  std::cout << "Total Failures for " << __FILE__ << ": " << errorTotal
207  << std::endl;
208 
209  return errorTotal;
210 }
gnsstk::NavDataPtr
std::shared_ptr< NavData > NavDataPtr
Factories instantiate these in response to find() requests.
Definition: NavData.hpp:62
StdNavTimeOffset_T::getOffsetTest
unsigned getOffsetTest()
Definition: StdNavTimeOffset_T.cpp:98
StdNavTimeOffset_T::constructorTest
unsigned constructorTest()
Make sure constructor initializes data members correctly.
Definition: StdNavTimeOffset_T.cpp:75
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
TUFAIL
#define TUFAIL(MSG)
Definition: TestUtil.hpp:228
StdNavTimeOffset_T::getConversionsTest
unsigned getConversionsTest()
Definition: StdNavTimeOffset_T.cpp:180
gnsstk::StringUtils::asString
std::string asString(IonexStoreStrategy e)
Convert a IonexStoreStrategy to a whitespace-free string name.
Definition: IonexStoreStrategy.cpp:46
StdNavTimeOffset.hpp
main
int main()
Definition: StdNavTimeOffset_T.cpp:197
gnsstk::CommonTime::setTimeSystem
CommonTime & setTimeSystem(TimeSystem timeSystem)
Definition: CommonTime.hpp:195
TestClass::clone
gnsstk::NavDataPtr clone() const override
Definition: StdNavTimeOffset_T.cpp:60
StdNavTimeOffset_T
Definition: StdNavTimeOffset_T.cpp:64
gnsstk::TimeSystem::Unknown
@ Unknown
unknown time frame; for legacy code compatibility
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
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::Exception
Definition: Exception.hpp:151
TestClass::validate
bool validate() const override
Definition: StdNavTimeOffset_T.cpp:58
TUASSERT
#define TUASSERT(EXPR)
Definition: TestUtil.hpp:63
TestUtil.hpp
TURETURN
#define TURETURN()
Definition: TestUtil.hpp:232
gnsstk::TimeSystem::GAL
@ GAL
Galileo system time.
TUPASS
#define TUPASS(MSG)
Definition: TestUtil.hpp:230
gnsstk::CommonTime
Definition: CommonTime.hpp:84
gnsstk::TimeSystem
TimeSystem
Definition of various time systems.
Definition: TimeSystem.hpp:51
TUDEF
#define TUDEF(CLASS, METHOD)
Definition: TestUtil.hpp:56
gnsstk::TimeSystem::GLO
@ GLO
GLONASS system time (aka UTC(SU))
gnsstk::TimeSystem::UTC
@ UTC
Coordinated Universal Time (e.g., from NTP)
std::operator<<
std::ostream & operator<<(std::ostream &s, gnsstk::StringUtils::FFLead v)
Definition: FormattedDouble_T.cpp:44
gnsstk::NavMessageType::TimeOffset
@ TimeOffset
Message containing information about time system offsets.
GPSWeekSecond.hpp
gnsstk::TimeSystem::GPS
@ GPS
GPS system time.
std
Definition: Angle.hpp:142
gnsstk::NavMessageType
NavMessageType
Identify different types of navigation message data.
Definition: NavMessageType.hpp:59
TestClass::getOffset
bool getOffset(gnsstk::TimeSystem fromSys, gnsstk::TimeSystem toSys, const gnsstk::CommonTime &when, gnsstk::NavDataPtr &offset, gnsstk::SVHealth xmitHealth, gnsstk::NavValidityType valid) override
Definition: NavDataFactory_T.cpp:71
TestClass
Make GroupPathCorrector instantiatable for testing.
Definition: GroupPathCorrector_T.cpp:56
TUASSERTFE
#define TUASSERTFE(EXP, GOT)
Definition: TestUtil.hpp:103
gnsstk::StdNavTimeOffset
Definition: StdNavTimeOffset.hpp:72
TimeString.hpp


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