Refactor: code duplication reduced for size check of seatalk messages
[marnav.git] / src / marnav / seatalk / message_20.hpp
blob70a28dc4b5636fa66d6e73a748e1d33c7e102881
1 #ifndef __SEATALK__MESSAGE_20__HPP__
2 #define __SEATALK__MESSAGE_20__HPP__
4 #include <marnav/seatalk/message.hpp>
6 namespace marnav
8 namespace seatalk
11 /// @brief Speed through water
12 ///
13 /// @code
14 /// 20 01 XX XX
15 ///
16 /// Speed through water: XXXX/10 Knots
17 /// @endcode
18 ///
19 /// Corresponding NMEA sentence: VHW
20 ///
21 class message_20 : public message
23 public:
24 constexpr static const message_id ID = message_id::speed_through_water;
25 constexpr static size_t SIZE = 4;
27 message_20();
28 message_20(const message_20 &) = default;
29 message_20 & operator=(const message_20 &) = default;
31 virtual raw get_data() const override;
33 static std::unique_ptr<message> parse(const raw & data);
35 private:
36 uint16_t speed; // speed in 1/10th of knots
38 public:
39 uint16_t get_speed() const noexcept { return speed; }
41 void set_speed(uint16_t t) noexcept { speed = t; }
46 #endif