GLOFNavUT1TimeOffset.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 "GLOFNavUT1TimeOffset.hpp"
40 #include "TimeString.hpp"
41 
42 using namespace std;
43 
44 namespace gnsstk
45 {
46  GLOFNavUT1TimeOffset ::
47  GLOFNavUT1TimeOffset()
48  : tauc(std::numeric_limits<double>::quiet_NaN()),
49  B1(std::numeric_limits<double>::quiet_NaN()),
50  B2(std::numeric_limits<double>::quiet_NaN()),
51  KP(-1), NT(-1), NA(-1)
52  {
53  msgLenSec = 2.0;
54  weekFmt = "";
55  }
56 
57 
59  dump(std::ostream& s, DumpDetail dl) const
60  {
61  const ios::fmtflags oldFlags = s.flags();
62  if (dl == DumpDetail::Terse)
63  {
64  dumpTerse(s);
65  return;
66  }
67  if (dl == DumpDetail::OneLine)
68  {
69  NavData::dump(s,dl);
70  return;
71  }
72  if (dl == DumpDetail::Brief)
73  {
74  double offset;
76  // brief just shows the offset as of the reference time.
79  << " offset = " << offset << endl;
80  return;
81  }
82  s << "****************************************************************"
83  << "************" << endl
84  << "Time System Offset"
85  << endl
86  << endl
87  << getSignalString() << endl
88  << endl
89  << " TIMES OF INTEREST" << endl << endl
90  << " " << getDumpTimeHdr(dl) << endl
91  << "Transmit: " << getDumpTime(dl, timeStamp)
92  << endl << endl
93  << " " << StringUtils::asString(TimeSystem::GLO) << " "
94  << StringUtils::asString(TimeSystem::UTC) << " PARAMETERS" << endl
95  << "Parameter Value" << endl;
96  s.setf(ios::scientific, ios::floatfield);
97  s.setf(ios::right, ios::adjustfield);
98  s.setf(ios::uppercase);
99  s.precision(6);
100  s.fill(' ');
101  s << "tau_c " << setw(14) << tauc << " sec" << endl
102  << "B1 " << setw(14) << B1 << " sec" << endl
103  << "B2 " << setw(14) << B2 << " sec/sec" << endl
104  << "KP " << setw(12) << KP;
105  if (KP==0)
106  {
107  s << " No leap second this quarter";
108  }
109  else if (KP==1)
110  {
111  s << " +1 leap second this quarter";
112  }
113  else if (KP==3)
114  {
115  s << " -1 leap second this quarter";
116  }
117  else
118  {
119  s << " Unknown meaning";
120  }
121  s << endl
122  << "NT " << setw(12) << NT << " days" << endl
123  << "NA " << setw(12) << NA << " days" << endl;
124  s.flags(oldFlags);
125  }
126 
127 
129  dumpTerse(ostream& s) const
130  {
131  s << std::setw(4) << signal.sat.id
132  << printTime(timeStamp,"%02m/%02d/%04Y %03j %02H:%02M:%02S") << "! ";
133  s.setf(ios::scientific, ios::floatfield);
134  s.setf(ios::right, ios::adjustfield);
135  s.setf(ios::uppercase);
136  s.precision(9);
137  s.fill(' ');
138  s << "B1:" << B1;
139  s.precision(6);
140  s << " s, B2:" << B2;
141 
142  s.precision(0);
143  s << " s/s, KP:" << KP;
144  s << " ";
145  }
146 
147 
150  const CommonTime& when, double& offset)
151  const
152  {
153  if (((fromSys == TimeSystem::GLO) && (toSys == TimeSystem::UTC)) ||
154  ((fromSys == TimeSystem::UTC) && (toSys == TimeSystem::GLO)))
155  {
156  GNSSTK_ASSERT(when.getTimeSystem() == fromSys);
157  long dt = NT-NA;
158  double dUT1 = B1 + B2*dt;
159  // T_GLO = T_UTC(SU) + 3 hours, or
160  // T_UTC(SU) = T_GLO - 3 hours
161  // UT1 = UTC(SU) - dUT1
162  offset = -10800 + tauc + dUT1;
163  if (fromSys == TimeSystem::UTC)
164  offset = -offset;
165  return true;
166  }
167  return false;
168  }
169 
170 
173  {
176  return TimeCvtSet({ keyF, keyR });
177  }
178 
179 
181  validate() const
182  {
184  return true;
185  }
186 }
187 
gnsstk::GLOFNavUT1TimeOffset::dumpTerse
void dumpTerse(std::ostream &s) const
Definition: GLOFNavUT1TimeOffset.cpp:129
gnsstk::NavData::getSignalString
std::string getSignalString() const
Definition: NavData.cpp:86
gnsstk::NavData::msgLenSec
double msgLenSec
Definition: NavData.hpp:199
gnsstk::SatID::id
int id
Satellite identifier, e.g. PRN.
Definition: SatID.hpp:154
gnsstk::NavData::dump
virtual void dump(std::ostream &s, DumpDetail dl) const
Definition: NavData.cpp:79
gnsstk::TimeCvtKey
std::pair< TimeSystem, TimeSystem > TimeCvtKey
Definition: TimeOffsetData.hpp:53
gnsstk::GLOFNavUT1TimeOffset::B1
double B1
Time bias in seconds.
Definition: GLOFNavUT1TimeOffset.hpp:104
gnsstk::GLOFNavUT1TimeOffset::KP
unsigned KP
Leap second indicator.
Definition: GLOFNavUT1TimeOffset.hpp:106
gnsstk::NavData::getDumpTime
std::string getDumpTime(DumpDetail dl, const CommonTime &t) const
Definition: NavData.cpp:145
gnsstk::GLOFNavUT1TimeOffset::B2
double B2
Time drift in s/s.
Definition: GLOFNavUT1TimeOffset.hpp:105
gnsstk::StringUtils::asString
std::string asString(IonexStoreStrategy e)
Convert a IonexStoreStrategy to a whitespace-free string name.
Definition: IonexStoreStrategy.cpp:46
gnsstk::NavData::getDumpTimeHdr
std::string getDumpTimeHdr(DumpDetail dl) const
Definition: NavData.cpp:127
gnsstk::NavData::signal
NavMessageID signal
Source signal identification for this navigation message data.
Definition: NavData.hpp:175
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
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::NavData::weekFmt
std::string weekFmt
Definition: NavData.hpp:193
gnsstk::GLOFNavUT1TimeOffset::validate
bool validate() const override
Definition: GLOFNavUT1TimeOffset.cpp:181
gnsstk::GLOFNavUT1TimeOffset::tauc
double tauc
Non-integer correction between UTC(SU) and GLONASS.
Definition: GLOFNavUT1TimeOffset.hpp:103
gnsstk::CarrierBand::B1
@ B1
BeiDou B1.
gnsstk::NavSatelliteID::sat
SatID sat
ID of satellite to which the nav data applies.
Definition: NavSatelliteID.hpp:169
gnsstk::CommonTime
Definition: CommonTime.hpp:84
gnsstk::TimeSystem
TimeSystem
Definition of various time systems.
Definition: TimeSystem.hpp:51
gnsstk::TimeSystem::GLO
@ GLO
GLONASS system time (aka UTC(SU))
gnsstk::TimeSystem::UTC
@ UTC
Coordinated Universal Time (e.g., from NTP)
gnsstk::CarrierBand::B2
@ B2
BeiDou B2b.
gnsstk::DumpDetail::Terse
@ Terse
Aptly named, multiple lines of output with no labels.
gnsstk::GLOFNavUT1TimeOffset::dump
void dump(std::ostream &s, DumpDetail dl) const override
Definition: GLOFNavUT1TimeOffset.cpp:59
GNSSTK_ASSERT
#define GNSSTK_ASSERT(CONDITION)
Provide an "ASSERT" type macro.
Definition: Exception.hpp:373
gnsstk::GLOFNavUT1TimeOffset::NT
unsigned NT
Ephemeris days since leap year.
Definition: GLOFNavUT1TimeOffset.hpp:107
gnsstk::GLOFNavUT1TimeOffset::getConversions
TimeCvtSet getConversions() const override
Definition: GLOFNavUT1TimeOffset.cpp:172
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.
gnsstk::GLOFNavUT1TimeOffset::NA
unsigned NA
Almanac days since leap year.
Definition: GLOFNavUT1TimeOffset.hpp:108
std
Definition: Angle.hpp:142
gnsstk::DumpDetail::OneLine
@ OneLine
Limit output to minimal information on a single line.
GLOFNavUT1TimeOffset.hpp
TimeString.hpp
gnsstk::GLOFNavUT1TimeOffset::getOffset
bool getOffset(TimeSystem fromSys, TimeSystem toSys, const CommonTime &when, double &offset) const override
Definition: GLOFNavUT1TimeOffset.cpp:149


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