SeaTalk: message 54 added.
[marnav.git] / src / marnav / seatalk / message_26.hpp
blob9293016407fecd79cf192065c9b6e7bf6f1613f5
1 #ifndef __SEATALK__MESSAGE_26__HPP__
2 #define __SEATALK__MESSAGE_26__HPP__
4 #include <marnav/seatalk/message.hpp>
6 namespace marnav
8 namespace seatalk
11 /// @brief Speed through water
12 ///
13 /// @code
14 /// 26 04 XX XX YY YY DE
15 ///
16 /// XXXX/100 Knots, sensor 1, current speed, valid if D & 4 == 4
17 /// YYYY/100 Knots, average speed (trip/time) if D & 8 == 0
18 /// or data from sensor 2 if D & 8 == 8
19 /// E & 1 == 1: Average speed calulation stopped
20 /// E & 2 == 2: Display value in MPH
21 /// @endcode
22 ///
23 /// Corresponding NMEA sentence: VHW
24 ///
25 class message_26 : public message
27 public:
28 constexpr static const message_id ID = message_id::speed_through_water_2;
30 message_26();
31 message_26(const message_26 &) = default;
32 message_26 & operator=(const message_26 &) = default;
34 virtual raw get_data() const override;
36 static std::unique_ptr<message> parse(const raw & data);
38 private:
39 uint16_t speed1;
40 uint16_t speed2;
41 uint8_t status;
43 public:
44 bool is_display_in_mph() const noexcept { return (status & 0x02) != 0; }
45 bool avg_speed_calc_stopped() const noexcept { return (status & 0x01) != 0; }
46 bool is_sensor1_valid() const noexcept { return (status & 0x40) != 0; }
47 bool is_avg_valid() const noexcept { return (status & 0x80) == 0; }
48 bool is_sensor2_valid() const noexcept { return (status & 0x80) != 0; }
50 double get_speed1() const noexcept;
51 double get_speed2() const noexcept;
53 void set_display_in_mph(bool t) noexcept;
54 void set_avg_speed_calc_stopped(bool t) noexcept;
55 void set_sensor1_valid(bool t) noexcept;
56 void set_avg_valid() noexcept { status &= ~0x80; }
57 void set_sensor2_valid() noexcept { status |= 0x80; }
59 void set_speed1(double t) noexcept;
60 void set_speed2(double t) noexcept;
65 #endif