1 #include "message_19.hpp"
2 #include <marnav/ais/angle.hpp>
3 #include <marnav/utils/unique.hpp>
10 message_19::message_19()
15 message_19::message_19(message_id id
)
17 , shipname("@@@@@@@@@@@@@@@@@@@@")
21 std::unique_ptr
<message
> message_19::parse(const raw
& bits
)
23 if (bits
.size() != SIZE_BITS
)
24 throw std::invalid_argument
{"invalid number of bits in message_19::parse"};
26 std::unique_ptr
<message
> result
= utils::make_unique
<message_19
>();
27 message_19
& msg
= static_cast<message_19
&>(*result
);
34 void message_19::read_data(const raw
& bits
)
36 bits
.get(repeat_indicator
, 6, 2);
37 bits
.get(mmsi
, 8, 30);
38 // regional reserved: 38 - 45
39 bits
.get(sog
, 46, 10);
40 bits
.get(position_accuracy
, 56, 1);
41 bits
.get(longitude_minutes
, 57, 28);
42 bits
.get(latitude_minutes
, 85, 27);
43 bits
.get(cog
, 112, 12);
44 bits
.get(hdg
, 124, 9);
45 bits
.get(timestamp
, 133, 6);
46 // regional reserved: 139 - 142
47 shipname
= read_string(bits
, 143, 20);
48 bits
.get(shiptype
, 263, 8);
49 bits
.get(to_bow
, 271, 9);
50 bits
.get(to_stern
, 280, 9);
51 bits
.get(to_port
, 289, 6);
52 bits
.get(to_starboard
, 295, 6);
53 bits
.get(epfd_fix
, 301, 4);
54 bits
.get(raim
, 305, 1);
55 bits
.get(dte
, 306, 1);
56 bits
.get(assigned
, 307, 1);
60 raw
message_19::get_data() const
64 bits
.set(type(), 0, 6);
65 bits
.set(repeat_indicator
, 6, 2);
66 bits
.set(mmsi
, 8, 30);
67 bits
.set(sog
, 46, 10);
68 bits
.set(position_accuracy
, 56, 1);
69 bits
.set(longitude_minutes
, 57, 28);
70 bits
.set(latitude_minutes
, 85, 27);
71 bits
.set(cog
, 112, 12);
72 bits
.set(hdg
, 124, 9);
73 bits
.set(timestamp
, 133, 6);
74 write_string(bits
, 143, 20, shipname
);
75 bits
.set(shiptype
, 263, 8);
76 bits
.set(to_bow
, 271, 9);
77 bits
.set(to_stern
, 280, 9);
78 bits
.set(to_port
, 289, 6);
79 bits
.set(to_starboard
, 295, 6);
80 bits
.set(epfd_fix
, 301, 4);
81 bits
.set(raim
, 305, 1);
82 bits
.set(dte
, 306, 1);
83 bits
.set(assigned
, 307, 1);
88 geo::longitude
message_19::get_longitude() const { return to_geo_longitude(longitude_minutes
); }
90 geo::latitude
message_19::get_latitude() const { return to_geo_latitude(latitude_minutes
); }
92 void message_19::set_longitude(const geo::longitude
& t
)
94 longitude_minutes
= to_longitude_minutes(t
);
97 void message_19::set_latitude(const geo::latitude
& t
)
99 latitude_minutes
= to_latitude_minutes(t
);