NMEA: detectio of the optional tag block in front of a sentence, ignoring it for...
[marnav.git] / src / marnav / nmea / osd.cpp
blobf2ae9fee743e1950be86a02c8b8f51520f842ba6
1 #include "osd.hpp"
2 #include <marnav/nmea/io.hpp>
4 namespace marnav
6 namespace nmea
8 MARNAV_NMEA_DEFINE_SENTENCE_PARSE_FUNC(osd)
10 constexpr const char * osd::TAG;
12 osd::osd()
13 : sentence(ID, TAG, talker_id::integrated_instrumentation)
17 osd::osd(talker talk, fields::const_iterator first, fields::const_iterator last)
18 : sentence(ID, TAG, talk)
20 if (std::distance(first, last) != 9)
21 throw std::invalid_argument{"invalid number of fields in osd"};
23 read(*(first + 0), heading);
24 read(*(first + 1), data_valid);
25 read(*(first + 2), course);
26 read(*(first + 3), course_ref);
27 read(*(first + 4), speed);
28 read(*(first + 5), speed_unit);
29 read(*(first + 6), vessel_set);
30 read(*(first + 7), vessel_drift);
31 read(*(first + 8), vessel_drift_unit);
34 void osd::set_course(double t) noexcept
36 course = t;
37 course_ref = reference::TRUE;
40 void osd::set_speed(double t, unit::velocity u) noexcept
42 speed = t;
43 speed_unit = u;
46 void osd::set_drift(double t, unit::velocity u) noexcept
48 vessel_drift = t;
49 vessel_drift_unit = u;
52 std::vector<std::string> osd::get_data() const
54 return {to_string(heading), to_string(data_valid), to_string(course), to_string(course_ref),
55 to_string(speed), to_string(speed_unit), to_string(vessel_set), to_string(vessel_drift),
56 to_string(vessel_drift_unit)};