AshtechPBEN.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 // 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 
39 #include "StringUtils.hpp"
40 #include "BinUtils.hpp"
41 
42 #include "AshtechPBEN.hpp"
43 #include "AshtechStream.hpp"
44 #include "TimeConstants.hpp"
45 
46 using namespace std;
47 
48 namespace gnsstk
49  {
50  const char* AshtechPBEN::myId = "PBN";
51 
52  //---------------------------------------------------------------------------
53  void AshtechPBEN::reallyGetRecord(FFStream& ffs)
54  {
55  AshtechStream& stream=dynamic_cast<AshtechStream&>(ffs);
56 
57  // make sure the object is reset before starting the search
58  clear(fmtbit | lenbit | crcbit);
59  string& rawData = stream.rawData;
60 
61  // If this object doesn't have an id set yet, assume that the streams
62  // most recent read id is what we need to be
63  if (id == "" && rawData.size()>=11 &&
64  rawData.substr(0,7) == preamble &&
65  rawData[10]==',')
66  id = rawData.substr(7,3);
67 
68  // If that didn't work, or this is object is not of the right type,
69  // then give up.
70  if (id == "" || !checkId(id))
71  return;
72 
73  readBody(stream);
74  }
75 
76  //---------------------------------------------------------------------------
77  void AshtechPBEN::decode(const std::string& data)
78  {
80 
81  string str(data);
82  if (str.length() == 69)
83  {
84  ascii=false;
85  header = str.substr(0,11); str.erase(0,11);
86  sow = 1e-3 * decodeVar<int32_t>(str);
87  sitename = str.substr(0,4); str.erase(0,4);
88  navx = decodeVar<double>(str);
89  navy = decodeVar<double>(str);
90  navz = decodeVar<double>(str);
91  navt = decodeVar<float>(str);
92  navxdot = decodeVar<float>(str);
93  navydot = decodeVar<float>(str);
94  navzdot = decodeVar<float>(str);
95  navtdot = decodeVar<float>(str);
96  pdop = decodeVar<uint16_t>(str);
97  lat = lon = alt = numSV = hdop = vdop = tdop = 0;
98 
99  checksum = decodeVar<uint16_t>(str);
100  clear();
101 
102  uint16_t csum=0;
103  int len=data.size()-3-11;
104  string body(data.substr(11, len));
105  while (body.size()>1)
106  csum += decodeVar<uint16_t>(body);
107 
108  if (csum != checksum)
109  {
110  setstate(crcbit);
111  if (debugLevel)
112  cout << "checksum error, computed:" << hex << csum
113  << " received:" << checksum << dec << endl;
114  }
115 
116  }
117  else
118  {
119  ascii=true;
120  header = str.substr(0,11); str.erase(0,11);
121  stringstream iss(str);
122  double latMin,lonMin;
123  char c;
124  iss >> sow >> c
125  >> navx>> c >> navy >> c >> navz >> c
126  >> lat >> c >> latMin >> c >> lon >> c >> lonMin >> c >> alt >> c
127  >> navxdot>> c >> navydot>> c >> navzdot >> c
128  >> numSV >> c;
129  getline(iss, sitename, ',');
130  iss >> pdop>> c >> hdop>> c >> vdop>> c >> tdop;
131 
132  // Note that there isn't a checksum on the PBNs
133 
134  lat += latMin / 60;
135  lon += lonMin / 60;
136  navt = navtdot = 0;
137  if (iss)
138  clear();
139  }
140 
141  if (sow>FULLWEEK)
142  setstate(fmtbit);
143  }
144 
145  //---------------------------------------------------------------------------
146  void AshtechPBEN::dump(ostream& out) const noexcept
147  {
148  ostringstream oss;
151 
152  AshtechData::dump(out);
153  oss << getName() << "1:"
154  << " SOW:" << asString(sow, 1)
155  << " #SV:" << (int)numSV
156  << " PDOP:" << (int)pdop
157  << " ClkOff:" << asString(navt, 3)
158  << " ClkDft:" << asString(navtdot, 3)
159  << " sitename:" << sitename
160  << " " << (ascii?"ascii":"bin")
161  << endl
162  << getName() << "2:"
163  << " X:" << asString(navx, 1)
164  << " Y:" << asString(navy, 1)
165  << " Z:" << asString(navz, 1)
166  << " Vx:" << asString(navxdot, 3)
167  << " Vy:" << asString(navydot, 3)
168  << " Vz:" << asString(navzdot, 3)
169  << endl;
170  out << oss.str() << flush;
171  }
172 } // namespace gnsstk
gnsstk::dump
void dump(vector< SatPass > &SatPassList, ostream &os, bool rev, bool dbug)
Definition: SatPassUtilities.cpp:59
TimeConstants.hpp
example3.header
header
Definition: example3.py:22
gnsstk::lenbit
static const std::ios_base::iostate lenbit
Definition: DataStatus.hpp:88
gnsstk::FFStream
Definition: FFStream.hpp:119
StringUtils.hpp
gnsstk::FULLWEEK
const long FULLWEEK
Seconds per whole week.
Definition: TimeConstants.hpp:60
AshtechPBEN.hpp
gnsstk::crcbit
static const std::ios_base::iostate crcbit
Define additional/other bits are the data requires.
Definition: DataStatus.hpp:86
gnsstk::StringUtils::asString
std::string asString(IonexStoreStrategy e)
Convert a IonexStoreStrategy to a whitespace-free string name.
Definition: IonexStoreStrategy.cpp:46
gnsstk::fmtbit
static const std::ios_base::iostate fmtbit
Definition: DataStatus.hpp:87
AshtechStream.hpp
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
gnsstk::AshtechStream
Definition: AshtechStream.hpp:54
BinUtils.hpp
example3.data
data
Definition: example3.py:22
std
Definition: Angle.hpp:142
gnsstk::StringUtils::leftJustify
std::string & leftJustify(std::string &s, const std::string::size_type length, const char pad=' ')
Definition: StringUtils.hpp:1582
gnsstk::AshtechStream::rawData
std::string rawData
The raw bytes read from the file.
Definition: AshtechStream.hpp:78
gnsstk::BinUtils::decodeVar
T decodeVar(const std::string &str, std::string::size_type pos)
Definition: BinUtils.hpp:366


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