1 #include "message_00.hpp"
8 message_00::message_00()
10 , anchor_alarm_active(false)
11 , metric_display_units(false)
12 , transducer_defective(false)
13 , depth_alarm_active(false)
14 , shallow_depth_alarm_active(false)
19 std::unique_ptr
<message
> message_00::parse(const raw
& data
)
22 throw std::invalid_argument
{"invalid number of bytes in message_00::parse"};
24 throw std::invalid_argument
{"invalid size specified in message"};
26 std::unique_ptr
<message
> result
= utils::make_unique
<message_00
>();
27 message_00
& msg
= static_cast<message_00
&>(*result
);
29 const uint8_t flags
= data
[2];
30 msg
.anchor_alarm_active
= (flags
& 0x80) != 0;
31 msg
.metric_display_units
= (flags
& 0x40) != 0;
32 msg
.transducer_defective
= (flags
& 0x04) != 0;
33 msg
.depth_alarm_active
= (flags
& 0x02) != 0;
34 msg
.shallow_depth_alarm_active
= (flags
& 0x01) != 0;
44 raw
message_00::get_data() const
48 flags
|= anchor_alarm_active
? 0x80 : 0x00;
49 flags
|= metric_display_units
? 0x40 : 0x00;
50 flags
|= transducer_defective
? 0x04 : 0x00;
51 flags
|= depth_alarm_active
? 0x02 : 0x00;
52 flags
|= shallow_depth_alarm_active
? 0x01 : 0x00;
54 return raw
{static_cast<uint8_t>(ID
), 0x02, flags
, static_cast<uint8_t>((depth
>> 0) & 0xff),
55 static_cast<uint8_t>((depth
>> 8) & 0xff)};
58 double message_00::get_depth_meters() const noexcept
60 if (transducer_defective
)
62 return (static_cast<double>(depth
) / 10.0) * 3.2808;