NMEA: detectio of the optional tag block in front of a sentence, ignoring it for...
[marnav.git] / src / marnav / nmea / xtr.hpp
blob6776614f356d0612815ef7382d54ddc8fc4a0ac3
1 #ifndef __MARNAV__NMEA__XTR__HPP__
2 #define __MARNAV__NMEA__XTR__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(xtr)
13 /// @brief XTR - Cross Track Error - Dead Reckoning
14 ///
15 /// @code
16 /// 1 2 3
17 /// | | |
18 /// $--XTR,x.x,a,N*hh<CR><LF>
19 /// @endcode
20 ///
21 /// Field Number:
22 /// 1. Magnitude of cross track error
23 /// 2. Direction to steer
24 /// - L = left
25 /// - R = right
26 /// 3. Unit
27 /// - N = Nautical Miles
28 ///
29 class xtr : public sentence
31 MARNAV_NMEA_SENTENCE_FRIENDS(xtr)
33 public:
34 constexpr static const sentence_id ID = sentence_id::XTR;
35 constexpr static const char * TAG = "XTR";
37 xtr();
38 xtr(const xtr &) = default;
39 xtr & operator=(const xtr &) = default;
40 xtr(xtr &&) = default;
41 xtr & operator=(xtr &&) = default;
43 protected:
44 xtr(talker talk, fields::const_iterator first, fields::const_iterator last);
45 virtual std::vector<std::string> get_data() const override;
47 private:
48 utils::optional<double> cross_track_error_magnitude;
49 utils::optional<side> direction_to_steer;
50 utils::optional<unit::distance> cross_track_unit;
52 public:
53 decltype(cross_track_error_magnitude) get_cross_track_error_magnitude() const
55 return cross_track_error_magnitude;
57 decltype(direction_to_steer) get_direction_to_steer() const { return direction_to_steer; }
58 decltype(cross_track_unit) get_cross_track_unit() const { return cross_track_unit; }
60 void set_cross_track_error_magnitude(double t) noexcept
62 cross_track_error_magnitude = t;
63 cross_track_unit = unit::distance::nm;
65 void set_direction_to_steer(side t) noexcept { direction_to_steer = t; }
70 #endif