nmealib 0.0.4
NMEA 0183/NMEA 2000 parsing library
Loading...
Searching...
No Matches
dpt.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 NotDPTException(const std::string& context, const std::string& details = "") :
23 NmeaException(context, "The sentence is not a DPT sentence", details) {}
24};
25
37class DPT : public Message0183 {
38public:
47 DPT(std::string talkerId,
48 double waterDepthMeters,
49 double transducerOffset,
50 double maxRangeScale
51 );
52
53 DPT(const DPT&) = default;
54 DPT& operator=(const DPT&) = default;
55 DPT(DPT&&) noexcept = default;
56 DPT& operator=(DPT&&) noexcept = default;
57
58 ~DPT() override = default;
59
65 std::unique_ptr<nmealib::Message> clone() const override;
66
68 double getWaterDepthMeters() const noexcept;
70 double getTransducerOffset() const noexcept;
72 double getMaxRangeScale() const noexcept;
73
80 std::string getStringContent(bool verbose) const noexcept override;
81
90 bool operator==(const DPT& other) const noexcept;
91
92private:
93 double waterDepthMeters_{};
94 double transducerOffset_{};
95 double maxRangeScale_{};
96
97 DPT() = delete;
98
99 DPT(Message0183 baseMessage,
100 double waterDepthMeters,
101 double transducerOffset,
102 double maxRangeScale
103 ) noexcept;
104
105 static std::unique_ptr<DPT> create(std::unique_ptr<Message0183> baseMessage);
106 static std::string composeRaw(const std::string& talkerId,
107 double waterDepthMeters,
108 double transducerOffset,
109 double maxRangeScale);
110
111 friend class Nmea0183Factory;
112 friend class MessageRegistry;
113};
114
115} // namespace nmea0183
116} // 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 DPT (Depth of Water) sentence.
Definition dpt.h:37
DPT(const DPT &)=default
DPT & operator=(const DPT &)=default
double getMaxRangeScale() const noexcept
Get maximum range scale in meters.
Definition dpt.cpp:119
std::string getStringContent(bool verbose) const noexcept override
Return a human-readable string representation of this message.
Definition dpt.cpp:80
double getTransducerOffset() const noexcept
Get transducer offset in meters.
Definition dpt.cpp:115
std::unique_ptr< nmealib::Message > clone() const override
Create a polymorphic copy of this DPT message.
Definition dpt.cpp:76
DPT(DPT &&) noexcept=default
double getWaterDepthMeters() const noexcept
Get water depth in meters.
Definition dpt.cpp:111
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 DPT sentence.
Definition dpt.h:14
NotDPTException(const std::string &context, const std::string &details="")
Construct a NotDPTException with context and optional details.
Definition dpt.h:22