NMEA: detectio of the optional tag block in front of a sentence, ignoring it for...
[marnav.git] / src / marnav / nmea / vwr.cpp
blob1e104748f85450b64e70c92ee5d3bb0e9022c251
1 #include "vwr.hpp"
2 #include <marnav/nmea/io.hpp>
4 namespace marnav
6 namespace nmea
8 MARNAV_NMEA_DEFINE_SENTENCE_PARSE_FUNC(vwr)
10 constexpr const char * vwr::TAG;
12 vwr::vwr()
13 : sentence(ID, TAG, talker_id::integrated_instrumentation)
17 vwr::vwr(talker talk, fields::const_iterator first, fields::const_iterator last)
18 : sentence(ID, TAG, talk)
20 if (std::distance(first, last) != 8)
21 throw std::invalid_argument{"invalid number of fields in vwr"};
23 read(*(first + 0), angle);
24 read(*(first + 1), angle_side);
25 read(*(first + 2), speed_knots);
26 read(*(first + 3), speed_knots_unit);
27 read(*(first + 4), speed_mps);
28 read(*(first + 5), speed_mps_unit);
29 read(*(first + 6), speed_kmh);
30 read(*(first + 7), speed_kmh_unit);
33 void vwr::set_angle(double angle, side s) noexcept
35 this->angle = angle;
36 this->angle_side = s;
39 void vwr::set_speed_knots(double t) noexcept
41 speed_knots = t;
42 speed_knots_unit = unit::velocity::knot;
45 void vwr::set_speed_mps(double t) noexcept
47 speed_mps = t;
48 speed_mps_unit = unit::velocity::mps;
51 void vwr::set_speed_kmh(double t) noexcept
53 speed_kmh = t;
54 speed_kmh_unit = unit::velocity::kmh;
57 std::vector<std::string> vwr::get_data() const
59 return {to_string(angle), to_string(angle_side), to_string(speed_knots),
60 to_string(speed_knots_unit), to_string(speed_mps), to_string(speed_mps_unit),
61 to_string(speed_kmh), to_string(speed_kmh_unit)};