nmealib 0.0.4
NMEA 0183/NMEA 2000 parsing library
Loading...
Searching...
No Matches
vhw.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 NotVHWException(const std::string& context, const std::string& details = "") :
23 NmeaException(context, "The sentence is not a VHW sentence", details) {}
24};
25
36class VHW : public Message0183 {
37public:
50 VHW(std::string talkerId,
51 double headingTrue,
52 double headingMagnetic,
53 double speedKnots,
54 double speedKph
55 );
56
57 VHW(const VHW&) = default;
58 VHW& operator=(const VHW&) = default;
59 VHW(VHW&&) noexcept = default;
60 VHW& operator=(VHW&&) noexcept = default;
61
62 ~VHW() override = default;
63
69 std::unique_ptr<nmealib::Message> clone() const override;
70
72 double getHeadingTrue() const noexcept;
74 char getHeadingTrueType() const noexcept;
76 double getHeadingMagnetic() const noexcept;
78 char getHeadingMagneticType() const noexcept;
80 double getSpeedKnots() const noexcept;
82 char getSpeedKnotsType() const noexcept;
84 double getSpeedKph() const noexcept;
86 char getSpeedKphType() const noexcept;
87
94 std::string getStringContent(bool verbose) const noexcept override;
95
104 bool operator==(const VHW& other) const noexcept;
105
106private:
107 double headingTrue_{};
108 char headingTrueType_{};
109 double headingMagnetic_{};
110 char headingMagneticType_{};
111 double speedKnots_{};
112 char speedKnotsType_{};
113 double speedKph_{};
114 char speedKphType_{};
115
116 VHW() = delete;
117
118 VHW(Message0183 baseMessage,
119 double headingTrue,
120 char headingTrueType,
121 double headingMagnetic,
122 char headingMagneticType,
123 double speedKnots,
124 char speedKnotsType,
125 double speedKph,
126 char speedKphType
127 ) noexcept;
128
129 static std::unique_ptr<VHW> create(std::unique_ptr<Message0183> baseMessage);
130 static std::string composeRaw(const std::string& talkerId,
131 double headingTrue,
132 double headingMagnetic,
133 double speedKnots,
134 double speedKph);
135
136 friend class Nmea0183Factory;
137 friend class MessageRegistry;
138};
139
140} // namespace nmea0183
141} // 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 VHW sentence.
Definition vhw.h:14
NotVHWException(const std::string &context, const std::string &details="")
Construct a NotVHWException with context and optional details.
Definition vhw.h:22
Represents a parsed NMEA 0183 VHW (Water Speed and Heading) sentence.
Definition vhw.h:36
std::unique_ptr< nmealib::Message > clone() const override
Create a polymorphic copy of this VHW message.
Definition vhw.cpp:105
char getSpeedKphType() const noexcept
Get km/h unit indicator (typically 'K').
Definition vhw.cpp:174
char getHeadingTrueType() const noexcept
Get true heading type indicator (typically 'T').
Definition vhw.cpp:150
double getHeadingMagnetic() const noexcept
Get magnetic heading in degrees.
Definition vhw.cpp:154
VHW & operator=(const VHW &)=default
VHW(VHW &&) noexcept=default
std::string getStringContent(bool verbose) const noexcept override
Return a human-readable string representation of this message.
Definition vhw.cpp:109
double getHeadingTrue() const noexcept
Get true heading in degrees.
Definition vhw.cpp:146
char getHeadingMagneticType() const noexcept
Get magnetic heading type indicator (typically 'M').
Definition vhw.cpp:158
double getSpeedKph() const noexcept
Get speed through water in kilometers per hour.
Definition vhw.cpp:170
double getSpeedKnots() const noexcept
Get speed through water in knots.
Definition vhw.cpp:162
VHW(std::string talkerId, double headingTrue, double headingMagnetic, double speedKnots, double speedKph)
Construct a VHW message from individual field values.
Definition vhw.cpp:86
char getSpeedKnotsType() const noexcept
Get knots unit indicator (typically 'N').
Definition vhw.cpp:166
VHW(const VHW &)=default