nmealib 0.0.4
NMEA 0183/NMEA 2000 parsing library
Loading...
Searching...
No Matches
rmb.h
Go to the documentation of this file.
1#pragma once
2
3#include <nmealib/nmea0183.h>
4
5#include <optional>
6
7namespace nmealib {
8namespace nmea0183 {
9
17public:
24 explicit NotRMBException(const std::string& context, const std::string& details = "") :
25 NmeaException(context, "The sentence is not an RMB sentence", details) {}
26};
27
41class RMB : public Message0183 {
42public:
65 RMB(std::string talkerId,
66 char status,
67 double crossTrackErrorNm,
68 char directionToSteer,
69 std::string originWaypointId,
70 std::string destinationWaypointId,
71 double destinationLatitude,
72 char destinationLatitudeHemisphere,
73 double destinationLongitude,
74 char destinationLongitudeHemisphere,
75 double rangeToDestinationNm,
76 double bearingToDestinationTrue,
77 double destinationClosingVelocityKnots,
78 char arrivalStatus,
79 std::optional<char> faaModeIndicator = std::nullopt
80 );
81
82 RMB(const RMB&) = default;
83 RMB& operator=(const RMB&) = default;
84 RMB(RMB&&) noexcept = default;
85 RMB& operator=(RMB&&) noexcept = default;
86
87 ~RMB() override = default;
88
94 std::unique_ptr<nmealib::Message> clone() const override;
95
97 char getStatus() const noexcept;
99 double getCrossTrackErrorNm() const noexcept;
101 char getDirectionToSteer() const noexcept;
103 std::string getOriginWaypointId() const noexcept;
105 std::string getDestinationWaypointId() const noexcept;
107 double getDestinationLatitude() const noexcept;
109 char getDestinationLatitudeHemisphere() const noexcept;
111 double getDestinationLongitude() const noexcept;
113 char getDestinationLongitudeHemisphere() const noexcept;
115 double getRangeToDestinationNm() const noexcept;
117 double getBearingToDestinationTrue() const noexcept;
119 double getDestinationClosingVelocityKnots() const noexcept;
121 char getArrivalStatus() const noexcept;
123 bool hasFaaModeIndicator() const noexcept;
125 std::optional<char> getFaaModeIndicator() const noexcept;
126
133 std::string getStringContent(bool verbose) const noexcept override;
134
143 bool operator==(const RMB& other) const noexcept;
144
145private:
146 char status_{};
147 double crossTrackErrorNm_{};
148 char directionToSteer_{};
149 std::string originWaypointId_{};
150 std::string destinationWaypointId_{};
151 double destinationLatitude_{};
152 char destinationLatitudeHemisphere_{};
153 double destinationLongitude_{};
154 char destinationLongitudeHemisphere_{};
155 double rangeToDestinationNm_{};
156 double bearingToDestinationTrue_{};
157 double destinationClosingVelocityKnots_{};
158 char arrivalStatus_{};
159 std::optional<char> faaModeIndicator_{};
160
161 RMB() = delete;
162
163 RMB(Message0183 baseMessage,
164 char status,
165 double crossTrackErrorNm,
166 char directionToSteer,
167 std::string originWaypointId,
168 std::string destinationWaypointId,
169 double destinationLatitude,
170 char destinationLatitudeHemisphere,
171 double destinationLongitude,
172 char destinationLongitudeHemisphere,
173 double rangeToDestinationNm,
174 double bearingToDestinationTrue,
175 double destinationClosingVelocityKnots,
176 char arrivalStatus,
177 std::optional<char> faaModeIndicator
178 ) noexcept;
179
180 static std::unique_ptr<RMB> create(std::unique_ptr<Message0183> baseMessage);
181 static std::string composeRaw(const std::string& talkerId,
182 char status,
183 double crossTrackErrorNm,
184 char directionToSteer,
185 const std::string& originWaypointId,
186 const std::string& destinationWaypointId,
187 double destinationLatitude,
188 char destinationLatitudeHemisphere,
189 double destinationLongitude,
190 char destinationLongitudeHemisphere,
191 double rangeToDestinationNm,
192 double bearingToDestinationTrue,
193 double destinationClosingVelocityKnots,
194 char arrivalStatus,
195 std::optional<char> faaModeIndicator);
196
197 friend class Nmea0183Factory;
198 friend class MessageRegistry;
199};
200
201} // namespace nmea0183
202} // namespace nmealib
Defines a base class for NMEA messages, encapsulating common properties and behaviors.
Definition message.h:14
Base exception class for all NMEA library errors.
Represents an NMEA 0183 sentence.
Definition nmea0183.h:98
Registry for message type creators.
Factory for creating typed NMEA 0183 message objects from raw sentence strings.
Exception thrown when a sentence is not a valid RMB sentence.
Definition rmb.h:16
NotRMBException(const std::string &context, const std::string &details="")
Construct a NotRMBException with context and optional details.
Definition rmb.h:24
Represents a parsed NMEA 0183 RMB (Recommended Minimum Navigation Information) sentence.
Definition rmb.h:41
RMB(const RMB &)=default
std::string getStringContent(bool verbose) const noexcept override
Return a human-readable string representation of this message.
Definition rmb.cpp:161
double getBearingToDestinationTrue() const noexcept
Get bearing to destination in true degrees.
Definition rmb.cpp:287
char getArrivalStatus() const noexcept
Get arrival status ('A' arrived, 'V' not arrived).
Definition rmb.cpp:295
RMB(std::string talkerId, char status, double crossTrackErrorNm, char directionToSteer, std::string originWaypointId, std::string destinationWaypointId, double destinationLatitude, char destinationLatitudeHemisphere, double destinationLongitude, char destinationLongitudeHemisphere, double rangeToDestinationNm, double bearingToDestinationTrue, double destinationClosingVelocityKnots, char arrivalStatus, std::optional< char > faaModeIndicator=std::nullopt)
Construct an RMB message from individual field values.
Definition rmb.cpp:112
RMB & operator=(const RMB &)=default
char getDestinationLatitudeHemisphere() const noexcept
Get destination latitude hemisphere indicator ('N' or 'S').
Definition rmb.cpp:271
std::string getDestinationWaypointId() const noexcept
Get destination waypoint identifier.
Definition rmb.cpp:263
char getDestinationLongitudeHemisphere() const noexcept
Get destination longitude hemisphere indicator ('E' or 'W').
Definition rmb.cpp:279
std::string getOriginWaypointId() const noexcept
Get origin waypoint identifier.
Definition rmb.cpp:259
char getDirectionToSteer() const noexcept
Get direction to steer ('L' or 'R').
Definition rmb.cpp:255
std::unique_ptr< nmealib::Message > clone() const override
Create a polymorphic copy of this RMB message.
Definition rmb.cpp:157
std::optional< char > getFaaModeIndicator() const noexcept
Get optional FAA mode indicator (NMEA 2.3+).
Definition rmb.cpp:303
bool hasFaaModeIndicator() const noexcept
Return whether FAA mode indicator is present.
Definition rmb.cpp:299
double getCrossTrackErrorNm() const noexcept
Get cross track error in nautical miles.
Definition rmb.cpp:251
double getDestinationLongitude() const noexcept
Get destination waypoint longitude in decimal degrees.
Definition rmb.cpp:275
double getDestinationClosingVelocityKnots() const noexcept
Get destination closing velocity in knots.
Definition rmb.cpp:291
double getDestinationLatitude() const noexcept
Get destination waypoint latitude in decimal degrees.
Definition rmb.cpp:267
RMB(RMB &&) noexcept=default
double getRangeToDestinationNm() const noexcept
Get range to destination in nautical miles.
Definition rmb.cpp:283
char getStatus() const noexcept
Get status indicator ('A' active, 'V' invalid).
Definition rmb.cpp:247