nmealib 0.0.4
NMEA 0183/NMEA 2000 parsing library
Loading...
Searching...
No Matches
vwr.h
Go to the documentation of this file.
1#pragma once
2
3#include <nmealib/nmea0183.h>
4
5namespace nmealib {
6namespace nmea0183 {
7
12public:
13 explicit NotVWRException(const std::string& context, const std::string& details = "") :
14 NmeaException(context, "The sentence is not a VWR sentence", details) {}
15};
16
37class VWR : public Message0183 {
38public:
49 VWR(std::string talkerId,
50 double windAngle,
51 char windSide,
52 double speedKnots,
53 double speedMps,
54 double speedKph
55 );
56
57 VWR(const VWR&) = default;
58 VWR& operator=(const VWR&) = default;
59 VWR(VWR&&) noexcept = default;
60 VWR& operator=(VWR&&) noexcept = default;
61
62 ~VWR() override = default;
63
64 std::unique_ptr<nmealib::Message> clone() const override;
65
71 double getWindAngle() const noexcept;
72
78 char getWindSide() const noexcept;
79
85 double getSpeedKnots() const noexcept;
86
92 char getSpeedKnotsUnit() const noexcept;
93
99 double getSpeedMps() const noexcept;
100
106 char getSpeedMpsUnit() const noexcept;
107
113 double getSpeedKph() const noexcept;
114
120 char getSpeedKphUnit() const noexcept;
121
122 std::string getStringContent(bool verbose) const noexcept override;
123 bool operator==(const VWR& other) const noexcept;
124
125private:
126 double windAngle_{};
127 char windSide_{};
128 double speedKnots_{};
129 char speedKnotsUnit_{};
130 double speedMps_{};
131 char speedMpsUnit_{};
132 double speedKph_{};
133 char speedKphUnit_{};
134
135 VWR() = delete;
136
137 VWR(Message0183 baseMessage,
138 double windAngle,
139 char windSide,
140 double speedKnots,
141 char speedKnotsUnit,
142 double speedMps,
143 char speedMpsUnit,
144 double speedKph,
145 char speedKphUnit
146 ) noexcept;
147
148 static std::unique_ptr<VWR> create(std::unique_ptr<Message0183> baseMessage);
149 static std::string composeRaw(const std::string& talkerId,
150 double windAngle,
151 char windSide,
152 double speedKnots,
153 double speedMps,
154 double speedKph);
155
156 friend class Nmea0183Factory;
157 friend class MessageRegistry;
158};
159
160} // namespace nmea0183
161} // 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 that is not a VWR sentence is processed as one.
Definition vwr.h:11
NotVWRException(const std::string &context, const std::string &details="")
Definition vwr.h:13
Represents a parsed NMEA 0183 VWR sentence (Relative Wind Speed and Angle).
Definition vwr.h:37
VWR & operator=(const VWR &)=default
double getSpeedKph() const noexcept
Returns the wind speed in kilometers per hour.
Definition vwr.cpp:175
double getWindAngle() const noexcept
Returns the wind direction magnitude in degrees (0–180).
Definition vwr.cpp:151
char getSpeedKnotsUnit() const noexcept
Returns the knots unit indicator character.
Definition vwr.cpp:163
VWR(std::string talkerId, double windAngle, char windSide, double speedKnots, double speedMps, double speedKph)
Construct a VWR sentence from individual field values.
Definition vwr.cpp:86
VWR(const VWR &)=default
char getSpeedMpsUnit() const noexcept
Returns the meters-per-second unit indicator character.
Definition vwr.cpp:171
char getWindSide() const noexcept
Returns the wind direction side relative to the vessel.
Definition vwr.cpp:155
std::string getStringContent(bool verbose) const noexcept override
Returns a human-readable string representation of the message content.
Definition vwr.cpp:111
double getSpeedKnots() const noexcept
Returns the wind speed in knots.
Definition vwr.cpp:159
std::unique_ptr< nmealib::Message > clone() const override
Creates a polymorphic deep copy of this Message0183.
Definition vwr.cpp:107
double getSpeedMps() const noexcept
Returns the wind speed in meters per second.
Definition vwr.cpp:167
char getSpeedKphUnit() const noexcept
Returns the kilometers-per-hour unit indicator character.
Definition vwr.cpp:179
VWR(VWR &&) noexcept=default