NMEA: detectio of the optional tag block in front of a sentence, ignoring it for...
[marnav.git] / src / marnav / nmea / vpw.hpp
blob9153777ee82c76165ccf8408e0eea2afb2d6b454
1 #ifndef __MARNAV__NMEA__VPW__HPP__
2 #define __MARNAV__NMEA__VPW__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(vpw)
13 /// @brief VPW - Speed - Measured Parallel to Wind
14 ///
15 /// @code
16 /// 1 2 3 4
17 /// | | | |
18 /// $--VPW,x.x,N,x.x,M*hh<CR><LF>
19 /// @endcode
20 ///
21 /// Field Number:
22 ///
23 /// 1. Speed knots, "-" means downwind
24 /// 2. Speed knots unit
25 /// - N = Knots
26 /// 3. Speed meters per second, "-" means downwind
27 /// 4. Speed meters per second unit
28 /// - M = Meters per second
29 ///
30 class vpw : public sentence
32 MARNAV_NMEA_SENTENCE_FRIENDS(vpw)
34 public:
35 constexpr static const sentence_id ID = sentence_id::VPW;
36 constexpr static const char * TAG = "VPW";
38 vpw();
39 vpw(const vpw &) = default;
40 vpw & operator=(const vpw &) = default;
41 vpw(vpw &&) = default;
42 vpw & operator=(vpw &&) = default;
44 protected:
45 vpw(talker talk, fields::const_iterator first, fields::const_iterator last);
46 virtual std::vector<std::string> get_data() const override;
48 private:
49 utils::optional<double> speed_knots; // negative means downwind
50 utils::optional<unit::velocity> speed_knots_unit;
51 utils::optional<double> speed_meters_per_second; // negative means downwind
52 utils::optional<unit::velocity> speed_meters_per_second_unit;
54 public:
55 decltype(speed_knots) get_speed_knots() const { return speed_knots; }
56 decltype(speed_knots_unit) get_speed_knots_unit() const { return speed_knots_unit; }
57 decltype(speed_meters_per_second) get_speed_meters_per_second() const
59 return speed_meters_per_second;
61 decltype(speed_meters_per_second_unit) get_speed_meters_per_second_unit() const
63 return speed_meters_per_second_unit;
66 void set_speed_knots(double t) noexcept;
67 void set_speed_mps(double t) noexcept;
72 #endif