BDSWeekSecond.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_BDSWEEKSECOND_HPP
43 #define GNSSTK_BDSWEEKSECOND_HPP
44 
45 #include "WeekSecond.hpp"
46 
47 namespace gnsstk
48 {
50 
51 
56  class BDSWeekSecond : public WeekSecond
57  {
58  public:
59 
61  BDSWeekSecond(unsigned int w = 0,
62  double s = 0.,
64  : WeekSecond(w,s)
65  { timeSystem = ts; }
66 
68  BDSWeekSecond( const CommonTime& right )
69  {
70  convertFromCommonTime( right );
71  }
72 
74  ~BDSWeekSecond() noexcept {}
75 
76  // the rest define the week rollover and starting time
77 
80  int Nbits(void) const
81  {
82  static const int n=13;
83  return n;
84  }
85 
87  int bitmask(void) const
88  {
89  static const int bm=0x1FFF;
90  return bm;
91  }
92 
94  long MJDEpoch(void) const
95  {
96  static const long e=BDS_EPOCH_MJD;
97  return e;
98  }
99 
102  virtual std::string getPrintChars() const
103  {
104  return "RDewgP";
105  }
106 
108  virtual std::string getDefaultFormat() const
109  {
110  return "%D %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() + "R",
122  "Ru", getEpoch() );
123  rv = formattedPrint( rv, getFormatPrefixInt() + "D",
124  "Du", week );
125  rv = formattedPrint( rv, getFormatPrefixInt() + "e",
126  "eu", 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() + "R",
148  "Rs", "BadBDSepoch");
149  rv = formattedPrint( rv, getFormatPrefixInt() + "D",
150  "Ds", "BadBDSfweek");
151  rv = formattedPrint( rv, getFormatPrefixInt() + "e",
152  "es", "BadBDSmweek");
153  rv = formattedPrint( rv, getFormatPrefixInt() + "w",
154  "wu", "BadBDSdow");
155  rv = formattedPrint( rv, getFormatPrefixFloat() + "g",
156  "gf", "BadBDSsow");
157  rv = formattedPrint( rv, getFormatPrefixInt() + "P",
158  "Ps", "BadBDSsys");
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 'R':
179  setEpoch( gnsstk::StringUtils::asInt( i->second ) );
180  break;
181  case 'D':
182  week = gnsstk::StringUtils::asInt( i->second );
183  break;
184  case 'e':
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 BDSWeekSecond
207 
209 
210 } // namespace
211 
212 #endif // GNSSTK_BDSWEEKSECOND_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::BDSWeekSecond::~BDSWeekSecond
~BDSWeekSecond() noexcept
Destructor.
Definition: BDSWeekSecond.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::BDSWeekSecond::printf
virtual std::string printf(const std::string &fmt) const
Definition: BDSWeekSecond.hpp:115
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::BDSWeekSecond::getPrintChars
virtual std::string getPrintChars() const
Definition: BDSWeekSecond.hpp:102
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
gnsstk::BDSWeekSecond::bitmask
int bitmask(void) const
Return the bitmask used to get the ModWeek from the full week.
Definition: BDSWeekSecond.hpp:87
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::BDSWeekSecond::MJDEpoch
long MJDEpoch(void) const
Return the Modified Julian Date (MJD) of epoch for this system.
Definition: BDSWeekSecond.hpp:94
gnsstk::Week::setModWeek
virtual void setModWeek(unsigned int w)
Definition: Week.hpp:206
gnsstk::BDSWeekSecond::BDSWeekSecond
BDSWeekSecond(unsigned int w=0, double s=0., TimeSystem ts=TimeSystem::BDT)
Constructor.
Definition: BDSWeekSecond.hpp:61
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::BDSWeekSecond::Nbits
int Nbits(void) const
Definition: BDSWeekSecond.hpp:80
gnsstk::BDSWeekSecond::getDefaultFormat
virtual std::string getDefaultFormat() const
Return a string containing the default format to use in printing.
Definition: BDSWeekSecond.hpp:108
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
gnsstk::BDSWeekSecond::BDSWeekSecond
BDSWeekSecond(const CommonTime &right)
Constructor from CommonTime.
Definition: BDSWeekSecond.hpp:68
WeekSecond.hpp
gnsstk::BDS_EPOCH_MJD
const long BDS_EPOCH_MJD
Modified Julian Date of BDS epoch (Jan. 1, 2006).
Definition: TimeConstants.hpp:120
gnsstk::BDSWeekSecond::setFromInfo
bool setFromInfo(const IdToValue &info)
Definition: BDSWeekSecond.hpp:170
gnsstk::BDSWeekSecond::printError
virtual std::string printError(const std::string &fmt) const
Definition: BDSWeekSecond.hpp:141
gnsstk::BDSWeekSecond
Definition: BDSWeekSecond.hpp:56
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::TimeSystem::BDT
@ BDT
BeiDou system Time.
gnsstk::Week::getModWeek
virtual unsigned int getModWeek() const
Definition: Week.hpp:183


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