nmealib 0.0.4
NMEA 0183/NMEA 2000 parsing library
Loading...
Searching...
No Matches
rmc.h
Go to the documentation of this file.
1#pragma once
2
3#include <nmealib/nmea0183.h>
4
5namespace nmealib {
6namespace nmea0183 {
7
15public:
22 explicit NotRMCException(const std::string& context, const std::string& details = "") :
23 NmeaException(context, "The sentence is not an RMC sentence", details) {}
24};
25
37class RMC : public Message0183 {
38public:
60 RMC(std::string talkerId,
61 unsigned int utcFix,
62 char status,
63 double latitude,
64 char latitudeDirection,
65 double longitude,
66 char longitudeDirection,
67 double speedOverGround,
68 double courseOverGround,
69 unsigned int date,
70 double magneticVariation,
71 char magneticVariationDirection,
72 char modeIndicator,
73 char navigationStatus
74 );
75
76 RMC(const RMC&) = default;
77 RMC& operator=(const RMC&) = default;
78 RMC(RMC&&) noexcept = default;
79 RMC& operator=(RMC&&) noexcept = default;
80
81 ~RMC() override = default;
82
88 std::unique_ptr<nmealib::Message> clone() const override;
89
91 unsigned int getUtcFix() const noexcept;
93 char getStatus() const noexcept;
95 double getLatitude() const noexcept;
97 char getLatitudeDirection() const noexcept;
99 double getLongitude() const noexcept;
101 char getLongitudeDirection() const noexcept;
103 double getSpeedOverGround() const noexcept;
105 double getCourseOverGround() const noexcept;
107 unsigned int getDate() const noexcept;
109 double getMagneticVariation() const noexcept;
111 char getMagneticVariationDirection() const noexcept;
113 char getModeIndicator() const noexcept;
115 char getNavigationStatus() const noexcept;
116
123 std::string getStringContent(bool verbose) const noexcept override;
124
133 bool operator==(const RMC& other) const noexcept;
134
135private:
136 unsigned int utcFix_{};
137 char status_{};
138 double latitude_{};
139 char latitudeDirection_{};
140 double longitude_{};
141 char longitudeDirection_{};
142 double speedOverGround_{};
143 double courseOverGround_{};
144 unsigned int date_{};
145 double magneticVariation_{};
146 char magneticVariationDirection_{};
147 char modeIndicator_{};
148 char navigationStatus_{};
149
150 RMC() = delete;
151
152 RMC(Message0183 baseMessage,
153 unsigned int utcFix,
154 char status,
155 double latitude,
156 char latitudeDirection,
157 double longitude,
158 char longitudeDirection,
159 double speedOverGround,
160 double courseOverGround,
161 unsigned int date,
162 double magneticVariation,
163 char magneticVariationDirection,
164 char modeIndicator,
165 char navigationStatus
166 ) noexcept;
167
168 static std::unique_ptr<RMC> create(std::unique_ptr<Message0183> baseMessage);
169 static std::string composeRaw(const std::string& talkerId, unsigned int utcFix,
170 char status,
171 double latitude,
172 char latitudeDirection,
173 double longitude,
174 char longitudeDirection,
175 double speedOverGround,
176 double courseOverGround,
177 unsigned int date,
178 double magneticVariation,
179 char magneticVariationDirection,
180 char modeIndicator,
181 char navigationStatus);
182
183 friend class Nmea0183Factory;
184 friend class MessageRegistry;
185};
186
187} // namespace nmea0183
188} // 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 RMC sentence.
Definition rmc.h:14
NotRMCException(const std::string &context, const std::string &details="")
Construct a NotRMCException with context and optional details.
Definition rmc.h:22
Represents a parsed NMEA 0183 RMC (Recommended Minimum Navigation Information) sentence.
Definition rmc.h:37
double getCourseOverGround() const noexcept
Get course over ground in degrees.
Definition rmc.cpp:263
char getLatitudeDirection() const noexcept
Get latitude hemisphere indicator ('N' or 'S').
Definition rmc.cpp:247
char getMagneticVariationDirection() const noexcept
Get magnetic variation direction ('E' or 'W').
Definition rmc.cpp:275
RMC(RMC &&) noexcept=default
double getMagneticVariation() const noexcept
Get magnetic variation in degrees.
Definition rmc.cpp:271
double getSpeedOverGround() const noexcept
Get speed over ground in knots.
Definition rmc.cpp:259
char getStatus() const noexcept
Get status indicator.
Definition rmc.cpp:239
std::string getStringContent(bool verbose) const noexcept override
Return a human-readable string representation of this message.
Definition rmc.cpp:158
double getLatitude() const noexcept
Get latitude in decimal degrees.
Definition rmc.cpp:243
char getModeIndicator() const noexcept
Get mode indicator character.
Definition rmc.cpp:279
std::unique_ptr< nmealib::Message > clone() const override
Create a polymorphic copy of this RMC message.
Definition rmc.cpp:154
unsigned int getUtcFix() const noexcept
Get UTC fix time in hhmmss[.ss] numeric form.
Definition rmc.cpp:235
RMC(std::string talkerId, unsigned int utcFix, char status, double latitude, char latitudeDirection, double longitude, char longitudeDirection, double speedOverGround, double courseOverGround, unsigned int date, double magneticVariation, char magneticVariationDirection, char modeIndicator, char navigationStatus)
Construct an RMC message from individual field values.
Definition rmc.cpp:123
double getLongitude() const noexcept
Get longitude in decimal degrees.
Definition rmc.cpp:251
unsigned int getDate() const noexcept
Get date in ddmmyy numeric form.
Definition rmc.cpp:267
char getNavigationStatus() const noexcept
Get navigation status character.
Definition rmc.cpp:283
RMC & operator=(const RMC &)=default
RMC(const RMC &)=default
char getLongitudeDirection() const noexcept
Get longitude hemisphere indicator ('E' or 'W').
Definition rmc.cpp:255