IRNWeekSecond.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_IRNWEEKSECOND_HPP
43 #define GNSSTK_IRNWEEKSECOND_HPP
44 
45 #include "WeekSecond.hpp"
46 
47 namespace gnsstk
48 {
50 
51 
56  class IRNWeekSecond : public WeekSecond
57  {
58  public:
59 
61  IRNWeekSecond(unsigned int w = 0,
62  double s = 0.,
64  : WeekSecond(w,s)
65  { timeSystem = ts; }
66 
68  IRNWeekSecond( const CommonTime& right )
69  {
70  convertFromCommonTime( right );
71  }
72 
74  ~IRNWeekSecond() noexcept {}
75 
76  // the rest define the week rollover and starting time
77 
80  int Nbits(void) const
81  {
82  static const int n=10;
83  return n;
84  }
85 
87  int bitmask(void) const
88  {
89  static const int bm=0x03FF;
90  return bm;
91  }
92 
94  long MJDEpoch(void) const
95  {
96  static const long e=IRN_EPOCH_MJD;
97  return e;
98  }
99 
102  virtual std::string getPrintChars() const
103  {
104  return "XOowgP";
105  }
106 
108  virtual std::string getDefaultFormat() const
109  {
110  return "%O %g %P";
111  }
112 
115  virtual std::string printf(const std::string& fmt) const
116  {
117  try {
119 
120  std::string rv = fmt;
121  rv = formattedPrint( rv, getFormatPrefixInt() + "X",
122  "Xu", getEpoch() );
123  rv = formattedPrint( rv, getFormatPrefixInt() + "O",
124  "Ou", week );
125  rv = formattedPrint( rv, getFormatPrefixInt() + "o",
126  "ou", getModWeek() );
127  rv = formattedPrint( rv, getFormatPrefixInt() + "w",
128  "wu", getDayOfWeek() );
129  rv = formattedPrint( rv, getFormatPrefixFloat() + "g",
130  "gf", sow );
131  rv = formattedPrint( rv, getFormatPrefixInt() + "P",
132  "Ps", StringUtils::asString(timeSystem).c_str() );
133  return rv;
134  }
135  catch(gnsstk::StringUtils::StringException& e)
136  { GNSSTK_RETHROW(e); }
137  }
138 
141  virtual std::string printError(const std::string& fmt) const
142  {
143  try {
145  std::string rv = fmt;
146 
147  rv = formattedPrint( rv, getFormatPrefixInt() + "X",
148  "Xs", "BadIRNepoch");
149  rv = formattedPrint( rv, getFormatPrefixInt() + "O",
150  "Os", "BadIRNfweek");
151  rv = formattedPrint( rv, getFormatPrefixInt() + "o",
152  "os", "BadIRNmweek");
153  rv = formattedPrint( rv, getFormatPrefixInt() + "w",
154  "ws", "BadIRNdow");
155  rv = formattedPrint( rv, getFormatPrefixFloat() + "g",
156  "gs", "BadIRNsow");
157  rv = formattedPrint( rv, getFormatPrefixInt() + "P",
158  "Ps", "BadIRNsys");
159  return rv;
160  }
161  catch(gnsstk::StringUtils::StringException& e)
162  { GNSSTK_RETHROW(e); }
163  }
164 
170  bool setFromInfo( const IdToValue& info )
171  {
172 
173  for( IdToValue::const_iterator i = info.begin(); i != info.end(); i++ )
174  {
175  // based on the character, we know what to do...
176  switch ( i->first )
177  {
178  case 'X':
179  setEpoch( gnsstk::StringUtils::asInt( i->second ) );
180  break;
181  case 'O':
182  week = gnsstk::StringUtils::asInt( i->second );
183  break;
184  case 'o':
185  setModWeek( gnsstk::StringUtils::asInt( i->second ) );
186  break;
187  case 'w':
188  sow = static_cast<double>(gnsstk::StringUtils::asInt(i->second))*SEC_PER_DAY;
189  break;
190  case 'g':
191  sow = gnsstk::StringUtils::asDouble( i->second );
192  break;
193  case 'P':
195  break;
196  default:
197  // do nothing
198  break;
199  };
200 
201  } // end of for loop
202 
203  return true;
204  }
205 
206  }; // end class IRNWeekSecond
207 
209 
210 } // namespace
211 
212 #endif // GNSSTK_IRNWEEKSECOND_HPP
gnsstk::TimeTag::getFormatPrefixInt
static std::string getFormatPrefixInt()
Definition: TimeTag.hpp:152
gnsstk::IRNWeekSecond::setFromInfo
bool setFromInfo(const IdToValue &info)
Definition: IRNWeekSecond.hpp:170
gnsstk::IRNWeekSecond::MJDEpoch
long MJDEpoch(void) const
Return the Modified Julian Date (MJD) of epoch for this system.
Definition: IRNWeekSecond.hpp:94
gnsstk::StringUtils::asInt
long asInt(const std::string &s)
Definition: StringUtils.hpp:713
gnsstk::IRNWeekSecond::getDefaultFormat
virtual std::string getDefaultFormat() const
Return a string containing the default format to use in printing.
Definition: IRNWeekSecond.hpp:108
gnsstk::IRN_EPOCH_MJD
const long IRN_EPOCH_MJD
Modified Julian Date of BDS epoch (Aug 22, 1999).
Definition: TimeConstants.hpp:128
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::IRNWeekSecond::~IRNWeekSecond
~IRNWeekSecond() noexcept
Destructor.
Definition: IRNWeekSecond.hpp:74
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::IRNWeekSecond::getPrintChars
virtual std::string getPrintChars() const
Definition: IRNWeekSecond.hpp:102
gnsstk::StringUtils::asString
std::string asString(IonexStoreStrategy e)
Convert a IonexStoreStrategy to a whitespace-free string name.
Definition: IonexStoreStrategy.cpp:46
gnsstk::Week::setEpoch
virtual void setEpoch(unsigned int e)
Definition: Week.hpp:200
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
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::Week::setModWeek
virtual void setModWeek(unsigned int w)
Definition: Week.hpp:206
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::TimeSystem::IRN
@ IRN
IRNSS system Time.
gnsstk::CommonTime
Definition: CommonTime.hpp:84
gnsstk::WeekSecond::sow
double sow
Definition: WeekSecond.hpp:155
gnsstk::IRNWeekSecond
Definition: IRNWeekSecond.hpp:56
gnsstk::IRNWeekSecond::Nbits
int Nbits(void) const
Definition: IRNWeekSecond.hpp:80
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::IRNWeekSecond::IRNWeekSecond
IRNWeekSecond(unsigned int w=0, double s=0., TimeSystem ts=TimeSystem::IRN)
Constructor.
Definition: IRNWeekSecond.hpp:61
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::IRNWeekSecond::bitmask
int bitmask(void) const
Return the bitmask used to get the ModWeek from the full week.
Definition: IRNWeekSecond.hpp:87
gnsstk::IRNWeekSecond::IRNWeekSecond
IRNWeekSecond(const CommonTime &right)
Constructor from CommonTime.
Definition: IRNWeekSecond.hpp:68
gnsstk::IRNWeekSecond::printf
virtual std::string printf(const std::string &fmt) const
Definition: IRNWeekSecond.hpp:115
gnsstk::Week::getModWeek
virtual unsigned int getModWeek() const
Definition: Week.hpp:183
gnsstk::IRNWeekSecond::printError
virtual std::string printError(const std::string &fmt) const
Definition: IRNWeekSecond.hpp:141


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