General: standard compliance with underscores
[marnav.git] / include / marnav / ais / binary_001_11.hpp
blobd832ff8d7c5620a5b7694d3ee4bd3b228d2f326e
1 #ifndef MARNAV_AIS_BINARY_001_11_HPP
2 #define MARNAV_AIS_BINARY_001_11_HPP
4 #include <marnav/ais/binary_data.hpp>
5 #include <marnav/geo/position.hpp>
6 #include <marnav/utils/optional.hpp>
8 namespace marnav
10 namespace ais
12 /// @brief Meteorological and Hydrological Data (IMO236).
13 ///
14 class binary_001_11 final : public binary_data
16 public:
17 /// This offset is the size of the header of the binary message 08,
18 /// which carries the binary information of this class.
19 /// For convenience (see bitset value mapping below), the offsets
20 /// are the same as the documentation for easier reading and understanding.
21 /// It is also less error prone. This means however, the offset
22 /// must be computed, which is a minor nuisance, especially since
23 /// the header of the message 08 must not be included in this header.
24 constexpr static uint32_t MSG08_HEAD = 56;
26 constexpr static uint32_t SIZE_BITS = 352 - MSG08_HEAD;
28 constexpr static uint32_t lat_not_available = 0x7fffff;
29 constexpr static uint32_t lon_not_available = 0xffffff;
30 constexpr static uint32_t day_not_available = 31;
31 constexpr static uint32_t hour_not_available = 31;
32 constexpr static uint32_t minute_not_available = 63;
33 constexpr static uint32_t wind_speed_avg_not_available = 127;
34 constexpr static uint32_t wind_gust_not_available = 127;
35 constexpr static uint32_t wind_direction_not_available = 511;
36 constexpr static uint32_t wind_gust_direction_not_available = 511;
37 constexpr static uint32_t temperature_not_available = 2047;
38 constexpr static uint32_t humidity_not_available = 127;
39 constexpr static uint32_t dew_point_not_available = 1023;
40 constexpr static uint32_t pressure_not_available = 511;
41 constexpr static uint32_t visibility_not_available = 255;
42 constexpr static uint32_t water_level_not_available = 511;
43 constexpr static uint32_t current_speed_not_available = 255;
44 constexpr static uint32_t current_direction_not_available = 511;
45 constexpr static uint32_t current_depth_not_available = 31;
46 constexpr static uint32_t wave_height_not_available = 255;
47 constexpr static uint32_t wave_period_not_available = 63;
48 constexpr static uint32_t wave_direction_not_available = 511;
49 constexpr static uint32_t sea_state_not_available = 15;
50 constexpr static uint32_t water_temperature_not_available = 1023;
51 constexpr static uint32_t salinity_not_available = 511;
53 enum class trend : uint8_t {
54 steady = 0,
55 decreasing = 1,
56 increasing = 2,
57 not_available = 3
60 enum class ice : uint8_t { no = 0, yes = 1, not_available = 3 };
62 enum class precipitation : uint8_t {
63 rain = 1,
64 thunderstorm = 2,
65 freezing_rain = 3,
66 mixed_ice = 4,
67 snow = 5,
68 not_available = 7
71 void read_from(const raw & payload);
72 void write_to(raw & payload) const;
74 private:
75 // clang-format off
76 bitset_value< 56 - MSG08_HEAD, 24, uint32_t > lat = lat_not_available;
77 bitset_value< 80 - MSG08_HEAD, 25, uint32_t > lon = lon_not_available;
78 bitset_value<105 - MSG08_HEAD, 5, uint32_t > day = day_not_available; /// @todo Investigation about range and not_available value, because 31 could be a valid day in the range of 1..31
79 bitset_value<110 - MSG08_HEAD, 5, uint32_t > hour = hour_not_available;
80 bitset_value<115 - MSG08_HEAD, 6, uint32_t > minute = minute_not_available;
81 bitset_value<121 - MSG08_HEAD, 7, uint32_t > wind_speed_avg = wind_speed_avg_not_available;
82 bitset_value<128 - MSG08_HEAD, 7, uint32_t > wind_gust = wind_gust_not_available;
83 bitset_value<135 - MSG08_HEAD, 9, uint32_t > wind_direction = wind_direction_not_available;
84 bitset_value<144 - MSG08_HEAD, 9, uint32_t > wind_gust_direction = wind_gust_direction_not_available;
85 bitset_value<153 - MSG08_HEAD, 11, uint32_t > temperature = temperature_not_available;
86 bitset_value<164 - MSG08_HEAD, 7, uint32_t > humidity = humidity_not_available;
87 bitset_value<171 - MSG08_HEAD, 10, uint32_t > dew_point = dew_point_not_available;
88 bitset_value<181 - MSG08_HEAD, 9, uint32_t > pressure = pressure_not_available;
89 bitset_value<190 - MSG08_HEAD, 2, trend > pressure_trend = trend::not_available;
90 bitset_value<192 - MSG08_HEAD, 8, uint32_t > visibility = visibility_not_available;
91 bitset_value<200 - MSG08_HEAD, 9, uint32_t > water_level = water_level_not_available;
92 bitset_value<209 - MSG08_HEAD, 2, trend > water_level_trend = trend::not_available;
93 bitset_value<211 - MSG08_HEAD, 8, uint32_t > surface_current_speed = current_speed_not_available;
94 bitset_value<219 - MSG08_HEAD, 9, uint32_t > surface_current_direction = current_direction_not_available;
95 bitset_value<228 - MSG08_HEAD, 8, uint32_t > current_2_speed = current_speed_not_available;
96 bitset_value<236 - MSG08_HEAD, 9, uint32_t > current_2_direction = current_direction_not_available;
97 bitset_value<245 - MSG08_HEAD, 5, uint32_t > current_2_depth = current_depth_not_available;
98 bitset_value<250 - MSG08_HEAD, 8, uint32_t > current_3_speed = current_speed_not_available;
99 bitset_value<258 - MSG08_HEAD, 9, uint32_t > current_3_direction = current_direction_not_available;
100 bitset_value<267 - MSG08_HEAD, 5, uint32_t > current_3_depth = current_depth_not_available;
101 bitset_value<272 - MSG08_HEAD, 8, uint32_t > wave_height = wave_height_not_available;
102 bitset_value<280 - MSG08_HEAD, 6, uint32_t > wave_period = wave_period_not_available;
103 bitset_value<286 - MSG08_HEAD, 9, uint32_t > wave_direction = wave_direction_not_available;
104 bitset_value<295 - MSG08_HEAD, 8, uint32_t > swell_height = wave_height_not_available;
105 bitset_value<303 - MSG08_HEAD, 6, uint32_t > swell_period = wave_period_not_available;
106 bitset_value<309 - MSG08_HEAD, 9, uint32_t > swell_direction = wave_direction_not_available;
107 bitset_value<318 - MSG08_HEAD, 4, uint32_t > sea_state = sea_state_not_available;
108 bitset_value<322 - MSG08_HEAD, 10, uint32_t > water_temperature = water_temperature_not_available;
109 bitset_value<332 - MSG08_HEAD, 3, precipitation> precipitation_type = precipitation::not_available;
110 bitset_value<335 - MSG08_HEAD, 9, uint32_t > sailinity = salinity_not_available;
111 bitset_value<344 - MSG08_HEAD, 2, ice > ice_info = ice::not_available;
112 // clang-format on
114 public:
115 utils::optional<geo::position> get_position() const;
116 utils::optional<uint32_t> get_day() const;
117 utils::optional<uint32_t> get_hour() const;
118 utils::optional<uint32_t> get_minute() const;
119 utils::optional<uint32_t> get_wind_speed_avg() const;
120 utils::optional<uint32_t> get_wind_gust() const;
121 utils::optional<uint32_t> get_wind_direction() const;
122 utils::optional<uint32_t> get_wind_gust_direction() const;
123 utils::optional<double> get_temperature() const;
124 utils::optional<uint32_t> get_humidity() const;
125 utils::optional<double> get_dew_point() const;
126 utils::optional<uint32_t> get_pressure() const;
127 utils::optional<trend> get_pressure_trend() const;
128 utils::optional<double> get_visibility() const;
129 utils::optional<double> get_water_level() const;
130 utils::optional<trend> get_water_level_trend() const;
131 utils::optional<double> get_surface_current_speed() const;
132 utils::optional<uint32_t> get_surface_current_direction() const;
133 utils::optional<double> get_current_2_speed() const;
134 utils::optional<uint32_t> get_current_2_direction() const;
135 utils::optional<uint32_t> get_current_2_depth() const;
136 utils::optional<double> get_current_3_speed() const;
137 utils::optional<uint32_t> get_current_3_direction() const;
138 utils::optional<uint32_t> get_current_3_depth() const;
139 utils::optional<double> get_wave_height() const;
140 utils::optional<uint32_t> get_wave_period() const;
141 utils::optional<uint32_t> get_wave_direction() const;
142 utils::optional<double> get_swell_height() const;
143 utils::optional<uint32_t> get_swell_period() const;
144 utils::optional<uint32_t> get_swell_direction() const;
145 utils::optional<uint32_t> get_sea_state() const;
146 utils::optional<double> get_water_temperature() const;
147 utils::optional<precipitation> get_precipitation() const;
148 utils::optional<double> get_salinity() const;
149 utils::optional<ice> get_ice() const;
151 void set_position(utils::optional<geo::position> t);
152 void set_day(utils::optional<uint32_t> t);
153 void set_hour(utils::optional<uint32_t> t);
154 void set_minute(utils::optional<uint32_t> t);
155 void set_wind_speed_avg(utils::optional<uint32_t> t);
156 void set_wind_gust(utils::optional<uint32_t> t);
157 void set_wind_direction(utils::optional<uint32_t> t);
158 void set_wind_gust_direction(utils::optional<uint32_t> t);
159 void set_temperature(utils::optional<double> t);
160 void set_humidity(utils::optional<uint32_t> t);
161 void set_dew_point(utils::optional<double> t);
162 void set_pressure(utils::optional<uint32_t> t);
163 void set_pressure_trend(utils::optional<trend> t);
164 void set_visibility(utils::optional<double> t);
165 void set_water_level(utils::optional<double> t);
166 void set_water_level_trend(utils::optional<trend> t);
167 void set_surface_current_speed(utils::optional<double> t);
168 void set_surface_current_direction(utils::optional<uint32_t> t);
169 void set_current_2_speed(utils::optional<double> t);
170 void set_current_2_direction(utils::optional<uint32_t> t);
171 void set_current_2_depth(utils::optional<uint32_t> t);
172 void set_current_3_speed(utils::optional<double> t);
173 void set_current_3_direction(utils::optional<uint32_t> t);
174 void set_current_3_depth(utils::optional<uint32_t> t);
175 void set_wave_height(utils::optional<double> t);
176 void set_wave_period(utils::optional<uint32_t> t);
177 void set_wave_direction(utils::optional<uint32_t> t);
178 void set_swell_height(utils::optional<double> t);
179 void set_swell_period(utils::optional<uint32_t> t);
180 void set_swell_direction(utils::optional<uint32_t> t);
181 void set_sea_state(utils::optional<uint32_t> t);
182 void set_water_temperature(utils::optional<double> t);
183 void set_precipitation(utils::optional<precipitation> t);
184 void set_salinity(utils::optional<double> t);
185 void set_ice(utils::optional<ice> t);
190 #endif