nmealib 0.0.4
NMEA 0183/NMEA 2000 parsing library
Loading...
Searching...
No Matches
gsa.h
Go to the documentation of this file.
1#pragma once
2
3#include <nmealib/nmea0183.h>
4
5#include <array>
6#include <optional>
7
8namespace nmealib {
9namespace nmea0183 {
10
18public:
25 explicit NotGSAException(const std::string& context, const std::string& details = "") :
26 NmeaException(context, "The sentence is not a GSA sentence", details) {}
27};
28
40class GSA : public Message0183 {
41public:
54 GSA(std::string talkerId,
55 char selectionMode,
56 unsigned int mode,
57 std::array<unsigned int, 12> satelliteIds,
58 double pdop,
59 double hdop,
60 double vdop,
61 std::optional<unsigned int> systemId = std::nullopt
62 );
63
64 GSA(const GSA&) = default;
65 GSA& operator=(const GSA&) = default;
66 GSA(GSA&&) noexcept = default;
67 GSA& operator=(GSA&&) noexcept = default;
68
69 ~GSA() override = default;
70
76 std::unique_ptr<nmealib::Message> clone() const override;
77
79 char getSelectionMode() const noexcept;
81 unsigned int getMode() const noexcept;
83 std::array<unsigned int, 12> getSatelliteIds() const noexcept;
90 unsigned int getSatelliteId(size_t index) const noexcept;
92 double getPdop() const noexcept;
94 double getHdop() const noexcept;
96 double getVdop() const noexcept;
98 bool hasSystemId() const noexcept;
100 std::optional<unsigned int> getSystemId() const noexcept;
101
108 std::string getStringContent(bool verbose) const noexcept override;
109
118 bool operator==(const GSA& other) const noexcept;
119
120private:
121 char selectionMode_{};
122 unsigned int mode_{};
123 std::array<unsigned int, 12> satelliteIds_{};
124 double pdop_{};
125 double hdop_{};
126 double vdop_{};
127 std::optional<unsigned int> systemId_{};
128
129 GSA() = delete;
130
131 GSA(Message0183 baseMessage,
132 char selectionMode,
133 unsigned int mode,
134 std::array<unsigned int, 12> satelliteIds,
135 double pdop,
136 double hdop,
137 double vdop,
138 std::optional<unsigned int> systemId
139 ) noexcept;
140
141 static std::unique_ptr<GSA> create(std::unique_ptr<Message0183> baseMessage);
142 static std::string composeRaw(const std::string& talkerId,
143 char selectionMode,
144 unsigned int mode,
145 std::array<unsigned int, 12> satelliteIds,
146 double pdop,
147 double hdop,
148 double vdop,
149 std::optional<unsigned int> systemId);
150
151 friend class Nmea0183Factory;
152 friend class MessageRegistry;
153};
154
155} // namespace nmea0183
156} // 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 a parsed NMEA 0183 GSA (GNSS DOP and Active Satellites) sentence.
Definition gsa.h:40
GSA & operator=(const GSA &)=default
bool hasSystemId() const noexcept
Return whether an optional system ID is present.
Definition gsa.cpp:234
GSA(std::string talkerId, char selectionMode, unsigned int mode, std::array< unsigned int, 12 > satelliteIds, double pdop, double hdop, double vdop, std::optional< unsigned int > systemId=std::nullopt)
Construct a GSA message from individual field values.
Definition gsa.cpp:98
GSA(const GSA &)=default
unsigned int getSatelliteId(size_t index) const noexcept
Get one satellite ID by slot index.
Definition gsa.cpp:218
double getVdop() const noexcept
Get VDOP value.
Definition gsa.cpp:230
GSA(GSA &&) noexcept=default
std::unique_ptr< nmealib::Message > clone() const override
Create a polymorphic copy of this GSA message.
Definition gsa.cpp:122
std::optional< unsigned int > getSystemId() const noexcept
Get optional GNSS system ID.
Definition gsa.cpp:238
double getHdop() const noexcept
Get HDOP value.
Definition gsa.cpp:226
double getPdop() const noexcept
Get PDOP value.
Definition gsa.cpp:222
unsigned int getMode() const noexcept
Get fix dimension mode.
Definition gsa.cpp:210
std::array< unsigned int, 12 > getSatelliteIds() const noexcept
Get all 12 satellite ID slots (0 for empty).
Definition gsa.cpp:214
char getSelectionMode() const noexcept
Get selection mode indicator.
Definition gsa.cpp:206
std::string getStringContent(bool verbose) const noexcept override
Return a human-readable string representation of this message.
Definition gsa.cpp:126
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 GSA sentence.
Definition gsa.h:17
NotGSAException(const std::string &context, const std::string &details="")
Construct a NotGSAException with context and optional details.
Definition gsa.h:25