NMEA: detectio of the optional tag block in front of a sentence, ignoring it for...
[marnav.git] / src / marnav / nmea / mtw.cpp
blob1ba8ccf3dd4cae51162e6b3d10e956c407cf999f
1 #include "mtw.hpp"
2 #include <marnav/nmea/io.hpp>
4 namespace marnav
6 namespace nmea
8 MARNAV_NMEA_DEFINE_SENTENCE_PARSE_FUNC(mtw)
10 constexpr const char * mtw::TAG;
12 mtw::mtw()
13 : sentence(ID, TAG, talker_id::integrated_instrumentation)
17 mtw::mtw(talker talk, fields::const_iterator first, fields::const_iterator last)
18 : sentence(ID, TAG, talk)
20 if (std::distance(first, last) != 2)
21 throw std::invalid_argument{"invalid number of fields in mtw"};
23 read(*(first + 0), temperature);
24 read(*(first + 1), temperature_unit);
27 void mtw::set_temperature(double t) noexcept
29 temperature = t;
30 temperature_unit = unit::temperature::celsius;
33 std::vector<std::string> mtw::get_data() const
35 return {to_string(temperature), to_string(temperature_unit)};