1 #include "message_24.hpp"
3 #include <marnav/utils/unique.hpp>
4 #include <marnav/utils/mmsi.hpp>
11 message_24::message_24()
16 message_24::message_24(message_id id
)
18 , shipname("@@@@@@@@@@@@@@@@@@@@")
24 std::unique_ptr
<message
> message_24::parse(const raw
& bits
)
26 if ((bits
.size() != SIZE_BITS
) && (bits
.size() != SIZE_BITS_IGNORED_SPARES_OF_TYPE_A
))
27 throw std::invalid_argument
{"invalid number of bits in message_24::parse"};
30 bits
.get(part
, 38, 2);
33 throw std::invalid_argument
{"invalid part number message_24::parse"};
35 std::unique_ptr
<message
> result
= utils::make_unique
<message_24
>();
36 message_24
& msg
= static_cast<message_24
&>(*result
);
43 bool message_24::is_auxiliary_vessel() const { return utils::mmsi
{mmsi
}.is_auxiliary(); }
45 void message_24::read_data(const raw
& bits
)
47 bits
.get(repeat_indicator
, 6, 2);
48 bits
.get(mmsi
, 8, 30);
50 std::underlying_type
<part
>::type tmp
= 3;
52 part_number
= static_cast<part
>(tmp
);
54 if (part_number
== part::A
) {
55 shipname
= read_string(bits
, 40, 20);
58 bits
.get(shiptype
, 40, 8);
59 vendor_id
= read_string(bits
, 48, 3);
60 bits
.get(model
, 66, 4);
61 bits
.get(serial
, 70, 20);
62 callsign
= read_string(bits
, 90, 7);
63 if (is_auxiliary_vessel()) {
64 bits
.get(mothership_mmsi
, 132, 30);
66 bits
.get(to_bow
, 132, 9);
67 bits
.get(to_stern
, 141, 9);
68 bits
.get(to_port
, 150, 6);
69 bits
.get(to_starboard
, 156, 6);
75 raw
message_24::get_data() const
79 bits
.set(type(), 0, 6);
80 bits
.set(repeat_indicator
, 6, 2);
81 bits
.set(mmsi
, 8, 30);
82 bits
.set(static_cast<std::underlying_type
<part
>::type
>(part_number
), 38, 2);
84 if (part_number
== part::A
) {
85 write_string(bits
, 40, 20, shipname
);
87 bits
.set(shiptype
, 40, 8);
88 write_string(bits
, 48, 3, vendor_id
);
89 bits
.set(model
, 66, 4);
90 bits
.set(serial
, 70, 20);
91 write_string(bits
, 90, 7, callsign
);
92 if (is_auxiliary_vessel()) {
93 bits
.set(mothership_mmsi
, 132, 30);
95 bits
.set(to_bow
, 132, 9);
96 bits
.set(to_stern
, 141, 9);
97 bits
.set(to_port
, 150, 6);
98 bits
.set(to_starboard
, 156, 6);