NMEA: detectio of the optional tag block in front of a sentence, ignoring it for...
[marnav.git] / src / marnav / nmea / pgrmz.hpp
blobec0bd095445b9c243a0cde2367a3eca9ed17d721
1 #ifndef __MARNAV__NMEA__PGRMZ__HPP__
2 #define __MARNAV__NMEA__PGRMZ__HPP__
4 #include <marnav/nmea/sentence.hpp>
5 #include <marnav/utils/optional.hpp>
7 namespace marnav
9 namespace nmea
11 MARNAV_NMEA_DECLARE_SENTENCE_PARSE_FUNC(pgrmz)
13 /// @brief PGRMZ - Garmin Altitude Information
14 ///
15 /// @code
16 /// 1 2 3
17 /// | | |
18 /// $PGRMZ,x.x,f,h*hh<CR><LF>
19 /// @endcode
20 ///
21 /// Field Number:
22 ///
23 /// 1. Altitude
24 /// 2. f=feet
25 /// 3. Fix Type
26 /// - 1 = no fix
27 /// - 2 = 2D fix
28 /// - 3 = 3D fix
29 ///
30 /// Example: <tt>$PGRMZ,1494,f,*10</tt>
31 ///
32 class pgrmz : public sentence
34 MARNAV_NMEA_SENTENCE_FRIENDS(pgrmz)
36 public:
37 constexpr static const sentence_id ID = sentence_id::PGRMZ;
38 constexpr static const char * TAG = "PGRMZ";
40 enum class fix_type : char {
41 no_fix, ///< NMEA representation: '1'
42 d2fix, ///< NMEA representation: '2'
43 d3fix ///< NMEA representation: '3'
46 pgrmz();
47 pgrmz(const pgrmz &) = default;
48 pgrmz & operator=(const pgrmz &) = default;
49 pgrmz(pgrmz &&) = default;
50 pgrmz & operator=(pgrmz &&) = default;
52 protected:
53 pgrmz(talker talk, fields::const_iterator first, fields::const_iterator last);
54 virtual std::vector<std::string> get_data() const override;
56 private:
57 double altitude = 0.0;
58 unit::distance altitude_unit = unit::distance::feet;
59 utils::optional<fix_type> fix;
61 public:
62 decltype(altitude) get_altitude() const { return altitude; }
63 decltype(altitude_unit) get_altitude_unit() const { return altitude_unit; }
64 decltype(fix) get_fix() const { return fix; }
66 void set_altitude(double t) noexcept
68 altitude = t;
69 altitude_unit = unit::distance::feet;
71 void set_fix(fix_type t) noexcept { fix = t; }
74 std::string to_string(pgrmz::fix_type value);
78 #endif