NMEA: Qt example extended.
[marnav.git] / src / marnav / nmea / mwv.hpp
blob3a658a292ca950701bf98ae29746f39994b716ed
1 #ifndef __NMEA__MWV__HPP__
2 #define __NMEA__MWV__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(mwv)
13 /// @brief MWV - Wind Speed and Angle
14 ///
15 /// @code
16 /// 1 2 3 4 5
17 /// | | | | |
18 /// $--MWV,x.x,a,x.x,a,a*hh<CR><LF>
19 /// @endcode
20 ///
21 /// Field Number:
22 /// 1. Wind Angle, 0 to 360 degrees
23 /// 2. Wind Angle Reference
24 /// - R = Relative
25 /// - T = True
26 /// 3. Wind Speed
27 /// 4. Wind Speed Unit
28 /// - K
29 /// - M
30 /// - N
31 /// 5. Status
32 /// - A = Data Valid
33 // - V = Invalid
34 ///
35 class mwv : public sentence
37 MARNAV_NMEA_SENTENCE_FRIENDS(mwv)
39 public:
40 constexpr static const sentence_id ID = sentence_id::MWV;
41 constexpr static const char * TAG = "MWV";
43 virtual ~mwv() {}
45 mwv();
46 mwv(const mwv &) = default;
47 mwv & operator=(const mwv &) = default;
49 protected:
50 mwv(const std::string & talker, fields::const_iterator first, fields::const_iterator last);
51 virtual std::vector<std::string> get_data() const override;
53 private:
54 utils::optional<double> angle; // wind angle, 0..359 right of bow
55 utils::optional<reference> angle_ref; // R:relative, T:true
56 utils::optional<double> speed; // wind speed
57 utils::optional<unit::velocity> speed_unit; // wind speed unit, K:knots, M:mph
58 utils::optional<status> data_valid; // status, A:valid
60 public:
61 NMEA_GETTER(angle)
62 NMEA_GETTER(angle_ref)
63 NMEA_GETTER(speed)
64 NMEA_GETTER(speed_unit)
65 NMEA_GETTER(data_valid)
67 void set_angle(double deg, reference ref);
68 void set_speed(double speed, unit::velocity u) noexcept;
69 void set_data_valid(status t) noexcept { data_valid = t; }
74 #endif