StdNavTimeOffset.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 "TimeString.hpp"
41 
42 using namespace std;
43 
44 namespace gnsstk
45 {
46  StdNavTimeOffset ::
47  StdNavTimeOffset()
48  : a0(0.0), a1(0.0), a2(0.0), deltatLS(0.0), tot(0.0), wnot(0),
49  wnLSF(0), dn(0), deltatLSF(0.0), dnSun(1),
51  {
52  }
53 
54 
57  const CommonTime& when, double& offset)
58  const
59  {
60  if (((fromSys == src) && (toSys == tgt)) ||
61  ((fromSys == tgt) && (toSys == src)))
62  {
63  GNSSTK_ASSERT(when.getTimeSystem() == fromSys);
64  // Change the reference time system to the source time
65  // system (fromSys) to allow for reverse conversions
66  // (e.g. UTC->GPS vs GPS->UTC).
67  CommonTime t0(refTime);
68  t0.setTimeSystem(fromSys);
69  // difference between tE and tot (using GPS terms)
70  double dt = when - t0;
71  // delta tLS should be 0 for anything other than UTC,
72  // except in the case of GLONASS.
73  offset = deltatLS + a0 + a1*dt + a2*dt*dt;
74  // UTC conversion includes leap seconds and everyone
75  // copied what GPS was doing, more or less, including the
76  // ICD/IS.
77  if ((fromSys == TimeSystem::UTC) || (toSys == TimeSystem::UTC))
78  {
79  CommonTime effBlank(effTime);
80  effBlank.setTimeSystem(fromSys);
81  if ((when >= effBlank) && ((when - effBlank) <= effEnd()))
82  {
83  // use deltatLSF from effectivity time to
84  // effectivity time + effEnd()
85  offset = deltatLSF + a0 + a1*dt + a2*dt*dt;
86  }
87  }
88  if (fromSys == tgt)
89  offset = -offset;
90  return true;
91  }
92  return false;
93  }
94 
95 
97  dump(std::ostream& s, DumpDetail dl) const
98  {
99  const ios::fmtflags oldFlags = s.flags();
100  if (dl == DumpDetail::OneLine)
101  {
102  NavData::dump(s,dl);
103  return;
104  }
105  if (dl == DumpDetail::Brief)
106  {
107  double offset;
108  getOffset(src, tgt, refTime, offset);
109  // brief just shows the offset as of the reference time.
111  << " offset = " << offset << endl;
112  return;
113  }
114  s << "****************************************************************"
115  << "************" << endl
116  << "Time System Offset"
117  << endl
118  << endl
119  << getSignalString() << endl
120  << " TIMES OF INTEREST" << endl << endl
121  << " " << getDumpTimeHdr(dl) << endl
122  << "Transmit: " << getDumpTime(dl, timeStamp)
123  << endl << endl
124  << " " << StringUtils::asString(src) << " "
125  << StringUtils::asString(tgt) << " PARAMETERS" << endl
126  << "Parameter Value" << endl
127  << "Reference "
128  << printTime(refTime,"%Y/%02m/%02d %02H:%02M:%02S") << endl
129  << "Effective "
130  << printTime(effTime,"%Y/%02m/%02d %02H:%02M:%02S") << endl
131  << right << uppercase << fixed << setprecision(0) << setfill(' ')
132  << "t-sub-ot " << setw(16) << tot << " sec" << endl
133  << scientific << setprecision(9)
134  << "A0 " << setw(16) << a0 << " sec" << endl
135  << "A1 " << setw(16) << a1 << " sec/sec" << endl
136  << "A2 " << setw(16) << a2 << " sec/sec**2" << endl
137  << fixed << setprecision(0)
138  << "dtLS " << setw(16) << deltatLS << " sec" << endl
139  << "dtLSF " << setw(16) << deltatLSF << " sec" << endl
140  << "WNot " << setw(11) << wnot << "("
141  << setw(3) << (wnot & 0x0ff) << ") Full week (modulo 256 week)" << endl
142  << "WN(LSF) " << setw(11) << wnLSF << "("
143  << setw(3) << (wnLSF & 0x0ff) << ") Full week (modulo 256 week)" << endl
146  << "DN " << setw(16) << dn << " day (" << dnSun << "-"
147  << (dnSun+6) << ")" << endl;
148  s.flags(oldFlags);
149  }
150 
151 
154  {
155  TimeCvtKey keyF(src,tgt);
156  TimeCvtKey keyR(tgt,src);
157  return TimeCvtSet({ keyF, keyR });
158  }
159 }
160 
gnsstk::NavData::getSignalString
std::string getSignalString() const
Definition: NavData.cpp:86
gnsstk::StdNavTimeOffset::deltatLSF
double deltatLSF
Current or future leap second count (UTC only).
Definition: StdNavTimeOffset.hpp:135
gnsstk::StdNavTimeOffset::effEnd
virtual double effEnd() const
Definition: StdNavTimeOffset.hpp:108
gnsstk::NavData::dump
virtual void dump(std::ostream &s, DumpDetail dl) const
Definition: NavData.cpp:79
gnsstk::StdNavTimeOffset::dump
void dump(std::ostream &s, DumpDetail dl) const override
Definition: StdNavTimeOffset.cpp:97
gnsstk::StdNavTimeOffset::src
TimeSystem src
Source time system.
Definition: StdNavTimeOffset.hpp:120
gnsstk::TimeCvtKey
std::pair< TimeSystem, TimeSystem > TimeCvtKey
Definition: TimeOffsetData.hpp:53
gnsstk::NavData::getDumpTime
std::string getDumpTime(DumpDetail dl, const CommonTime &t) const
Definition: NavData.cpp:145
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
StdNavTimeOffset.hpp
gnsstk::CommonTime::setTimeSystem
CommonTime & setTimeSystem(TimeSystem timeSystem)
Definition: CommonTime.hpp:195
gnsstk::StdNavTimeOffset::deltatLS
double deltatLS
Current or past leap second count (UTC only).
Definition: StdNavTimeOffset.hpp:125
gnsstk::NavData::getDumpTimeHdr
std::string getDumpTimeHdr(DumpDetail dl) const
Definition: NavData.cpp:127
gnsstk::StdNavTimeOffset::wnot
unsigned wnot
Time data reference week number (storage only).
Definition: StdNavTimeOffset.hpp:129
gnsstk::StdNavTimeOffset::dnSun
unsigned dnSun
dn value for Sunday.
Definition: StdNavTimeOffset.hpp:136
gnsstk::StdNavTimeOffset::wnLSF
unsigned wnLSF
Leap second reference week number (UTC only).
Definition: StdNavTimeOffset.hpp:133
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
gnsstk::IonexStoreStrategy::Unknown
@ Unknown
Unknown or uninitialized stategy value.
gnsstk::StdNavTimeOffset::a1
double a1
Drift coefficient of source time scale.
Definition: StdNavTimeOffset.hpp:123
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
gnsstk::StdNavTimeOffset::dn
unsigned dn
Leap second reference day number (UTC only).
Definition: StdNavTimeOffset.hpp:134
gnsstk::StdNavTimeOffset::a2
double a2
Drift rate coefficient of source time scale.
Definition: StdNavTimeOffset.hpp:124
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
gnsstk::TimeSystem::UTC
@ UTC
Coordinated Universal Time (e.g., from NTP)
GNSSTK_ASSERT
#define GNSSTK_ASSERT(CONDITION)
Provide an "ASSERT" type macro.
Definition: Exception.hpp:373
gnsstk::CommonTime::getTimeSystem
TimeSystem getTimeSystem() const
Obtain time system info (enum).
Definition: CommonTime.cpp:288
gnsstk::DumpDetail
DumpDetail
Specify level of detail for dump output.
Definition: DumpDetail.hpp:51
gnsstk::printTime
std::string printTime(const CommonTime &t, const std::string &fmt)
Definition: TimeString.cpp:64
gnsstk::DumpDetail::Brief
@ Brief
Limit output to <= 5 lines of minimal information.
std
Definition: Angle.hpp:142
gnsstk::DumpDetail::OneLine
@ OneLine
Limit output to minimal information on a single line.
gnsstk::StdNavTimeOffset::a0
double a0
Bias coefficient of source time scale.
Definition: StdNavTimeOffset.hpp:122
gnsstk::StdNavTimeOffset::effTime
CommonTime effTime
Effectivity time (wnLSF,dn).
Definition: StdNavTimeOffset.hpp:127
gnsstk::StdNavTimeOffset::refTime
CommonTime refTime
Reference time for computation.
Definition: StdNavTimeOffset.hpp:126
TimeString.hpp
gnsstk::StdNavTimeOffset::tot
double tot
Time data reference time of week (storage only).
Definition: StdNavTimeOffset.hpp:128


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