1 //==============================================================================
2 //
3 //  This file is part of GPSTk, the GPS Toolkit.
4 //
5 //  The GPSTk 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 GPSTk 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 GPSTk; 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-2020, 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 /**
40  * @file YumaData.hpp
41  * Encapsulate Yuma Almanac file data, including I/O
42  */
43 
44 #ifndef YUMADATA_HPP
45 #define YUMADATA_HPP
46 
47 #include <vector>
48 #include <list>
49 #include <map>
50 
51 #include "FFStream.hpp"
52 #include "AlmOrbit.hpp"
53 #include "OrbAlmGen.hpp"
54 #include "YumaBase.hpp"
55 #include "YumaHeader.hpp"
56 #include "StringUtils.hpp"
57 
58 namespace gpstk
59 {
60    /// @ingroup Yuma
61    //@{
62 
63       /**
64        * This class stores, reads, and writes Yuma records.
65        *
66        * @sa tests/Yuma for examples
67        * @sa YumaStream.
68        * @sa YumaHeader for information on writing Yuma files.
69        */
70    class YumaData : public YumaBase
71    {
72    public:
73          /// Constructor.
YumaData()74       YumaData() {}
75 
76          /// Destructor
~YumaData()77       virtual ~YumaData() {}
78 
79          /// This is is the nearest full GPS week to the 10-bit week
80          /// available in the SEM file.  If this value is 0 it is ignored.
81          /// Otherwise, the 10-bit week is moved into the GPS Epoch
82          /// centered on the given full week.
83       static short nearFullWeek;
84 
85       static const std::string sID;     // ID label string
86       static const std::string sHlth;   // Satellite Health string
87       static const std::string sEcc;    // Eccentricity string
88       static const std::string sTOA;
89       static const std::string sOrbI;
90       static const std::string sRRA;
91       static const std::string sSqrA;
92       static const std::string sRtAs;
93       static const std::string sArgP;
94       static const std::string sMnAn;
95       static const std::string sAf0;
96       static const std::string sAf1;
97       static const std::string sweek;
98 
99 
100       short PRN;
101       short week;
102       short SV_health;
103       double ecc;
104       long Toa;
105       double i_total;    //radians
106       double i_offset;   // radians from 54 degrees (to match IS-GPS-200)
107       double OMEGAdot;   // radians
108       double Ahalf;      // m**1/2
109       double OMEGA0;     // radians
110       double w;          // radians
111       double M0;         // radians
112       double AF0;        // s
113       double AF1;        // s/s
114       long xmit_time;
115 
116 
117          /**
118           * Debug output function.
119           * Dump the contents of each of the Yuma class to a
120           * given ostream \c s.
121           */
122       virtual void dump(std::ostream& s) const;
123 
124          //! This class is "data" so this function always returns "true".
isData() const125       virtual bool isData() const {return true;}
126 
127          /**
128           * cast *this into an AlmOrbit
129           * @return the constructed AlmOrbit object
130           */
131       operator AlmOrbit() const;
132 
133          /**
134           * cast *this into an OrbAlmGen
135           * @return the constructed OrbAlmGen object
136           */
137       operator OrbAlmGen() const;
138 
139    protected:
140 	 /**
141           * Writes a correctly formatted record from this data to stream \a s.
142           * @throw std::exception
143           * @throw FFStreamError
144           * @throw StringUtils::StringException
145           */
146       void reallyPutRecord(FFStream& s) const;
147 
148          /**
149           * This functions obtains a Yuma almanac record from the given
150           * FFStream.
151           * If there is an error in reading from the stream, it is reset
152           * to its original position and its fail-bit is set.
153           * @throw std::exception
154           * @throw StringException when a StringUtils function fails
155           * @throw FFStreamError when exceptions(failbit) is set and
156           *  a read or formatting error occurs.  This also resets the
157           *  stream to its pre-read position.
158           */
159       virtual void reallyGetRecord(FFStream& s);
160 
161          /**
162           * @throw FFStreamError
163           */
164       std::string lineParser(const std::string& line, const std::string& s)
165          const;
166 
167    }; // class YumaData
168 
169    //@}
170 
171 } // namespace
172 
173 #endif
174