NMEA: detectio of the optional tag block in front of a sentence, ignoring it for...
[marnav.git] / src / marnav / ais / binary_200_10.hpp
blobbdf56ccd46990c74f0391aaaffcbd9e94750b11d
1 #ifndef __MARNAV__AIS__BINARY_200_10__HPP__
2 #define __MARNAV__AIS__BINARY_200_10__HPP__
4 #include <marnav/ais/binary_data.hpp>
6 namespace marnav
8 namespace ais
10 /// @brief Inland ship static and voyage related data (Inland AIS).
11 ///
12 class binary_200_10 final : public binary_data
14 public:
15 /// This offset is the size of the header of the binary message 08,
16 /// which carries the binary information of this class.
17 /// For convenience (see bitset value mapping below), the offsets
18 /// are the same as the documentation for easier reading and understanding.
19 /// It is also less error prone. This means however, the offset
20 /// must be computed, which is a minor nuisance, especially since
21 /// the header of the message 08 must not be included in this header.
22 constexpr static uint32_t MSG08_HEAD = 56;
24 constexpr static uint32_t SIZE_BITS = 168 - MSG08_HEAD;
26 enum class loaded_state : uint8_t { not_available = 0, unloaded = 1, loaded = 2 };
28 binary_200_10();
30 void read_from(const raw & payload);
31 void write_to(raw & payload) const;
33 private:
34 // clang-format off
35 bitset_value< 56 - MSG08_HEAD, 8, std::string > vessel_id;
36 bitset_value<104 - MSG08_HEAD, 13, uint32_t > length = 0;
37 bitset_value<117 - MSG08_HEAD, 10, uint32_t > beam = 0;
38 bitset_value<127 - MSG08_HEAD, 14, uint32_t > shiptype = 8000; // TODO: enumeration
39 bitset_value<141 - MSG08_HEAD, 3, uint32_t > hazard = 5;
40 bitset_value<144 - MSG08_HEAD, 11, uint32_t > draught = 0;
41 bitset_value<155 - MSG08_HEAD, 2, loaded_state> loaded = loaded_state::not_available;
42 bitset_value<157 - MSG08_HEAD, 1, bool > speed_q = false;
43 bitset_value<158 - MSG08_HEAD, 1, bool > course_q = false;
44 bitset_value<159 - MSG08_HEAD, 1, bool > heading_q = false;
45 // clang-format on
47 public:
48 std::string get_vessel_id() const;
49 double get_length() const;
50 double get_beam() const;
51 uint32_t get_shiptype() const { return shiptype; }
52 uint32_t get_hazard() const { return hazard; }
53 double get_draught() const;
54 loaded_state get_loaded() const { return loaded; }
55 bool get_speed_q() const { return speed_q; }
56 bool get_course_q() const { return course_q; }
57 bool get_heading_q() const { return heading_q; }
59 void set_vessel_id(const std::string & t);
60 void set_length(double t);
61 void set_beam(double t);
62 void set_shiptype(uint32_t t) { shiptype = t; }
63 void set_hazard(uint32_t t) { hazard = t; }
64 void set_draught(double t);
65 void set_loaded(loaded_state t) { loaded = t; }
66 void set_speed_q(bool t) { speed_q = t; }
67 void set_course_q(bool t) { course_q = t; }
68 void set_heading_q(bool t) { heading_q = t; }
73 #endif