NMEA: detectio of the optional tag block in front of a sentence, ignoring it for...
[marnav.git] / src / marnav / nmea / vbw.cpp
blob426146002ab6fb9463d280784c6227dbd03ba50b
1 #include "vbw.hpp"
2 #include <marnav/nmea/io.hpp>
4 namespace marnav
6 namespace nmea
8 MARNAV_NMEA_DEFINE_SENTENCE_PARSE_FUNC(vbw)
10 constexpr const char * vbw::TAG;
12 vbw::vbw()
13 : sentence(ID, TAG, talker_id::integrated_instrumentation)
17 vbw::vbw(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 vbw"};
23 read(*(first + 0), water_speed_longitudinal);
24 read(*(first + 1), water_speed_transveral);
25 read(*(first + 2), water_speed_status);
26 read(*(first + 3), ground_speed_longitudinal);
27 read(*(first + 4), ground_speed_transveral);
28 read(*(first + 5), water_speed_status);
31 void vbw::set_water_speed(double l, double t, status s) noexcept
33 water_speed_longitudinal = l;
34 water_speed_transveral = t;
35 water_speed_status = s;
38 void vbw::set_ground_speed(double l, double t, status s) noexcept
40 ground_speed_longitudinal = l;
41 ground_speed_transveral = t;
42 ground_speed_status = s;
45 std::vector<std::string> vbw::get_data() const
47 return {format(water_speed_longitudinal, 1), format(water_speed_transveral, 1),
48 to_string(water_speed_status), format(ground_speed_longitudinal, 1),
49 format(ground_speed_transveral, 1), to_string(ground_speed_status)};