NMEA: detectio of the optional tag block in front of a sentence, ignoring it for...
[marnav.git] / src / marnav / nmea / dbt.hpp
blob1c7ae9da7bdca276534e083b17034735e2c904a7
1 #ifndef __MARNAV__NMEA__DBT__HPP__
2 #define __MARNAV__NMEA__DBT__HPP__
4 #include <marnav/nmea/sentence.hpp>
5 #include <marnav/utils/optional.hpp>
7 namespace marnav
9 namespace nmea
11 MARNAV_NMEA_DECLARE_SENTENCE_PARSE_FUNC(dbt)
13 /// @brief DBT - Depth Below Transducer
14 ///
15 /// @code
16 /// 1 2 3 4 5 6
17 /// | | | | | |
18 /// $--DBT,x.x,f,x.x,M,x.x,F*hh<CR><LF>
19 /// @endcode
20 ///
21 /// Field Number:
22 /// 1. Depth feet
23 /// 2. Depth feet unit
24 /// - f = feet
25 /// 3. Depth meters
26 /// 4. Depth meters unit
27 /// - M = meters
28 /// 5. Depth Fathoms
29 /// 6. Depth Fathoms unit
30 /// - F = Fathoms
31 ///
32 /// In real-world sensors, sometimes not all three conversions are reported.
33 /// So you night see something like <tt>$SDDBT,,f,22.5,M,,F*cs</tt>
34 ///
35 class dbt : public sentence
37 MARNAV_NMEA_SENTENCE_FRIENDS(dbt)
39 public:
40 constexpr static const sentence_id ID = sentence_id::DBT;
41 constexpr static const char * TAG = "DBT";
43 dbt();
44 dbt(const dbt &) = default;
45 dbt & operator=(const dbt &) = default;
46 dbt(dbt &&) = default;
47 dbt & operator=(dbt &&) = default;
49 protected:
50 dbt(talker talk, fields::const_iterator first, fields::const_iterator last);
51 virtual std::vector<std::string> get_data() const override;
53 private:
54 utils::optional<double> depth_feet; // water depth in feet
55 utils::optional<unit::distance> depth_feet_unit; // f:feet
56 utils::optional<double> depth_meter; // water depth in meter
57 utils::optional<unit::distance> depth_meter_unit; // M:meter
58 utils::optional<double> depth_fathom; // water depth in fathom
59 utils::optional<unit::distance> depth_fathom_unit; // F:fathom
61 public:
62 decltype(depth_feet) get_depth_feet() const { return depth_feet; }
63 decltype(depth_feet_unit) get_depth_feet_unit() const { return depth_feet_unit; }
64 decltype(depth_meter) get_depth_meter() const { return depth_meter; }
65 decltype(depth_meter_unit) get_depth_meter_unit() const { return depth_meter_unit; }
66 decltype(depth_fathom) get_depth_fathom() const { return depth_fathom; }
67 decltype(depth_fathom_unit) get_depth_fathom_unit() const { return depth_fathom_unit; }
69 void set_depth_feet(double t) noexcept;
70 void set_depth_meter(double t) noexcept;
71 void set_depth_fathom(double t) noexcept;
76 #endif