NMEA: detectio of the optional tag block in front of a sentence, ignoring it for...
[marnav.git] / src / marnav / nmea / vdr.cpp
blobf857d7afceec5a9b06bcf05a70e0242d6df21ef2
1 #include "vdr.hpp"
2 #include <marnav/nmea/io.hpp>
4 namespace marnav
6 namespace nmea
8 MARNAV_NMEA_DEFINE_SENTENCE_PARSE_FUNC(vdr)
10 constexpr const char * vdr::TAG;
12 vdr::vdr()
13 : sentence(ID, TAG, talker_id::integrated_instrumentation)
17 vdr::vdr(talker talk, fields::const_iterator first, fields::const_iterator last)
18 : sentence(ID, TAG, talk)
20 if (std::distance(first, last) != 6)
21 throw std::invalid_argument{"invalid number of fields in vdr"};
23 read(*(first + 0), degrees_true);
24 read(*(first + 1), degrees_true_ref);
25 read(*(first + 2), degrees_mag);
26 read(*(first + 3), degrees_mag_ref);
27 read(*(first + 4), speed);
28 read(*(first + 5), speed_unit);
31 void vdr::set_degrees_true(double t) noexcept
33 degrees_true = t;
34 degrees_true_ref = reference::TRUE;
37 void vdr::set_degrees_mag(double t) noexcept
39 degrees_mag = t;
40 degrees_mag_ref = reference::MAGNETIC;
43 void vdr::set_speed(double t) noexcept
45 speed = t;
46 speed_unit = unit::velocity::knot;
49 std::vector<std::string> vdr::get_data() const
51 return {to_string(degrees_true), to_string(degrees_true_ref), to_string(degrees_mag),
52 to_string(degrees_mag_ref), to_string(speed), to_string(speed_unit)};