YumaNavDataFactory.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 //
28 // This software was developed by Applied Research Laboratories at the
29 // University of Texas at Austin, under contract to an agency or agencies
30 // within the U.S. Department of Defense. The U.S. Government retains all
31 // rights to use, duplicate, distribute, disclose, or release this software.
32 //
33 // Pursuant to DoD Directive 523024
34 //
35 // DISTRIBUTION STATEMENT A: This software has been approved for public
36 // release, distribution is unlimited.
37 //
38 //==============================================================================
39 #include "YumaNavDataFactory.hpp"
40 #include "YumaStream.hpp"
41 #include "YumaHeader.hpp"
42 #include "GPSLNavHealth.hpp"
43 #include "GPSWeekSecond.hpp"
45 
46 using namespace std;
47 
48 namespace gnsstk
49 {
50  YumaNavDataFactory ::
51  YumaNavDataFactory()
52  {
53  supportedSignals.insert(NavSignalID(SatelliteSystem::GPS,
55  TrackingCode::CA,
56  NavType::GPSLNAV));
57  }
58 
59 
60  bool YumaNavDataFactory ::
61  loadIntoMap(const std::string& filename, NavMessageMap& navMap,
62  NavNearMessageMap& navNearMap, OffsetCvtMap& ofsMap)
63  {
64  gnsstk::NavDataFactoryStoreCallback cb(this, navMap, navNearMap, ofsMap);
65  return process(filename, cb);
66  }
67 
68 
69  bool YumaNavDataFactory ::
70  process(const std::string& filename,
72  {
73  bool rv = true;
74  bool processAlm = (procNavTypes.count(NavMessageType::Almanac) > 0);
75  bool processHea = (procNavTypes.count(NavMessageType::Health) > 0);
79  bool gotdata = false;
80  try
81  {
82  YumaStream is(filename.c_str(), ios::in);
83  YumaData data;
84  if (!is)
85  return false;
86  while (is)
87  {
88  is >> data;
89  if (!is)
90  {
91  if (is.eof() && gotdata)
92  break;
93  else
94  return false; // some other error
95  }
96  gotdata = true;
97  NavDataPtr alm, health;
98  if (processAlm)
99  {
100  if (!convertToOrbit(data, alm))
101  return false;
102  }
103  if (processHea)
104  {
105  if (!convertToHealth(data, health))
106  return false;
107  }
108  // check the validity
109  bool check = false;
110  bool expect = false;
111  switch (navValidity)
112  {
113  case NavValidityType::ValidOnly:
114  check = true;
115  expect = true;
116  break;
117  case NavValidityType::InvalidOnly:
118  check = true;
119  expect = false;
120  break;
121  // Just treat everything else like All, which is to
122  // say, no checks.
123  default:
124  break;
125  }
126  if (check)
127  {
128  if (processAlm)
129  {
130  if (alm->validate() == expect)
131  {
132  if (!cb.process(alm))
133  return false;
134  }
135  }
136  if (processHea)
137  {
138  if (health->validate() == expect)
139  {
140  if (!cb.process(health))
141  return false;
142  }
143  }
144  }
145  else
146  {
147  if (processAlm)
148  {
149  if (!cb.process(alm))
150  return false;
151  }
152  if (processHea)
153  {
154  if (!cb.process(health))
155  return false;
156  }
157  }
158  }
159  }
160  catch (gnsstk::Exception& exc)
161  {
162  rv = false;
163  cerr << exc << endl;
164  }
165  catch (std::exception& exc)
166  {
167  rv = false;
168  cerr << exc.what() << endl;
169  }
170  catch (...)
171  {
172  rv = false;
173  cerr << "Unknown exception" << endl;
174  }
175  return rv;
176  }
177 
178 
179  std::string YumaNavDataFactory ::
180  getFactoryFormats() const
181  {
182  if (procNavTypes.empty() ||
183  (procNavTypes.count(NavMessageType::Almanac) > 0) ||
184  (procNavTypes.count(NavMessageType::Health) > 0))
185  {
186  return "Yuma";
187  }
188  return "";
189  }
190 
191 
192  bool YumaNavDataFactory ::
193  convertToOrbit(const YumaData& navIn, NavDataPtr& navOut)
194  {
195  bool rv = true;
196  GPSLNavAlm *gps;
197  navOut = std::make_shared<GPSLNavAlm>();
198  gps = dynamic_cast<GPSLNavAlm*>(navOut.get());
199  // NavData
200  fillNavData(navIn, navOut);
201  // OrbitDataKepler
202  gps->Toe = GPSWeekSecond(navIn.week, navIn.Toa);
203  // Toc, which is used to generate the clock corrections
204  // using af0 and af1, is the same as Toa in the almanac
205  // context.
206  gps->Toc = gps->Toe;
207  gps->fixFit();
208  // Transmit time is set to beginFit so that User-type
209  // searches will work. YumaData has a xmit_time field
210  // but it's always set to 0. Not sure why it's even
211  // there.
212  gps->xmitTime = gps->beginFit;
213  gps->timeStamp = gps->xmitTime;
214  gps->health = ((navIn.SV_health == 0) ? SVHealth::Healthy :
215  SVHealth::Unhealthy);
216  // not in almanac data.
217  gps->Cuc = 0.0;
218  gps->Cus = 0.0;
219  gps->Crc = 0.0;
220  gps->Crs = 0.0;
221  gps->Cic = 0.0;
222  gps->Cis = 0.0;
223  gps->M0 = navIn.M0;
224  gps->dn = 0.0;
225  gps->dndot = 0.0; // no dndot in Yuma or in GPS LNav
226  gps->ecc = navIn.ecc;
227  gps->Ahalf = navIn.Ahalf;
228  gps->A = navIn.Ahalf * navIn.Ahalf;
229  gps->Adot = 0.0; // no Adot in Yuma or in GPS LNav
230  gps->OMEGA0 = navIn.OMEGA0;
231  gps->i0 = navIn.i_total;
232  gps->w = navIn.w;
233  gps->OMEGAdot = navIn.OMEGAdot;
234  gps->idot = navIn.i_offset;
235  gps->af0 = navIn.AF0;
236  gps->af1 = navIn.AF1;
237  gps->af2 = 0.0;
238  gps->tlm = 0; // tlm not available in Yuma nav
239  return rv;
240  }
241 
242 
243  bool YumaNavDataFactory ::
244  convertToHealth(const YumaData& navIn, NavDataPtr& healthOut)
245  {
246  bool rv = true;
247  GPSLNavHealth *gps;
248  healthOut = std::make_shared<GPSLNavHealth>();
249  gps = dynamic_cast<GPSLNavHealth*>(healthOut.get());
250  // NavData
251  fillNavData(navIn, healthOut);
252  // manipulate a time stamp to mirror convertToOrbit
253  gps->timeStamp = GPSWeekSecond(navIn.week, navIn.Toa);
254  gps->timeStamp -= (70 * 3600.0);
255  // GPSLNavHealth
256  gps->svHealth = navIn.SV_health;
257  return rv;
258  }
259 
260 
261  void YumaNavDataFactory ::
262  fillNavData(const YumaData& navIn, NavDataPtr& navOut)
263  {
264  // NavData
265  // Yuma isn't really transmitted, so we set the sats the same
266  navOut->signal.sat = SatID(navIn.PRN,SatelliteSystem::GPS);
267  navOut->signal.xmitSat = SatID(navIn.PRN,SatelliteSystem::GPS);
268  navOut->signal.system = SatelliteSystem::GPS;
269  // we can't obtain these from Yuma nav, so just assume L1 C/A
270  navOut->signal.obs = ObsID(ObservationType::NavMsg, CarrierBand::L1,
271  TrackingCode::CA);
272  navOut->signal.nav = NavType::GPSLNAV;
273  }
274 }
gnsstk::NavDataPtr
std::shared_ptr< NavData > NavDataPtr
Factories instantiate these in response to find() requests.
Definition: NavData.hpp:62
gnsstk::OrbitDataKepler::idot
double idot
Rate of inclination angle (rad/sec)
Definition: OrbitDataKepler.hpp:193
gnsstk::GPSLNavHealth::svHealth
uint8_t svHealth
6-bit or 8-bit health.
Definition: GPSLNavHealth.hpp:80
gnsstk::NavDataFactoryCallback::process
virtual bool process(const NavDataPtr &navOut)
Definition: NavDataFactoryCallback.hpp:60
gnsstk::OrbitDataKepler::Cis
double Cis
Sine inclination (rad)
Definition: OrbitDataKepler.hpp:180
gnsstk::OrbitDataKepler::A
double A
Semi-major axis (m)
Definition: OrbitDataKepler.hpp:186
L1
gnsstk::Matrix< double > L1
Definition: Matrix_LUDecomp_T.cpp:46
gnsstk::OrbitDataKepler::af2
double af2
SV clock drift rate (sec/sec**2)
Definition: OrbitDataKepler.hpp:197
gnsstk::NavDataFactoryWithStore::OffsetCvtMap
std::map< TimeCvtKey, OffsetEpochMap > OffsetCvtMap
Map from the time system conversion pair to the conversion objects.
Definition: NavDataFactoryWithStore.hpp:74
gnsstk::NavMessageMap
std::map< NavMessageType, NavSatMap > NavMessageMap
Map nav message type to the rest of the storage.
Definition: NavData.hpp:71
gnsstk::YumaData::OMEGAdot
double OMEGAdot
Definition: YumaData.hpp:107
gnsstk::OrbitDataKepler::ecc
double ecc
Eccentricity.
Definition: OrbitDataKepler.hpp:185
NavDataFactoryStoreCallback.hpp
gnsstk::OrbitDataKepler::OMEGAdot
double OMEGAdot
Rate of Rt ascension (rad/sec)
Definition: OrbitDataKepler.hpp:192
gnsstk::Exception::what
std::string what() const
Dump to a string.
Definition: Exception.cpp:193
gnsstk::YumaData::PRN
short PRN
Definition: YumaData.hpp:100
gnsstk::SatID
Definition: SatID.hpp:89
gnsstk::OrbitDataKepler::Cuc
double Cuc
Cosine latitude (rad)
Definition: OrbitDataKepler.hpp:175
GPSLNavHealth.hpp
gnsstk::YumaData::AF0
double AF0
Definition: YumaData.hpp:112
gnsstk::YumaData::i_offset
double i_offset
Definition: YumaData.hpp:106
gnsstk::GPSLNavData::tlm
uint32_t tlm
The TLM message from word 1 of the subframe.
Definition: GPSLNavData.hpp:81
gnsstk::OrbitDataKepler::w
double w
Argument of perigee (rad)
Definition: OrbitDataKepler.hpp:191
gnsstk::OrbitDataKepler::Toe
CommonTime Toe
Orbit epoch.
Definition: OrbitDataKepler.hpp:171
gnsstk::OrbitDataKepler::Crs
double Crs
Sine radius (m)
Definition: OrbitDataKepler.hpp:178
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
gnsstk::GPSWeekSecond
Definition: GPSWeekSecond.hpp:56
gnsstk::OrbitDataKepler::xmitTime
CommonTime xmitTime
Time of transmission of the start of the data.
Definition: OrbitDataKepler.hpp:170
gnsstk::NavData::timeStamp
CommonTime timeStamp
Definition: NavData.hpp:173
gnsstk::OrbitDataKepler::Adot
double Adot
Rate of semi-major axis (m/sec)
Definition: OrbitDataKepler.hpp:188
gnsstk::NavDataFactoryCallback
Definition: NavDataFactoryCallback.hpp:54
gnsstk::OrbitDataKepler::M0
double M0
Mean anomaly (rad)
Definition: OrbitDataKepler.hpp:182
gnsstk::Exception
Definition: Exception.hpp:151
gnsstk::NavDataFactoryStoreCallback
Definition: NavDataFactoryStoreCallback.hpp:52
YumaStream.hpp
gnsstk::OrbitDataKepler::dndot
double dndot
Rate of correction to mean motion (rad/sec/sec)
Definition: OrbitDataKepler.hpp:184
gnsstk::YumaData::AF1
double AF1
Definition: YumaData.hpp:113
gnsstk::OrbitDataKepler::Cus
double Cus
Sine latitude (rad)
Definition: OrbitDataKepler.hpp:176
gnsstk::YumaData::w
double w
Definition: YumaData.hpp:110
gnsstk::YumaData::SV_health
short SV_health
Definition: YumaData.hpp:102
gnsstk::ObsID
Definition: ObsID.hpp:82
gnsstk::OrbitDataKepler::Ahalf
double Ahalf
Square Root of semi-major axis (m**.5)
Definition: OrbitDataKepler.hpp:187
gnsstk::YumaData
Definition: YumaData.hpp:70
gnsstk::OrbitDataKepler::Toc
CommonTime Toc
Clock epoch.
Definition: OrbitDataKepler.hpp:172
gnsstk::YumaData::week
short week
Definition: YumaData.hpp:101
gnsstk::NavFit::beginFit
CommonTime beginFit
Time at beginning of fit interval.
Definition: NavFit.hpp:54
gnsstk::YumaData::M0
double M0
Definition: YumaData.hpp:111
gnsstk::YumaStream
Definition: YumaStream.hpp:65
gnsstk::YumaData::i_total
double i_total
Definition: YumaData.hpp:105
gnsstk::GPSLNavAlm::fixFit
void fixFit()
Fill the beginFit and endFit values for this object.
Definition: GPSLNavAlm.cpp:65
gnsstk::YumaData::ecc
double ecc
Definition: YumaData.hpp:103
gnsstk::YumaData::Ahalf
double Ahalf
Definition: YumaData.hpp:108
gnsstk::OrbitDataKepler::i0
double i0
Inclination (rad)
Definition: OrbitDataKepler.hpp:190
example3.data
data
Definition: example3.py:22
gnsstk::OrbitDataKepler::Cic
double Cic
Cosine inclination (rad)
Definition: OrbitDataKepler.hpp:179
gnsstk::OrbitDataKepler::Crc
double Crc
Cosine radius (m)
Definition: OrbitDataKepler.hpp:177
gnsstk::NavSignalID
Class used to identify navigation data signal types.
Definition: NavSignalID.hpp:54
GPSWeekSecond.hpp
std
Definition: Angle.hpp:142
gnsstk::OrbitDataKepler::af0
double af0
SV clock error (sec)
Definition: OrbitDataKepler.hpp:195
YumaHeader.hpp
YumaNavDataFactory.hpp
gnsstk::YumaData::OMEGA0
double OMEGA0
Definition: YumaData.hpp:109
gnsstk::OrbitDataKepler::health
SVHealth health
SV health status.
Definition: OrbitDataKepler.hpp:173
gnsstk::NavNearMessageMap
std::map< NavMessageType, NavNearSatMap > NavNearMessageMap
Map nav message type to the rest of the storage.
Definition: NavData.hpp:81
gnsstk::OrbitDataKepler::OMEGA0
double OMEGA0
Longitude of ascending node at weekly epoch (rad)
Definition: OrbitDataKepler.hpp:189
gnsstk::YumaData::Toa
long Toa
Definition: YumaData.hpp:104
gnsstk::GPSLNavAlm
Class containing data elements unique to GPS LNav almanac pages.
Definition: GPSLNavAlm.hpp:50
gnsstk::OrbitDataKepler::af1
double af1
SV clock drift (sec/sec)
Definition: OrbitDataKepler.hpp:196
gnsstk::OrbitDataKepler::dn
double dn
Correction to mean motion (rad/sec)
Definition: OrbitDataKepler.hpp:183
gnsstk::GPSLNavHealth
Definition: GPSLNavHealth.hpp:51


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