SEMData.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 
44 #include "StringUtils.hpp"
45 #include "GNSSconstants.hpp"
46 
47 #include "SEMData.hpp"
48 #include "SEMStream.hpp"
49 
50 
51 using namespace gnsstk::StringUtils;
52 using namespace std;
53 
54 namespace gnsstk
55 {
57  : ecc(0, FFLead::Zero, 15, 4, 0, 'E', FFSign::NegSpace),
58  i_offset(0, FFLead::Zero, 15, 4, 0, 'E', FFSign::NegSpace),
59  OMEGAdot(0, FFLead::Zero, 15, 4, 0, 'E', FFSign::NegSpace),
60  Ahalf(0, FFLead::Zero, 15, 4, 0, 'E', FFSign::NegSpace),
61  OMEGA0(0, FFLead::Zero, 15, 4, 0, 'E', FFSign::NegSpace),
62  w(0, FFLead::Zero, 15, 4, 0, 'E', FFSign::NegSpace),
63  M0(0, FFLead::Zero, 15, 4, 0, 'E', FFSign::NegSpace),
64  AF0(0, FFLead::Zero, 15, 4, 0, 'E', FFSign::NegSpace),
65  AF1(0, FFLead::Zero, 15, 4, 0, 'E', FFSign::NegSpace)
66  {
67  }
68 
69 
71  {
72  string line;
73 
74  SEMStream& strm = dynamic_cast<SEMStream&>(ffs);
75 
76  //First output blank line to mark between records
77  strm << std::endl;
78 
79  //PRN output
80  strm << asString<short>(PRN) << endl;
81 
82  //SVNnum
83  strm << asString<short>(SVNnum) << endl;
84 
85  //URAnum
86  strm << asString<short>(URAnum) << endl;
87 
88  //Ecc, i_offset, OMEGAdot
89  strm << ecc << " " << (i_offset / gnsstk::PI) << " "
90  << (OMEGAdot / gnsstk::PI) << endl;
91 
92  //Ahalf, OMEGA0, w
93  strm << Ahalf << " " << (OMEGA0/gnsstk::PI) << " " << (w/gnsstk::PI)
94  << endl;
95 
96  //M0, AF0, AF1
97  strm << (M0/gnsstk::PI) << " " << AF0 << " " << AF1 << endl;
98 
99  //SV_health
100  strm << asString<short>(SV_health) << endl;
101 
102  //satConfig
103  strm << asString<short>(satConfig) << endl;
104 
105 
106  } // end SEMData::reallyPutRecord
107 
108 
110  {
111  string line;
112 
113  SEMStream& strm = dynamic_cast<SEMStream&>(ffs);
114 
115  //if(!strm.headerRead)
116  // strm >> strm.header;
117 
118  SEMHeader& hdr = strm.header;
119 
120  //Don't need first line - empty space
121  strm.formattedGetLine(line, true);
122 
123  // Second line - PRN
124  strm.formattedGetLine(line, true);
125  PRN = asInt(line);
126 
127  // Third line - SVN Number
128  // HACKHACKHACK This information might not be here??? Find out more info
129  strm.formattedGetLine(line, true);
130  SVNnum = (short) asInt(line);
131 
132  // Fourth line - Average URA Number as defined in ICD-GPS-200
133  strm.formattedGetLine(line, true);
134  URAnum = (short) asInt(line);
135 
136  string whitespace = " \t\r\n";
137 
138  // Fifth line - Eccentricity, Inclination Offset, and Rate of Right Ascension
139  strm.formattedGetLine(line, true);
140  string::size_type front = line.find_first_not_of(whitespace);
141  string::size_type end = line.find_first_of(whitespace,front);
142  string::size_type length = end - front;
143  ecc = line.substr(front,length);
144 
145  front = line.find_first_not_of(whitespace,end);
146  end = line.find_first_of(whitespace,front);
147  length = end - front;
148  i_offset = line.substr(front,length);
149  // Per ICD-GPS-240, i_offset is given relative to a fixed 0.3 semicircle offset.
150  i_total = i_offset + 0.3;
151 
152  front = line.find_first_not_of(whitespace,end);
153  length = line.length() - front;
154  OMEGAdot = line.substr(front,length);
155  // Convert from semicircles to radians.
156  i_offset *= gnsstk::PI;
157  i_total *= gnsstk::PI;
158  OMEGAdot *= gnsstk::PI;
159 
160  // Sixth line - Sqrt of A, Omega0, and Arg of Perigee
161  strm.formattedGetLine(line, true);
162 
163  front = line.find_first_not_of(whitespace);
164  end = line.find_first_of(whitespace,front);
165  length = end - front;
166  Ahalf = line.substr(front,length);
167 
168  front = line.find_first_not_of(whitespace,end);
169  end = line.find_first_of(whitespace,front);
170  length = end - front;
171  OMEGA0 = line.substr(front,length);
172 
173  front = line.find_first_not_of(whitespace,end);
174  length = line.length() - front;
175  OMEGA0 *= gnsstk::PI;
176  w = line.substr(front,length);
177  w *= gnsstk::PI;
178 
179  // Seventh Line - M0, AF0, AF1
180  strm.formattedGetLine(line, true);
181 
182  front = line.find_first_not_of(whitespace);
183  end = line.find_first_of(whitespace,front);
184  length = end - front;
185  M0 = line.substr(front,length);
186  M0 *= gnsstk::PI;
187 
188  front = line.find_first_not_of(whitespace,end);
189  end = line.find_first_of(whitespace,front);
190  length = end - front;
191  AF0 = line.substr(front,length);
192 
193  front = line.find_first_not_of(whitespace,end);
194  length = line.length() - front;
195  AF1 = line.substr(front,length);
196 
197  // Eigth line - Satellite Health
198  strm.formattedGetLine(line, true);
199  SV_health = (short) asInt(line);
200 
201  // Ninth line - Satellite Config
202  strm.formattedGetLine(line, true);
203  satConfig = (short) asInt(line);
204 
205  week = hdr.week;
206  Toa = hdr.Toa;
207 
208  xmit_time = 0;
209 
210  } // end of reallyGetRecord()
211 
212  void SEMData::dump(ostream& s) const
213  {
214  s << "PRN = " << PRN << std::endl;
215  s << "SVNnum = " << SVNnum << std::endl;
216  s << "URAnum = " << URAnum << std::endl;
217  s << "ecc = " << ecc << std::endl;
218  s << "i_offset = " << i_offset << std::endl;
219  s << "OMEGAdot = " << OMEGAdot << std::endl;
220  s << "Ahalf = " << Ahalf << std::endl;
221  s << "OMEGA0 = " << OMEGA0 << std::endl;
222  s << "w = " << w << std::endl;
223  s << "M0 = " << M0 << std::endl;
224  s << "AF0 = " << AF0 << std::endl;
225  s << "AF1 = " << AF1 << std::endl;
226  s << "SV_health = " << SV_health << std::endl;
227  s << "satConfig = " << satConfig << std::endl;
228  s << "xmit_time = " << xmit_time << std::endl;
229  s << "week = " << week << std::endl;
230  s << "toa = " << Toa << std::endl;
231  }
232 
233  SEMData::operator AlmOrbit() const
234  {
235 
236  AlmOrbit ao(PRN, ecc,i_offset, OMEGAdot, Ahalf, OMEGA0,
237  w, M0, AF0, AF1, Toa, xmit_time, week, SV_health);
238 
239  return ao;
240  }
241 
242 
243 } // namespace
gnsstk::StringUtils::asInt
long asInt(const std::string &s)
Definition: StringUtils.hpp:713
gnsstk::SEMData::AF1
FormattedDouble AF1
sec/sec
Definition: SEMData.hpp:96
gnsstk::SEMData::i_offset
FormattedDouble i_offset
redians
Definition: SEMData.hpp:88
gnsstk::FFStream
Definition: FFStream.hpp:119
gnsstk::SEMData::week
short week
Definition: SEMData.hpp:103
StringUtils.hpp
gnsstk::FFTextStream::formattedGetLine
void formattedGetLine(std::string &line, const bool expectEOF=false)
Definition: FFTextStream.cpp:149
gnsstk::SEMStream
Definition: SEMStream.hpp:68
gnsstk::SEMData::w
FormattedDouble w
radians
Definition: SEMData.hpp:93
gnsstk::SEMData::PRN
short PRN
Definition: SEMData.hpp:84
gnsstk::SEMData::ecc
FormattedDouble ecc
no units
Definition: SEMData.hpp:87
gnsstk::SEMData::AF0
FormattedDouble AF0
sec
Definition: SEMData.hpp:95
gnsstk::PI
const double PI
GPS value of PI; also specified by GAL.
Definition: GNSSconstants.hpp:62
GNSSconstants.hpp
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
gnsstk::StringUtils::FFLead
FFLead
Leading character for floatFormat(), after any whitespace or sign.
Definition: StringUtils.hpp:109
gnsstk::SEMHeader
Definition: SEMHeader.hpp:72
gnsstk::SEMData::xmit_time
long xmit_time
Definition: SEMData.hpp:100
gnsstk::SEMData::SVNnum
short SVNnum
SVN.
Definition: SEMData.hpp:85
gnsstk::StringUtils::FFLead::Zero
@ Zero
Start with zero, e.g. 0.12345.
gnsstk::StringUtils::FFSign::NegSpace
@ NegSpace
Prefix output with a minus sign (neg) or space (pos)
gnsstk::SEMData::OMEGAdot
FormattedDouble OMEGAdot
redians
Definition: SEMData.hpp:90
gnsstk::SEMData::reallyGetRecord
virtual void reallyGetRecord(FFStream &s)
Definition: SEMData.cpp:109
gnsstk::SEMData::URAnum
short URAnum
"Avg" URA index over unknown period
Definition: SEMData.hpp:86
gnsstk::SEMData::i_total
double i_total
radians
Definition: SEMData.hpp:89
gnsstk::SEMData::Ahalf
FormattedDouble Ahalf
m**0.5
Definition: SEMData.hpp:91
gnsstk::SEMData::M0
FormattedDouble M0
radians
Definition: SEMData.hpp:94
gnsstk::SEMData::Toa
long Toa
Definition: SEMData.hpp:102
SEMData.hpp
gnsstk::SEMData::SV_health
short SV_health
Definition: SEMData.hpp:97
gnsstk::StringUtils
Definition: IonexStoreStrategy.cpp:44
gnsstk::SEMData::satConfig
short satConfig
Definition: SEMData.hpp:98
std
Definition: Angle.hpp:142
SEMStream.hpp
gnsstk::SEMHeader::week
short week
Definition: SEMHeader.hpp:89
gnsstk::StringUtils::FFSign
FFSign
How to handle sign in floatFormat()
Definition: StringUtils.hpp:117
gnsstk::SEMData::reallyPutRecord
virtual void reallyPutRecord(FFStream &s) const
Definition: SEMData.cpp:70
gnsstk::SEMData::OMEGA0
FormattedDouble OMEGA0
radians
Definition: SEMData.hpp:92
gnsstk::SEMStream::header
SEMHeader header
SEMHeader for this file.
Definition: SEMStream.hpp:96
gnsstk::SEMHeader::Toa
long Toa
Definition: SEMHeader.hpp:90
gnsstk::SEMData::dump
virtual void dump(std::ostream &s) const
Definition: SEMData.cpp:212
gnsstk::SEMData::SEMData
SEMData()
Constructor.
Definition: SEMData.cpp:56
gnsstk::AlmOrbit
Definition: AlmOrbit.hpp:59


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