pub struct WindTracker { /* private fields */ }Expand description
Keeps the latest of each of the four wind readings Signal K can carry,
each with when it arrived, and resolves them to one Wind on
demand.
Implementations§
Source§impl WindTracker
impl WindTracker
Sourcepub fn record(&mut self, measurement: Measurement, now: Duration) -> bool
pub fn record(&mut self, measurement: Measurement, now: Duration) -> bool
Records one measurement, if it is a wind reading – returns
whether it was. Anything else is left for the caller to handle;
this never touches [fix::FixBuilder] or any other measurement
kind, the same separation crate::apply_measurement itself
keeps by only ever recognising the four fields a fix is made of.
now is the caller’s own clock – the same basis Self::wind
later judges freshness against, passed in rather than read from
the system clock so that a recorded stream of deltas replays
identically.
Sourcepub fn wind(
&self,
now: Duration,
heading_deg: Option<f64>,
sog_kn: f64,
good_for: Duration,
) -> Option<Wind>
pub fn wind( &self, now: Duration, heading_deg: Option<f64>, sog_kn: f64, good_for: Duration, ) -> Option<Wind>
The vessel’s true wind, however it can currently be determined.
now and good_for decide freshness together – see
DEFAULT_WIND_GOOD_FOR for a reasonable good_for when the
caller has no reason to choose its own. heading_deg and
sog_kn are the vessel’s own motion, needed only for the
fallback path below.
Prefers the server’s own directionTrue/speedTrue when both
are fresh: an installation that computes true wind for itself
may know things this cannot – current, calibration, a better
sensor. Falls back to deriving it from apparent wind and the
vessel’s own motion, via [nav_math::wind], when the server
does not.
None when neither path has anything fresh enough, or – for
the fallback path – when there is no heading to measure the
apparent angle against. Never a stale number quietly reused.
§The one approximation this makes
Deriving true wind from apparent wants speed through water –
[nav_math::wind]’s own doc calls this “the sailing wind”, the
one polar data and laylines are indexed by. Plenty of vessels
have no paddlewheel reading, only speed over ground; sog_kn
stands in for it here, and the two differ by the current vector,
which is exactly the error this introduces. Reason enough to
prefer the server’s own calculation whenever it publishes one.
Trait Implementations§
Source§impl Clone for WindTracker
impl Clone for WindTracker
Source§fn clone(&self) -> WindTracker
fn clone(&self) -> WindTracker
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for WindTracker
Source§impl Debug for WindTracker
impl Debug for WindTracker
Source§impl Default for WindTracker
impl Default for WindTracker
Source§fn default() -> WindTracker
fn default() -> WindTracker
Source§impl PartialEq for WindTracker
impl PartialEq for WindTracker
Source§fn eq(&self, other: &WindTracker) -> bool
fn eq(&self, other: &WindTracker) -> bool
self and other values to be equal, and is used by ==.