1 #ifndef MARNAV_AIS_MESSAGE_05_HPP
2 #define MARNAV_AIS_MESSAGE_05_HPP
4 #include <marnav/ais/message.hpp>
5 #include <marnav/ais/vessel_dimension.hpp>
6 #include <marnav/units/units.hpp>
7 #include <marnav/utils/mmsi.hpp>
13 /// @brief Static and Voyage related Data
15 /// This message handles messages of normal size 424 bits. The (presumably) common
16 /// occurrence of 422 bits, are also handled. The encoded message always is 424 bits.
17 /// The occurrence of 420 bits messages are not supported.
19 class message_05
: public message
21 friend class detail::factory
;
24 constexpr static message_id ID
= message_id::static_and_voyage_related_data
;
25 constexpr static std::size_t SIZE_BITS
= 424u;
26 constexpr static std::size_t SIZE_BITS_MIN
= 422u;
28 constexpr static uint32_t eta_month_not_available
= 0;
29 constexpr static uint32_t eta_day_not_available
= 0;
30 constexpr static uint32_t eta_hour_not_available
= 24;
31 constexpr static uint32_t eta_minute_not_available
= 60;
34 message_05(const message_05
&) = default;
35 message_05
& operator=(const message_05
&) = default;
36 message_05(message_05
&&) = default;
37 message_05
& operator=(message_05
&&) = default;
40 message_05(const raw
& bits
);
41 void read_data(const raw
& bits
);
42 virtual raw
get_data() const override
;
46 bitset_value
< 6, 2, uint32_t > repeat_indicator
= 0;
47 bitset_value
< 8, 30, uint32_t > mmsi
= 0;
48 bitset_value
< 38, 2, uint32_t > ais_version
= 0;
49 bitset_value
< 40, 30, uint32_t > imo_number
= 0;
50 bitset_value
< 70, 7, std::string
> callsign
;
51 bitset_value
<112, 20, std::string
> shipname
;
52 bitset_value
<232, 8, ship_type
> shiptype
= ship_type::not_available
;
53 bitset_value
<240, 9, uint32_t > to_bow
= 0;
54 bitset_value
<249, 9, uint32_t > to_stern
= 0;
55 bitset_value
<258, 6, uint32_t > to_port
= 0;
56 bitset_value
<264, 6, uint32_t > to_starboard
= 0;
57 bitset_value
<270, 4, epfd_fix_type
> epfd_fix
= epfd_fix_type::undefined
;
58 bitset_value
<274, 4, uint32_t > eta_month
= eta_month_not_available
;
59 bitset_value
<278, 5, uint32_t > eta_day
= eta_day_not_available
;
60 bitset_value
<283, 5, uint32_t > eta_hour
= eta_hour_not_available
;
61 bitset_value
<288, 6, uint32_t > eta_minute
= eta_minute_not_available
;
62 bitset_value
<294, 8, uint32_t > draught
= 0; // in 0.1m
63 bitset_value
<302, 20, std::string
> destination
;
64 bitset_value
<422, 1, data_terminal
> dte
= data_terminal::not_ready
;
68 uint32_t get_repeat_indicator() const noexcept
{ return repeat_indicator
; }
69 utils::mmsi
get_mmsi() const noexcept
{ return utils::mmsi
{mmsi
}; }
70 uint32_t get_ais_version() const noexcept
{ return ais_version
; }
71 uint32_t get_imo_number() const noexcept
{ return imo_number
; }
72 std::string
get_callsign() const;
73 std::string
get_shipname() const;
74 ship_type
get_shiptype() const noexcept
{ return shiptype
; }
75 vessel_dimension
get_vessel_dimension() const noexcept
;
76 epfd_fix_type
get_epfd_fix() const noexcept
{ return epfd_fix
; }
77 uint32_t get_eta_month() const noexcept
{ return eta_month
; }
78 uint32_t get_eta_day() const noexcept
{ return eta_day
; }
79 uint32_t get_eta_hour() const noexcept
{ return eta_hour
; }
80 uint32_t get_eta_minute() const noexcept
{ return eta_minute
; }
81 units::meters
get_draught() const noexcept
;
82 std::string
get_destination() const;
83 data_terminal
get_dte() const noexcept
{ return dte
; }
85 void set_repeat_indicator(uint32_t t
) noexcept
{ repeat_indicator
= t
; }
86 void set_mmsi(const utils::mmsi
& t
) noexcept
{ mmsi
= t
; }
87 void set_ais_version(uint32_t t
) noexcept
{ ais_version
= t
; }
88 void set_imo_number(uint32_t t
) noexcept
{ imo_number
= t
; }
89 void set_callsign(const std::string
& t
);
90 void set_shipname(const std::string
& t
);
91 void set_shiptype(ship_type t
) noexcept
{ shiptype
= t
; }
92 void set_vessel_dimension(const vessel_dimension
& t
);
93 void set_epfd_fix(epfd_fix_type t
) noexcept
{ epfd_fix
= t
; }
94 void set_eta_month(uint32_t t
) noexcept
{ eta_month
= t
; }
95 void set_eta_day(uint32_t t
) noexcept
{ eta_day
= t
; }
96 void set_eta_hour(uint32_t t
) noexcept
{ eta_hour
= t
; }
97 void set_eta_minute(uint32_t t
) noexcept
{ eta_minute
= t
; }
99 // The resolution of the draught is in 0.1m. For safety reasons, the value
100 // is ceiled within the resolution of 0.1m.
102 // set_draught(units::meters{1.5}) => stored draught 1.5
103 // set_draught(units::meters{1.51}) => stored draught 1.6
104 void set_draught(units::length t
);
106 void set_destination(const std::string
& t
);
107 void set_dte(data_terminal t
) noexcept
{ dte
= t
; }