1 #include <marnav/nmea/vbw.hpp>
2 #include <marnav/nmea/io.hpp>
9 constexpr sentence_id
vbw::ID
;
10 constexpr const char * vbw::TAG
;
13 : sentence(ID
, TAG
, talker::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(units::velocity l
, units::velocity t
, status s
)
33 water_speed_longitudinal_
= l
.get
<units::knots
>();
34 water_speed_transveral_
= t
.get
<units::knots
>();
35 water_speed_status_
= s
;
38 void vbw::set_ground_speed(units::velocity l
, units::velocity t
, status s
)
40 ground_speed_longitudinal_
= l
.get
<units::knots
>();
41 ground_speed_transveral_
= t
.get
<units::knots
>();
42 ground_speed_status_
= s
;
45 utils::optional
<units::velocity
> vbw::get_water_speed_longitudinal() const
47 if (ground_speed_longitudinal_
)
49 return {*ground_speed_longitudinal_
};
52 utils::optional
<units::velocity
> vbw::get_water_speed_transveral() const
54 if (water_speed_transveral_
)
56 return {*water_speed_transveral_
};
59 utils::optional
<units::velocity
> vbw::get_ground_speed_longitudinal() const
61 if (ground_speed_longitudinal_
)
63 return {*ground_speed_longitudinal_
};
66 utils::optional
<units::velocity
> vbw::get_ground_speed_transveral() const
68 if (ground_speed_transveral_
)
70 return {*ground_speed_transveral_
};
73 void vbw::append_data_to(std::string
& s
) const
75 append(s
, format(water_speed_longitudinal_
, 1));
76 append(s
, format(water_speed_transveral_
, 1));
77 append(s
, to_string(water_speed_status_
));
78 append(s
, format(ground_speed_longitudinal_
, 1));
79 append(s
, format(ground_speed_transveral_
, 1));
80 append(s
, to_string(ground_speed_status_
));