NMEA: detectio of the optional tag block in front of a sentence, ignoring it for...
[marnav.git] / src / marnav / nmea / mwv.hpp
blobba92fdca77956eb37a180f5dac3ae85d9849db03
1 #ifndef __MARNAV__NMEA__MWV__HPP__
2 #define __MARNAV__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 mwv();
44 mwv(const mwv &) = default;
45 mwv & operator=(const mwv &) = default;
46 mwv(mwv &&) = default;
47 mwv & operator=(mwv &&) = default;
49 protected:
50 mwv(talker talk, 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 decltype(angle) get_angle() const { return angle; }
62 decltype(angle_ref) get_angle_ref() const { return angle_ref; }
63 decltype(speed) get_speed() const { return speed; }
64 decltype(speed_unit) get_speed_unit() const { return speed_unit; }
65 decltype(data_valid) get_data_valid() const { return 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