2 #include <marnav/nmea/checks.hpp>
3 #include <marnav/nmea/io.hpp>
9 MARNAV_NMEA_DEFINE_SENTENCE_PARSE_FUNC(ttm
)
11 constexpr const char * ttm::TAG
;
14 : sentence(ID
, TAG
, talker_id::global_positioning_system
)
18 ttm::ttm(talker talk
, fields::const_iterator first
, fields::const_iterator last
)
19 : sentence(ID
, TAG
, talk
)
21 // according to http://catb.org/gpsd/NMEA.html#_ttm_tracked_target_message
22 // there are fields 14 and 15, but not supported by this implementation.
24 const auto dist
= std::distance(first
, last
);
26 if ((dist
< 13) || (dist
> 15))
27 throw std::invalid_argument
{"invalid number of fields in ttm"};
29 read(*(first
+ 0), target_number
);
30 read(*(first
+ 1), target_distance
);
31 read(*(first
+ 2), bearing_from_ownship
);
32 read(*(first
+ 3), bearing_from_ownship_ref
);
33 read(*(first
+ 4), target_speed
);
34 read(*(first
+ 5), target_course
);
35 read(*(first
+ 6), target_course_ref
);
36 read(*(first
+ 7), distance_cpa
);
37 read(*(first
+ 8), tcpa
);
38 read(*(first
+ 9), unknown
);
39 read(*(first
+ 10), target_name
);
40 read(*(first
+ 11), target_status
);
41 read(*(first
+ 12), reference_target
);
44 std::vector
<std::string
> ttm::get_data() const
46 return {format(target_number
, 2), to_string(target_distance
),
47 to_string(bearing_from_ownship
), to_string(bearing_from_ownship_ref
),
48 to_string(target_speed
), to_string(target_course
), to_string(target_course_ref
),
49 to_string(distance_cpa
), to_string(tcpa
), to_string(unknown
), to_string(target_name
),
50 to_string(target_status
), to_string(reference_target
)};