GALWeekSecond.hpp
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 // This software was developed by Applied Research Laboratories at the
28 // University of Texas at Austin, under contract to an agency or agencies
29 // within the U.S. Department of Defense. The U.S. Government retains all
30 // rights to use, duplicate, distribute, disclose, or release this software.
31 //
32 // Pursuant to DoD Directive 523024
33 //
34 // DISTRIBUTION STATEMENT A: This software has been approved for public
35 // release, distribution is unlimited.
36 //
37 //==============================================================================
38 
41 
42 #ifndef GNSSTK_GALWEEKSECOND_HPP
43 #define GNSSTK_GALWEEKSECOND_HPP
44 
45 #include "WeekSecond.hpp"
46 
47 namespace gnsstk
48 {
50 
51 
56  class GALWeekSecond : public WeekSecond
57  {
58  public:
59 
61  GALWeekSecond(unsigned int w = 0,
62  double s = 0.,
63  TimeSystem ts = TimeSystem::GAL) noexcept
64  : WeekSecond(w,s)
65  { timeSystem = ts; }
66 
68  GALWeekSecond( const CommonTime& right )
69  {
70  convertFromCommonTime( right );
71  }
72 
74  ~GALWeekSecond() noexcept {}
75 
78  int Nbits(void) const
79  {
80  static const int n=12;
81  return n;
82  }
83 
85  int bitmask(void) const
86  {
87  static const int bm=0xFFF;
88  return bm;
89  }
90 
92  long MJDEpoch(void) const
93  {
94  static const long e=GAL_EPOCH_MJD;
95  return e;
96  }
97 
100  virtual std::string getPrintChars() const
101  {
102  return "TLlwgP";
103  }
104 
106  virtual std::string getDefaultFormat() const
107  {
108  return "%L %g %P";
109  }
110 
113  virtual std::string printf(const std::string& fmt) const
114  {
115  try {
117 
118  std::string rv = fmt;
119  rv = formattedPrint( rv, getFormatPrefixInt() + "T",
120  "Tu", getEpoch() );
121  rv = formattedPrint( rv, getFormatPrefixInt() + "L",
122  "Lu", week );
123  rv = formattedPrint( rv, getFormatPrefixInt() + "l",
124  "lu", getModWeek() );
125  rv = formattedPrint( rv, getFormatPrefixInt() + "w",
126  "wu", getDayOfWeek() );
127  rv = formattedPrint( rv, getFormatPrefixFloat() + "g",
128  "gf", sow );
129  rv = formattedPrint( rv, getFormatPrefixInt() + "P",
130  "Ps", StringUtils::asString(timeSystem).c_str() );
131  return rv;
132  }
133  catch(gnsstk::StringUtils::StringException& e)
134  { GNSSTK_RETHROW(e); }
135  }
136 
139  virtual std::string printError(const std::string& fmt) const
140  {
141  try {
143  std::string rv = fmt;
144 
145  rv = formattedPrint( rv, getFormatPrefixInt() + "T",
146  "Ts", "BadGALepoch");
147  rv = formattedPrint( rv, getFormatPrefixInt() + "L",
148  "Ls", "BadGALfweek");
149  rv = formattedPrint( rv, getFormatPrefixInt() + "l",
150  "ls", "BadGALmweek");
151  rv = formattedPrint( rv, getFormatPrefixInt() + "w",
152  "wu", "BadGALdow");
153  rv = formattedPrint( rv, getFormatPrefixFloat() + "g",
154  "gf", "BadGALsow");
155  rv = formattedPrint( rv, getFormatPrefixInt() + "P",
156  "Ps", "BadGALsys");
157  return rv;
158  }
159  catch(gnsstk::StringUtils::StringException& e)
160  { GNSSTK_RETHROW(e); }
161  }
162 
168  bool setFromInfo( const IdToValue& info )
169  {
170 
171  for( IdToValue::const_iterator i = info.begin(); i != info.end(); i++ )
172  {
173  // based on the character, we know what to do...
174  switch ( i->first )
175  {
176  case 'T':
177  setEpoch( gnsstk::StringUtils::asInt( i->second ) );
178  break;
179  case 'L':
180  week = gnsstk::StringUtils::asInt( i->second );
181  break;
182  case 'l':
183  setModWeek( gnsstk::StringUtils::asInt( i->second ) );
184  break;
185  case 'w':
186  sow = static_cast<double>(gnsstk::StringUtils::asInt(i->second))*SEC_PER_DAY;
187  break;
188  case 'g':
189  sow = gnsstk::StringUtils::asDouble( i->second );
190  break;
191  case 'P':
193  break;
194  default:
195  // do nothing
196  break;
197  };
198 
199  } // end of for loop
200 
201  return true;
202  }
203 
204 
211  {
212  double diff = sow - refTime.sow;
213  if (diff < -HALFWEEK)
214  {
215  week = refTime.week + 1;
216  }
217  else if (diff > HALFWEEK)
218  {
219  week = refTime.week - 1;
220  }
221  else
222  {
223  week = refTime.week;
224  }
225  return *this;
226  }
227 
228  }; // end class GALWeekSecond
229 
231 
232 } // namespace
233 
234 #endif // GNSSTK_GALWEEKSECOND_HPP
gnsstk::TimeTag::getFormatPrefixInt
static std::string getFormatPrefixInt()
Definition: TimeTag.hpp:152
gnsstk::StringUtils::asInt
long asInt(const std::string &s)
Definition: StringUtils.hpp:713
gnsstk::HALFWEEK
const long HALFWEEK
Seconds per half week.
Definition: TimeConstants.hpp:58
gnsstk::GALWeekSecond::setFromInfo
bool setFromInfo(const IdToValue &info)
Definition: GALWeekSecond.hpp:168
gnsstk::WeekSecond::WeekSecond
WeekSecond(unsigned int w=0, double s=0., TimeSystem ts=TimeSystem::Unknown)
Definition: WeekSecond.hpp:74
gnsstk::Week::getEpoch
virtual unsigned int getEpoch() const
Definition: Week.hpp:188
gnsstk::TimeTag::IdToValue
std::map< char, std::string > IdToValue
Definition: TimeTag.hpp:103
gnsstk::SEC_PER_DAY
const long SEC_PER_DAY
Seconds per day.
Definition: TimeConstants.hpp:63
gnsstk::WeekSecond::convertFromCommonTime
virtual void convertFromCommonTime(const CommonTime &ct)
Definition: WeekSecond.cpp:78
gnsstk::StringUtils::asString
std::string asString(IonexStoreStrategy e)
Convert a IonexStoreStrategy to a whitespace-free string name.
Definition: IonexStoreStrategy.cpp:46
gnsstk::GALWeekSecond::MJDEpoch
long MJDEpoch(void) const
Return the Modified Julian Date (MJD) of epoch for this system.
Definition: GALWeekSecond.hpp:92
gnsstk::Week::setEpoch
virtual void setEpoch(unsigned int e)
Definition: Week.hpp:200
gnsstk::GALWeekSecond
Definition: GALWeekSecond.hpp:56
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
gnsstk::GALWeekSecond::getDefaultFormat
virtual std::string getDefaultFormat() const
Return a string containing the default format to use in printing.
Definition: GALWeekSecond.hpp:106
gnsstk::GALWeekSecond::printError
virtual std::string printError(const std::string &fmt) const
Definition: GALWeekSecond.hpp:139
gnsstk::TimeTag::timeSystem
TimeSystem timeSystem
time system (representation) of the data
Definition: TimeTag.hpp:204
gnsstk::WeekSecond::getDayOfWeek
virtual unsigned int getDayOfWeek() const
Force this interface on this classes descendants.
Definition: WeekSecond.hpp:134
gnsstk::GALWeekSecond::GALWeekSecond
GALWeekSecond(unsigned int w=0, double s=0., TimeSystem ts=TimeSystem::GAL) noexcept
Constructor.
Definition: GALWeekSecond.hpp:61
gnsstk::GALWeekSecond::GALWeekSecond
GALWeekSecond(const CommonTime &right)
Constructor from CommonTime.
Definition: GALWeekSecond.hpp:68
gnsstk::Week::setModWeek
virtual void setModWeek(unsigned int w)
Definition: Week.hpp:206
gnsstk::GALWeekSecond::Nbits
int Nbits(void) const
Definition: GALWeekSecond.hpp:78
gnsstk::GALWeekSecond::printf
virtual std::string printf(const std::string &fmt) const
Definition: GALWeekSecond.hpp:113
gnsstk::TimeTag::getFormatPrefixFloat
static std::string getFormatPrefixFloat()
Definition: TimeTag.hpp:157
gnsstk::StringUtils::asTimeSystem
TimeSystem asTimeSystem(const std::string &s)
Convert a string representation of TimeSystem to an enum.
Definition: TimeSystem.cpp:324
gnsstk::GALWeekSecond::getPrintChars
virtual std::string getPrintChars() const
Definition: GALWeekSecond.hpp:100
gnsstk::TimeSystem::GAL
@ GAL
Galileo system time.
gnsstk::CommonTime
Definition: CommonTime.hpp:84
gnsstk::WeekSecond::sow
double sow
Definition: WeekSecond.hpp:155
gnsstk::GALWeekSecond::weekRolloverAdj
GALWeekSecond & weekRolloverAdj(const GALWeekSecond &refTime)
Definition: GALWeekSecond.hpp:210
gnsstk::TimeSystem
TimeSystem
Definition of various time systems.
Definition: TimeSystem.hpp:51
gnsstk::Week::week
int week
Full week number.
Definition: Week.hpp:267
gnsstk::StringUtils::asDouble
double asDouble(const std::string &s)
Definition: StringUtils.hpp:705
GNSSTK_RETHROW
#define GNSSTK_RETHROW(exc)
Definition: Exception.hpp:369
gnsstk::WeekSecond
Definition: WeekSecond.hpp:60
WeekSecond.hpp
gnsstk::GAL_EPOCH_MJD
const long GAL_EPOCH_MJD
Modified Julian Date of GAL epoch (Aug 22 1999)
Definition: TimeConstants.hpp:104
gnsstk::GALWeekSecond::bitmask
int bitmask(void) const
Return the bitmask used to get the ModWeek from the full week.
Definition: GALWeekSecond.hpp:85
gnsstk::StringUtils::formattedPrint
std::string formattedPrint(const std::string &fmt, const std::string &pat, const std::string &rep, T to)
Definition: StringUtils.hpp:2020
gnsstk::Week::getModWeek
virtual unsigned int getModWeek() const
Definition: Week.hpp:183
gnsstk::GALWeekSecond::~GALWeekSecond
~GALWeekSecond() noexcept
Destructor.
Definition: GALWeekSecond.hpp:74


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