1 #ifndef __MARNAV__NMEA__GRS__HPP__
2 #define __MARNAV__NMEA__GRS__HPP__
5 #include <marnav/nmea/sentence.hpp>
6 #include <marnav/nmea/time.hpp>
7 #include <marnav/utils/optional.hpp>
13 MARNAV_NMEA_DECLARE_SENTENCE_PARSE_FUNC(grs
)
15 /// @brief GRS - GPS Range Residuals
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>
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)
39 /// The order of satellites the same as those in the last GSA.
41 class grs
: public sentence
43 MARNAV_NMEA_SENTENCE_FRIENDS(grs
)
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
57 grs(const grs
&) = default;
58 grs
& operator=(const grs
&) = default;
59 grs(grs
&&) = default;
60 grs
& operator=(grs
&&) = default;
63 grs(talker talk
, fields::const_iterator first
, fields::const_iterator last
);
64 virtual std::vector
<std::string
> get_data() const override
;
69 std::array
<utils::optional
<double>, num_satellite_residuals
> sat_residual
;
71 void check_index(int index
) const;
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
);