AIS: smaller public interface for AIS messages regarding encoding.
[marnav.git] / src / marnav / nmea / osd.hpp
blob183b247073f4046d716d7d0703f750a4a7d5be35
1 #ifndef __NMEA__OSD__HPP__
2 #define __NMEA__OSD__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(osd)
13 /// @brief OSD - Own Ship Data
14 ///
15 /// @code
16 /// 1 2 3 4 5 6 7 8 9
17 /// | | | | | | | | |
18 /// $--OSD,x.x,A,x.x,a,x.x,a,x.x,x.x,a*hh<CR><LF>
19 /// @endcode
20 ///
21 /// Field Number:
22 /// 1. Heading, degrees true
23 /// 2. Status
24 /// - A = Data Valid
25 /// - V = Invalid
26 /// 3. Vessel Course, degrees True
27 /// 4. Course Reference
28 /// - T = True
29 /// 5. Vessel Speed
30 /// 6. Speed Unit
31 /// 7. Vessel Set, degrees True
32 /// 8. Vessel drift (speed)
33 /// 9. Speed Units
34 ///
35 class osd : public sentence
37 MARNAV_NMEA_SENTENCE_FRIENDS(osd)
39 public:
40 constexpr static const sentence_id ID = sentence_id::OSD;
41 constexpr static const char * TAG = "OSD";
43 virtual ~osd() {}
45 osd();
46 osd(const osd &) = default;
47 osd & operator=(const osd &) = default;
49 protected:
50 osd(const std::string & talker, fields::const_iterator first, fields::const_iterator last);
51 virtual std::vector<std::string> get_data() const override;
53 private:
54 utils::optional<double> heading; // degrees true
55 utils::optional<status> data_valid;
56 utils::optional<double> course; // degrees true
57 utils::optional<reference> course_ref;
58 utils::optional<double> speed;
59 utils::optional<unit::velocity> speed_unit;
60 utils::optional<double> vessel_set; // degrees true
61 utils::optional<double> vessel_drift; // (speed)
62 utils::optional<unit::velocity> vessel_drift_unit;
64 public:
65 NMEA_GETTER(heading)
66 NMEA_GETTER(data_valid)
67 NMEA_GETTER(course)
68 NMEA_GETTER(course_ref)
69 NMEA_GETTER(speed)
70 NMEA_GETTER(speed_unit)
71 NMEA_GETTER(vessel_set)
72 NMEA_GETTER(vessel_drift)
73 NMEA_GETTER(vessel_drift_unit)
75 void set_heading(double t) noexcept { heading = t; }
76 void set_data_valid(status t) noexcept { data_valid = t; }
77 void set_course(double t) noexcept;
78 void set_speed(double t, unit::velocity u) noexcept;
79 void set_vessel_set(double t) noexcept { vessel_set = t; }
80 void set_drift(double t, unit::velocity u) noexcept;
85 #endif