QZSWeekSecond.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 
40 
41 #ifndef GNSSTK_QZSWEEKSECOND_HPP
42 #define GNSSTK_QZSWEEKSECOND_HPP
43 
44 #include "WeekSecond.hpp"
45 
46 namespace gnsstk
47 {
49 
50 
56  class QZSWeekSecond : public WeekSecond
57  {
58  public:
59 
61  QZSWeekSecond(unsigned int w = 0,
62  double s = 0.,
64  : WeekSecond(w,s)
65  { timeSystem = ts; }
66 
68  QZSWeekSecond( const CommonTime& right )
69  {
70  convertFromCommonTime( right );
71  }
72 
75 
76 
79  int Nbits(void) const
80  {
81  static const int n=16;
82  return n;
83  }
84 
86  int bitmask(void) const
87  {
88  static const int bm=0xFFFF;
89  return bm;
90  }
91 
93  long MJDEpoch(void) const
94  {
95  static const long e=QZS_EPOCH_MJD;
96  return e;
97  }
98 
101  virtual std::string getPrintChars() const
102  {
103  return "VhiwgP";
104  }
105 
107  virtual std::string getDefaultFormat() const
108  {
109  return "%h %g %P";
110  }
111 
114  virtual std::string printf(const std::string& fmt) const
115  {
116  try {
118 
119  std::string rv = fmt;
120  rv = formattedPrint( rv, getFormatPrefixInt() + "V",
121  "Vu", getEpoch() );
122  rv = formattedPrint( rv, getFormatPrefixInt() + "h",
123  "hu", week );
124  rv = formattedPrint( rv, getFormatPrefixInt() + "i",
125  "iu", getModWeek() );
126  rv = formattedPrint( rv, getFormatPrefixInt() + "w",
127  "wu", getDayOfWeek() );
128  rv = formattedPrint( rv, getFormatPrefixFloat() + "g",
129  "gf", sow );
130  rv = formattedPrint( rv, getFormatPrefixInt() + "P",
131  "Ps", StringUtils::asString(timeSystem).c_str() );
132  return rv;
133  }
134  catch(gnsstk::StringUtils::StringException& e)
135  { GNSSTK_RETHROW(e); }
136  }
137 
140  virtual std::string printError(const std::string& fmt) const
141  {
142  try {
144  std::string rv = fmt;
145 
146  rv = formattedPrint( rv, getFormatPrefixInt() + "V",
147  "Vs", "BadQZSepoch");
148  rv = formattedPrint( rv, getFormatPrefixInt() + "h",
149  "hs", "BadQZSfweek");
150  rv = formattedPrint( rv, getFormatPrefixInt() + "i",
151  "is", "BadQZSmweek");
152  rv = formattedPrint( rv, getFormatPrefixInt() + "w",
153  "wu", "BadQZSdow");
154  rv = formattedPrint( rv, getFormatPrefixFloat() + "g",
155  "gf", "BadQZSsow");
156  rv = formattedPrint( rv, getFormatPrefixInt() + "P",
157  "Ps", "BadQZSsys");
158  return rv;
159  }
160  catch(gnsstk::StringUtils::StringException& e)
161  { GNSSTK_RETHROW(e); }
162  }
163 
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 'V':
177  setEpoch( gnsstk::StringUtils::asInt( i->second ) );
178  break;
179  case 'h':
180  week = gnsstk::StringUtils::asInt( i->second );
181  break;
182  case 'i':
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':
192  timeSystem = static_cast<TimeSystem>(gnsstk::StringUtils::asInt( i->second ));
193  break;
194  default:
195  // do nothing
196  break;
197  };
198 
199  } // end of for loop
200 
201  return true;
202  }
203 
204  }; // end class QZSWeekSecond
205 
207 
208 } // namespace
209 
210 #endif // GNSSTK_QZSWEEKSECOND_HPP
gnsstk::TimeTag::getFormatPrefixInt
static std::string getFormatPrefixInt()
Definition: TimeTag.hpp:152
gnsstk::QZSWeekSecond::bitmask
int bitmask(void) const
Return the bitmask used to get the ModWeek from the full week.
Definition: QZSWeekSecond.hpp:86
gnsstk::StringUtils::asInt
long asInt(const std::string &s)
Definition: StringUtils.hpp:713
gnsstk::QZSWeekSecond
Definition: QZSWeekSecond.hpp:56
gnsstk::Week::getEpoch
virtual unsigned int getEpoch() const
Definition: Week.hpp:188
gnsstk::QZSWeekSecond::printf
virtual std::string printf(const std::string &fmt) const
Definition: QZSWeekSecond.hpp:114
gnsstk::QZSWeekSecond::QZSWeekSecond
QZSWeekSecond(const CommonTime &right)
Constructor from CommonTime.
Definition: QZSWeekSecond.hpp:68
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::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::QZSWeekSecond::~QZSWeekSecond
~QZSWeekSecond()
Destructor.
Definition: QZSWeekSecond.hpp:74
gnsstk::QZSWeekSecond::Nbits
int Nbits(void) const
Definition: QZSWeekSecond.hpp:79
gnsstk::QZSWeekSecond::setFromInfo
bool setFromInfo(const IdToValue &info)
Definition: QZSWeekSecond.hpp:168
gnsstk::TimeTag::getFormatPrefixFloat
static std::string getFormatPrefixFloat()
Definition: TimeTag.hpp:157
gnsstk::TimeSystem::QZS
@ QZS
QZSS system Time.
gnsstk::QZSWeekSecond::QZSWeekSecond
QZSWeekSecond(unsigned int w=0, double s=0., TimeSystem ts=TimeSystem::QZS)
Constructor.
Definition: QZSWeekSecond.hpp:61
gnsstk::CommonTime
Definition: CommonTime.hpp:84
gnsstk::WeekSecond::sow
double sow
Definition: WeekSecond.hpp:155
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::QZSWeekSecond::MJDEpoch
long MJDEpoch(void) const
Return the Modified Julian Date (MJD) of epoch for this system.
Definition: QZSWeekSecond.hpp:93
gnsstk::QZS_EPOCH_MJD
const long QZS_EPOCH_MJD
Modified Julian Date of QZS epoch (Jan. 1, 1980).
Definition: TimeConstants.hpp:112
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::QZSWeekSecond::getDefaultFormat
virtual std::string getDefaultFormat() const
Return a string containing the default format to use in printing.
Definition: QZSWeekSecond.hpp:107
gnsstk::Week::getModWeek
virtual unsigned int getModWeek() const
Definition: Week.hpp:183
gnsstk::QZSWeekSecond::getPrintChars
virtual std::string getPrintChars() const
Definition: QZSWeekSecond.hpp:101
gnsstk::QZSWeekSecond::printError
virtual std::string printError(const std::string &fmt) const
Definition: QZSWeekSecond.hpp:140


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