2 #include <marnav/nmea/io.hpp>
8 MARNAV_NMEA_DEFINE_SENTENCE_PARSE_FUNC(rpm
)
12 /// Converts data read from the NMEA string to the corresponding
15 /// @param[in] value The numerical value to convert.
16 /// @return The corresponding enumerator.
17 /// @exception std::invalid_argument The specified value to convert is unknown.
19 static rpm::source_id
source_id_mapping(
20 typename
std::underlying_type
<rpm::source_id
>::type value
)
24 return rpm::source_id::shaft
;
26 return rpm::source_id::engine
;
28 throw std::invalid_argument
{"invaild value for conversion to rpm::source_id"};
32 std::string
to_string(rpm::source_id value
)
35 case rpm::source_id::shaft
:
37 case rpm::source_id::engine
:
40 throw std::invalid_argument
{"invaild value for conversion of rpm::source_id"};
43 constexpr const char * rpm::TAG
;
46 : sentence(ID
, TAG
, talker_id::integrated_instrumentation
)
50 rpm::rpm(talker talk
, fields::const_iterator first
, fields::const_iterator last
)
51 : sentence(ID
, TAG
, talk
)
53 if (std::distance(first
, last
) != 5)
54 throw std::invalid_argument
{"invalid number of fields in rpm"};
56 read(*(first
+ 0), source
, source_id_mapping
);
57 read(*(first
+ 1), source_number
);
58 read(*(first
+ 2), revolutions
);
59 read(*(first
+ 3), propeller_pitch
);
60 read(*(first
+ 4), data_valid
);
63 void rpm::set_source(source_id id
, uint32_t num
)
69 std::vector
<std::string
> rpm::get_data() const
71 return {to_string(source
), to_string(source_number
), format(revolutions
, 1),
72 format(propeller_pitch
, 1), to_string(data_valid
)};