AIS: smaller public interface for AIS messages regarding encoding.
[marnav.git] / src / marnav / nmea / hdg.hpp
bloba4e08c4c75479cb6239a7b605dd2747f7d060e84
1 #ifndef __NMEA__HDG__HPP__
2 #define __NMEA__HDG__HPP__
4 #include <marnav/nmea/sentence.hpp>
5 #include <marnav/utils/optional.hpp>
7 namespace marnav
9 namespace nmea
11 MARNAV_NMEA_DECLARE_SENTENCE_PARSE_FUNC(hdg)
13 /// @brief HDG - Heading - Deviation & Variation
14 ///
15 /// @code
16 /// 1 2 3 4 5
17 /// | | | | |
18 /// $--HDG,x.x,x.x,a,x.x,a*hh<CR><LF>
19 /// @endcode
20 ///
21 /// Field Number:
22 /// 1. Magnetic Sensor heading in degrees
23 /// 2. Magnetic Deviation degrees
24 /// 3. Magnetic Deviation direction
25 /// - E = Easterly
26 /// - W = Westerly
27 /// 4. Magnetic Variation degrees
28 /// 5. Magnetic Variation direction
29 /// - E = Easterly
30 /// - W = Westerly
31 ///
32 class hdg : public sentence
34 MARNAV_NMEA_SENTENCE_FRIENDS(hdg)
36 public:
37 constexpr static const sentence_id ID = sentence_id::HDG;
38 constexpr static const char * TAG = "HDG";
40 virtual ~hdg() {}
42 hdg();
43 hdg(const hdg &) = default;
44 hdg(hdg &&) = default;
45 hdg & operator=(const hdg &) = default;
46 hdg & operator=(hdg &&) = default;
48 protected:
49 hdg(const std::string & talker, fields::const_iterator first, fields::const_iterator last);
50 virtual std::vector<std::string> get_data() const override;
52 private:
53 utils::optional<double> heading; // magnetic sensor heading in deg
54 utils::optional<double> magn_dev; // magnetic deviation in deg
55 utils::optional<direction> magn_dev_hem; // E:east, W:west
56 utils::optional<double> magn_var; // magnetic variation in deg
57 utils::optional<direction> magn_var_hem; // E:east, W:west
59 public:
60 NMEA_GETTER(heading)
61 NMEA_GETTER(magn_dev)
62 NMEA_GETTER(magn_dev_hem)
63 NMEA_GETTER(magn_var)
64 NMEA_GETTER(magn_var_hem)
66 void set_heading(double t) noexcept { heading = t; }
67 void set_magn_dev(double deg, direction hem);
68 void set_magn_var(double deg, direction hem);
73 #endif