NMEA: detectio of the optional tag block in front of a sentence, ignoring it for...
[marnav.git] / src / marnav / nmea / grs.hpp
blobd44124f26fcc8cbfc28adb31572e07eefc764518
1 #ifndef __MARNAV__NMEA__GRS__HPP__
2 #define __MARNAV__NMEA__GRS__HPP__
4 #include <array>
5 #include <marnav/nmea/sentence.hpp>
6 #include <marnav/nmea/time.hpp>
7 #include <marnav/utils/optional.hpp>
9 namespace marnav
11 namespace nmea
13 MARNAV_NMEA_DECLARE_SENTENCE_PARSE_FUNC(grs)
15 /// @brief GRS - GPS Range Residuals
16 ///
17 /// @code
18 /// 1 2 3 4 5 6 7 8 9 10 11 12 13 14
19 /// | | | | | | | | | | | | | |
20 /// $--GRS,hhmmss.ss,m,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,*hh<CR><LF>
21 /// @endcode
22 ///
23 /// Field Number:
24 /// 1. UTC time of associated GGA fix
25 /// 2. 0 = Residuals used in GGA, 1 = residuals calculated after GGA
26 /// 3. Satellite 1 residual in meters
27 /// 4. Satellite 2 residual in meters
28 /// 5. Satellite 3 residual in meters
29 /// 6. Satellite 4 residual in meters (blank if unused)
30 /// 7. Satellite 5 residual in meters (blank if unused)
31 /// 8. Satellite 6 residual in meters (blank if unused)
32 /// 9. Satellite 7 residual in meters (blank if unused)
33 /// 10. Satellite 8 residual in meters (blank if unused)
34 /// 11. Satellite 9 residual in meters (blank if unused)
35 /// 12. Satellite 10 residual in meters (blank if unused)
36 /// 13. Satellite 11 residual in meters (blank if unused)
37 /// 14. Satellite 12 residual in meters (blank if unused)
38 ///
39 /// The order of satellites the same as those in the last GSA.
40 ///
41 class grs : public sentence
43 MARNAV_NMEA_SENTENCE_FRIENDS(grs)
45 public:
46 constexpr static const sentence_id ID = sentence_id::GRS;
47 constexpr static const char * TAG = "GRS";
49 constexpr static int num_satellite_residuals = 12;
51 enum class residual_usage : uint32_t {
52 used_in_gga, ///< NMEA representation: 0
53 calculated_after_gga, ///< NMEA representation: 1
56 grs();
57 grs(const grs &) = default;
58 grs & operator=(const grs &) = default;
59 grs(grs &&) = default;
60 grs & operator=(grs &&) = default;
62 protected:
63 grs(talker talk, fields::const_iterator first, fields::const_iterator last);
64 virtual std::vector<std::string> get_data() const override;
66 private:
67 nmea::time time_utc;
68 residual_usage usage;
69 std::array<utils::optional<double>, num_satellite_residuals> sat_residual;
71 void check_index(int index) const;
73 public:
74 decltype(time_utc) get_time_utc() const { return time_utc; }
75 decltype(usage) get_usage() const { return usage; }
76 utils::optional<double> get_sat_residual(int index) const;
78 void set_time_utc(const nmea::time & t) noexcept { time_utc = t; }
79 void set_usage(residual_usage t) noexcept { usage = t; }
80 void set_sat_residual(int index, double value);
83 std::string to_string(grs::residual_usage value);
87 #endif