nmealib 0.0.4
NMEA 0183/NMEA 2000 parsing library
Loading...
Searching...
No Matches
xte.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 NotXTEException(const std::string& context, const std::string& details = "") :
25 NmeaException(context, "The sentence is not an XTE sentence", details) {}
26};
27
44class XTE : public Message0183 {
45public:
57 XTE(std::string talkerId,
58 char status1,
59 char status2,
60 double crossTrackError,
61 char steerDirection,
62 char crossTrackUnits,
63 std::optional<char> faaModeIndicator = std::nullopt
64 );
65
66 XTE(const XTE&) = default;
67 XTE& operator=(const XTE&) = default;
68 XTE(XTE&&) noexcept = default;
69 XTE& operator=(XTE&&) noexcept = default;
70
71 ~XTE() override = default;
72
78 std::unique_ptr<nmealib::Message> clone() const override;
79
81 char getStatus1() const noexcept;
83 char getStatus2() const noexcept;
85 double getCrossTrackError() const noexcept;
87 char getSteerDirection() const noexcept;
89 char getCrossTrackUnits() const noexcept;
91 bool hasFaaModeIndicator() const noexcept;
93 std::optional<char> getFaaModeIndicator() const noexcept;
94
101 std::string getStringContent(bool verbose) const noexcept override;
102
111 bool operator==(const XTE& other) const noexcept;
112
113private:
114 char status1_{};
115 char status2_{};
116 double crossTrackError_{};
117 char steerDirection_{};
118 char crossTrackUnits_{};
119 std::optional<char> faaModeIndicator_{};
120
121 XTE() = delete;
122
123 XTE(Message0183 baseMessage,
124 char status1,
125 char status2,
126 double crossTrackError,
127 char steerDirection,
128 char crossTrackUnits,
129 std::optional<char> faaModeIndicator
130 ) noexcept;
131
132 static std::unique_ptr<XTE> create(std::unique_ptr<Message0183> baseMessage);
133 static std::string composeRaw(const std::string& talkerId,
134 char status1,
135 char status2,
136 double crossTrackError,
137 char steerDirection,
138 char crossTrackUnits,
139 std::optional<char> faaModeIndicator);
140
141 friend class Nmea0183Factory;
142 friend class MessageRegistry;
143};
144
145} // namespace nmea0183
146} // 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 XTE sentence.
Definition xte.h:16
NotXTEException(const std::string &context, const std::string &details="")
Construct a NotXTEException with context and optional details.
Definition xte.h:24
Represents a parsed NMEA 0183 XTE (Cross-Track Error, Measured) sentence.
Definition xte.h:44
char getStatus1() const noexcept
Get the first status field.
Definition xte.cpp:162
double getCrossTrackError() const noexcept
Get the cross-track error magnitude in nautical miles.
Definition xte.cpp:170
char getCrossTrackUnits() const noexcept
Get the cross-track units indicator (typically 'N').
Definition xte.cpp:178
std::optional< char > getFaaModeIndicator() const noexcept
Get optional FAA mode indicator.
Definition xte.cpp:186
std::unique_ptr< nmealib::Message > clone() const override
Create a polymorphic copy of this XTE message.
Definition xte.cpp:98
XTE(XTE &&) noexcept=default
XTE & operator=(const XTE &)=default
char getSteerDirection() const noexcept
Get the steer direction indicator ('L' or 'R').
Definition xte.cpp:174
char getStatus2() const noexcept
Get the second status field.
Definition xte.cpp:166
XTE(const XTE &)=default
std::string getStringContent(bool verbose) const noexcept override
Return a human-readable string representation of this message.
Definition xte.cpp:102
bool hasFaaModeIndicator() const noexcept
Return whether FAA mode indicator is present.
Definition xte.cpp:182
XTE(std::string talkerId, char status1, char status2, double crossTrackError, char steerDirection, char crossTrackUnits, std::optional< char > faaModeIndicator=std::nullopt)
Construct an XTE message from individual field values.
Definition xte.cpp:77