NMEA: detectio of the optional tag block in front of a sentence, ignoring it for...
[marnav.git] / src / marnav / nmea / mwd.hpp
blob740e50891e3608d98a54b879b8161824f9647ea0
1 #ifndef __MARNAV__NMEA__MWD__HPP__
2 #define __MARNAV__NMEA__MWD__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(mwd)
13 /// @brief MWD - Wind Direction and Speed
14 ///
15 /// Wind Direction and Speed, with respect to north.
16 ///
17 /// @code
18 /// 1 2 3
19 /// | | |
20 /// $--MWD,x.x,T,x.x,M,x.x.,N,x.x,M*hh<CR><LF>
21 /// @endcode
22 ///
23 /// Field Number:
24 /// 1. Wind direction true in degrees (0.0 .. 359.9), resolution: 0.1 degree
25 /// 2. Reference of wind direction
26 /// - T = True
27 /// 3. Wind direction magnetic in degrees (0.0 .. 359.9), resolution: 0.1 degree
28 /// 4. Reference of wind direction
29 /// - M = Magnetic
30 /// 5. Wind speed in knots (resolution: 0.1 knots)
31 /// 6. Wind speed unit
32 /// - N = Knots
33 /// 7. Wind speed in meters per second (resolution: 0.1 m/s)
34 /// 8. Wind speed unit
35 /// - M = Meters per Second
36 ///
37 class mwd : public sentence
39 MARNAV_NMEA_SENTENCE_FRIENDS(mwd)
41 public:
42 constexpr static const sentence_id ID = sentence_id::MWD;
43 constexpr static const char * TAG = "MWD";
45 mwd();
46 mwd(const mwd &) = default;
47 mwd & operator=(const mwd &) = default;
48 mwd(mwd &&) = default;
49 mwd & operator=(mwd &&) = default;
51 protected:
52 mwd(talker talk, fields::const_iterator first, fields::const_iterator last);
53 virtual std::vector<std::string> get_data() const override;
55 private:
56 utils::optional<double> direction_true;
57 utils::optional<reference> direction_true_ref;
58 utils::optional<double> direction_mag;
59 utils::optional<reference> direction_mag_ref;
60 utils::optional<double> speed_kn;
61 utils::optional<unit::velocity> speed_kn_unit;
62 utils::optional<double> speed_ms;
63 utils::optional<unit::velocity> speed_ms_unit;
65 public:
66 decltype(direction_true) get_direction_true() const { return direction_true; }
67 decltype(direction_true_ref) get_direction_true_ref() const { return direction_true_ref; }
68 decltype(direction_mag) get_direction_mag() const { return direction_mag; }
69 decltype(direction_mag_ref) get_direction_mag_ref() const { return direction_mag_ref; }
70 decltype(speed_kn) get_speed_kn() const { return speed_kn; }
71 decltype(speed_kn_unit) get_speed_kn_unit() const { return speed_kn_unit; }
72 decltype(speed_ms) get_speed_ms() const { return speed_ms; }
73 decltype(speed_ms_unit) get_speed_ms_unit() const { return speed_ms_unit; }
75 void set_direction_true(double t) noexcept;
76 void set_direction_mag(double t) noexcept;
77 void set_speed_knots(double t) noexcept;
78 void set_speed_mps(double t) noexcept;
83 #endif