1 #include <marnav/seatalk/message_00.hpp>
4 namespace marnav::seatalk
7 message_00::message_00()
12 std::unique_ptr
<message
> message_00::parse(const raw
& data
)
14 check_size(data
, SIZE
);
16 std::unique_ptr
<message
> result
= std::make_unique
<message_00
>();
17 auto & msg
= static_cast<message_00
&>(*result
);
19 const uint8_t flags
= data
[2];
20 msg
.anchor_alarm_active_
= (flags
& 0x80) != 0;
21 msg
.metric_display_units_
= (flags
& 0x40) != 0;
22 msg
.transducer_defective_
= (flags
& 0x04) != 0;
23 msg
.depth_alarm_active_
= (flags
& 0x02) != 0;
24 msg
.shallow_depth_alarm_active_
= (flags
& 0x01) != 0;
27 msg
.depth_
+= data
[4];
29 msg
.depth_
+= data
[3];
34 raw
message_00::get_data() const
38 flags
|= anchor_alarm_active_
? 0x80 : 0x00;
39 flags
|= metric_display_units_
? 0x40 : 0x00;
40 flags
|= transducer_defective_
? 0x04 : 0x00;
41 flags
|= depth_alarm_active_
? 0x02 : 0x00;
42 flags
|= shallow_depth_alarm_active_
? 0x01 : 0x00;
44 return raw
{static_cast<uint8_t>(ID
), 0x02, flags
,
45 static_cast<uint8_t>((depth_
>> 0) & 0xff), static_cast<uint8_t>((depth_
>> 8) & 0xff)};
48 double message_00::get_depth_meters() const noexcept
50 if (transducer_defective_
)
52 return (static_cast<double>(depth_
) / 10.0) / 3.2808;
55 void message_00::set_depth_meters(double t
) noexcept
60 depth_
= static_cast<uint16_t>(std::round(10.0 * (t
* 3.2808)));