NMEA: detectio of the optional tag block in front of a sentence, ignoring it for...
[marnav.git] / src / marnav / nmea / bww.cpp
blob2d86cbcae94bc09b08eabae71bdd7182ad6c733f
1 #include "bww.hpp"
2 #include <marnav/nmea/io.hpp>
4 namespace marnav
6 namespace nmea
8 MARNAV_NMEA_DEFINE_SENTENCE_PARSE_FUNC(bww)
10 constexpr const char * bww::TAG;
12 bww::bww()
13 : sentence(ID, TAG, talker_id::global_positioning_system)
17 bww::bww(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 bww"};
23 read(*(first + 0), bearing_true);
24 read(*(first + 1), bearing_true_ref);
25 read(*(first + 2), bearing_mag);
26 read(*(first + 3), bearing_mag_ref);
27 read(*(first + 4), waypoint_to);
28 read(*(first + 5), waypoint_from);
31 void bww::set_bearing_true(double t) noexcept
33 bearing_true = t;
34 bearing_true_ref = reference::TRUE;
37 void bww::set_bearing_mag(double t) noexcept
39 bearing_mag = t;
40 bearing_mag_ref = reference::MAGNETIC;
43 std::vector<std::string> bww::get_data() const
45 return {to_string(bearing_true), to_string(bearing_true_ref), to_string(bearing_mag),
46 to_string(bearing_mag_ref), to_string(waypoint_to), to_string(waypoint_from)};