NMEA: changed interface of sentences containing position information.
[marnav.git] / src / marnav / nmea / rmb.hpp
blob4d98191afb295b7895743f78a86af2c4be68a00c
1 #ifndef __NMEA__RMB__HPP__
2 #define __NMEA__RMB__HPP__
4 #include <marnav/nmea/sentence.hpp>
5 #include <marnav/nmea/angle.hpp>
6 #include <marnav/nmea/waypoint.hpp>
7 #include <marnav/utils/optional.hpp>
9 namespace marnav
11 namespace nmea
13 MARNAV_NMEA_DECLARE_SENTENCE_PARSE_FUNC(rmb)
15 /// @brief RMB - Recommended Minimum Navigation Information
16 ///
17 /// To be sent by a navigation receiver when a destination waypoint is active.
18 ///
19 /// @code
20 /// 14
21 /// 1 2 3 4 5 6 7 8 9 10 11 12 13|
22 /// | | | | | | | | | | | | | |
23 /// $--RMB,A,x.x,a,c--c,c--c,llll.ll,a,yyyyy.yy,a,x.x,x.x,x.x,A,m,*hh<CR><LF>
24 /// @endcode
25 ///
26 /// Field Number:
27 /// 1. Status
28 /// - A = Active
29 /// - V = Void
30 /// 2. Cross Track error - nautical miles
31 /// 3. Direction to Steer
32 /// - L = Left
33 /// - R = Right
34 /// 4. TO Waypoint ID
35 /// 5. FROM Waypoint ID
36 /// 6. Destination Waypoint Latitude
37 /// 7. Destination Waypoint Latitude hemisphere
38 /// - N = North
39 /// - S = South
40 /// 8. Destination Waypoint Longitude
41 /// 9. Destination Waypoint Longitude hemisphere
42 /// - E = East
43 /// - W = West
44 /// 10. Range to destination in nautical miles
45 /// 11. Bearing to destination in degrees True
46 /// 12. Destination closing velocity in knots
47 /// 13. Arrival Status
48 /// - A = Arrival Circle Entered
49 /// - V = Not Entered
50 /// 14. FAA mode indicator (NMEA 2.3 and later)
51 ///
52 /// Example:
53 /// @code
54 /// $GPRMB,A,0.66,L,003,004,4917.24,N,12309.57,W,001.3,052.5,000.5,V*0B
55 /// @endcode
56 ///
57 class rmb : public sentence
59 MARNAV_NMEA_SENTENCE_FRIENDS(rmb)
61 public:
62 constexpr static const sentence_id ID = sentence_id::RMB;
63 constexpr static const char * TAG = "RMB";
65 virtual ~rmb() {}
67 rmb();
68 rmb(const rmb &) = default;
69 rmb & operator=(const rmb &) = default;
71 protected:
72 rmb(const std::string & talker, fields::const_iterator first, fields::const_iterator last);
73 virtual std::vector<std::string> get_data() const override;
75 private:
76 utils::optional<status> active; // V:warning
77 utils::optional<double> cross_track_error; // cross track error in nautical miles
78 utils::optional<side> steer_dir; // direction to steer, left or right
79 utils::optional<waypoint> waypoint_to; // TO waypoint ID
80 utils::optional<waypoint> waypoint_from; // FROM waypoint ID
81 utils::optional<geo::latitude> lat; // destination waypoint latitude
82 utils::optional<direction> lat_hem; // destination waypoint latitude dir, N:north, S:south
83 utils::optional<geo::longitude> lon; // destination waypoint longitude
84 utils::optional<direction> lon_hem; // destination waypoint longitude dir, E:east, W:west
85 utils::optional<double> range; // range to destination in nautical miles
86 utils::optional<double> bearing; // bearing to destination in degrees to true
87 utils::optional<double> dst_velocity; // destination closing velocity in knots
88 utils::optional<status> arrival_status; // arrival status, A:arrival circle entered
89 utils::optional<positioning_system_mode_indicator> mode_indicator;
91 public:
92 NMEA_GETTER(active)
93 NMEA_GETTER(cross_track_error)
94 NMEA_GETTER(steer_dir)
95 NMEA_GETTER(waypoint_to)
96 NMEA_GETTER(waypoint_from)
97 NMEA_GETTER(range)
98 NMEA_GETTER(bearing)
99 NMEA_GETTER(dst_velocity)
100 NMEA_GETTER(arrival_status)
101 NMEA_GETTER(mode_indicator)
103 utils::optional<geo::longitude> get_longitude() const;
104 utils::optional<geo::latitude> get_latitude() const;
106 void set_active(status t) noexcept { active = t; }
107 void set_cross_track_error(double t) noexcept { cross_track_error = t; }
108 void set_steer_dir(side t) noexcept { steer_dir = t; }
109 void set_waypoint_to(const waypoint & id) { waypoint_to = id; }
110 void set_waypoint_from(const waypoint & id) { waypoint_from = id; }
111 void set_lat(const geo::latitude & t);
112 void set_lon(const geo::longitude & t);
113 void set_range(double t) noexcept { range = t; }
114 void set_bearing(double t) noexcept { bearing = t; }
115 void set_dst_velocity(double t) noexcept { dst_velocity = t; }
116 void set_arrival_status(status t) noexcept { arrival_status = t; }
117 void set_mode_indicator(positioning_system_mode_indicator t) noexcept
119 mode_indicator = t;
125 #endif