NMEA: detectio of the optional tag block in front of a sentence, ignoring it for...
[marnav.git] / src / marnav / nmea / ttm.hpp
blob34d1d2202dd42da59c3384d9ab1cd3529b125bdf
1 #ifndef __MARNAV__NMEA__TTM__HPP__
2 #define __MARNAV__NMEA__TTM__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(ttm)
13 /// @brief TTM - Tracked Target Message
14 ///
15 /// @code
16 /// 11 13
17 /// 1 2 3 4 5 6 7 8 9 10| 12| 14
18 /// | | | | | | | | | | | | | |
19 /// $--TTM,xx,x.x,x.x,a,x.x,x.x,a,x.x,x.x,a,c--c,a,a*hh<CR><LF>
20 /// @endcode
21 ///
22 /// Field Number:
23 /// 1. Target Number (00-99)
24 /// 2. Target Distance
25 /// 3. Bearing from own ship
26 /// 4. Bearing reference
27 /// - T = True
28 /// - R = Relative
29 /// 5. Target Speed
30 /// 6. Target Course
31 /// 7. Target Course reference
32 /// - T = True
33 /// - R = Relative
34 /// 8. Distance of closest-point-of-approach
35 /// 9. Time until closest-point-of-approach "-" means increasing
36 /// 10. ?
37 /// 11. Target name
38 /// 12. Target Status
39 /// 13. Reference Target
40 ///
41 /// @note Field 14 and 15 are not supported right now due to lack of
42 /// documentation. The sentence just ignores them. The other fields
43 /// are being processed.
44 ///
45 class ttm : public sentence
47 MARNAV_NMEA_SENTENCE_FRIENDS(ttm)
49 public:
50 constexpr static const sentence_id ID = sentence_id::TTM;
51 constexpr static const char * TAG = "TTM";
53 ttm();
54 ttm(const ttm &) = default;
55 ttm & operator=(const ttm &) = default;
56 ttm(ttm &&) = default;
57 ttm & operator=(ttm &&) = default;
59 protected:
60 ttm(talker talk, fields::const_iterator first, fields::const_iterator last);
61 virtual std::vector<std::string> get_data() const override;
63 private:
64 utils::optional<uint32_t> target_number;
65 utils::optional<double> target_distance;
66 utils::optional<double> bearing_from_ownship;
67 utils::optional<reference> bearing_from_ownship_ref;
68 utils::optional<double> target_speed;
69 utils::optional<double> target_course;
70 utils::optional<reference> target_course_ref;
71 utils::optional<double> distance_cpa; ///< Distance to closest point of approach
72 utils::optional<double> tcpa;
73 utils::optional<char> unknown;
74 utils::optional<std::string> target_name;
75 utils::optional<char> target_status;
76 utils::optional<char> reference_target;
78 public:
79 decltype(target_number) get_target_number() const { return target_number; }
80 decltype(target_distance) get_target_distance() const { return target_distance; }
81 decltype(bearing_from_ownship) get_bearing_from_ownship() const
83 return bearing_from_ownship;
85 decltype(bearing_from_ownship_ref) get_bearing_from_ownship_ref() const
87 return bearing_from_ownship_ref;
89 decltype(target_speed) get_target_speed() const { return target_speed; }
90 decltype(target_course) get_target_course() const { return target_course; }
91 decltype(target_course_ref) get_target_course_ref() const { return target_course_ref; }
92 decltype(distance_cpa) get_distance_cpa() const { return distance_cpa; }
93 decltype(tcpa) get_tcpa() const { return tcpa; }
94 decltype(unknown) get_unknown() const { return unknown; }
95 decltype(target_name) get_target_name() const { return target_name; }
96 decltype(target_status) get_target_status() const { return target_status; }
97 decltype(reference_target) get_reference_target() const { return reference_target; }
99 void set_target_number(uint32_t t) noexcept { target_number = t; }
100 void set_target_distance(double t) noexcept { target_distance = t; }
101 void set_bearing_from_ownship(double t, reference r) noexcept
103 bearing_from_ownship = t;
104 bearing_from_ownship_ref = r;
106 void set_target_speed(double t) noexcept { target_speed = t; }
107 void set_target_course(double t, reference r) noexcept
109 target_course = t;
110 target_course_ref = r;
112 void set_distance_cpa(double t) noexcept { distance_cpa = t; }
113 void set_tcpa(double t) noexcept { tcpa = t; }
114 void set_unknown(char t) noexcept { unknown = t; }
115 void set_target_name(const std::string & t) { target_name = t; }
116 void set_target_status(char t) noexcept { target_status = t; }
117 void set_reference_target(char t) noexcept { reference_target = t; }
122 #endif