NMEA: detectio of the optional tag block in front of a sentence, ignoring it for...
[marnav.git] / src / marnav / nmea / vhw.hpp
blob3e9b37c0c4fedbeb249c7b8b3362e08060daf94c
1 #ifndef __MARNAV__NMEA__VHW__HPP__
2 #define __MARNAV__NMEA__VHW__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(vhw)
13 /// @brief VHW - Water speed and heading
14 ///
15 /// @code
16 /// 1 2 3 4 5 6 7 8
17 /// | | | | | | | |
18 /// $--VHW,x.x,T,x.x,M,x.x,N,x.x,K*hh<CR><LF>
19 /// @endcode
20 ///
21 /// Field Number:
22 /// 1. Degress True
23 /// 2. Degress True reference
24 /// - T = True
25 /// 3. Degrees Magnetic
26 /// 4. Degrees Magnetic reference
27 /// - M = Magnetic
28 /// 5. Knots (speed of vessel relative to the water)
29 /// 6. N = Knots
30 /// 7. Kilometers per hour (speed of vessel relative to the water)
31 /// 8. K = Kilometers per hour
32 ///
33 class vhw : public sentence
35 MARNAV_NMEA_SENTENCE_FRIENDS(vhw)
37 public:
38 constexpr static const sentence_id ID = sentence_id::VHW;
39 constexpr static const char * TAG = "VHW";
41 vhw();
42 vhw(const vhw &) = default;
43 vhw & operator=(const vhw &) = default;
44 vhw(vhw &&) = default;
45 vhw & operator=(vhw &&) = default;
47 protected:
48 vhw(talker talk, fields::const_iterator first, fields::const_iterator last);
49 virtual std::vector<std::string> get_data() const override;
51 private:
52 utils::optional<char> heading_empty; // heading (empty)
53 utils::optional<reference> degrees_true; // T:true
54 utils::optional<double> heading; // heading in degrees, 0..359
55 utils::optional<reference> degrees_mag; // M:magnetic
56 utils::optional<double> speed_knots; // speed in knots
57 utils::optional<unit::velocity> speed_knots_unit; // N:knots
58 utils::optional<double> speed_kmh; // speed in kilometers per hour
59 utils::optional<unit::velocity> speed_kmh_unit; // K:kmh
61 public:
62 decltype(heading_empty) get_heading_empty() const { return heading_empty; }
63 decltype(degrees_true) get_degrees_true() const { return degrees_true; }
64 decltype(heading) get_heading() const { return heading; }
65 decltype(degrees_mag) get_degrees_mag() const { return degrees_mag; }
66 decltype(speed_knots) get_speed_knots() const { return speed_knots; }
67 decltype(speed_knots_unit) get_speed_knots_unit() const { return speed_knots_unit; }
68 decltype(speed_kmh) get_speed_kmh() const { return speed_kmh; }
69 decltype(speed_kmh_unit) get_speed_kmh_unit() const { return speed_kmh_unit; }
71 void set_heading(double t) noexcept;
72 void set_speed_knots(double t) noexcept;
73 void set_speed_kmh(double t) noexcept;
78 #endif