Skip to main content

WindTracker

Struct WindTracker 

Source
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

Source

pub fn new() -> Self

No readings yet.

Source

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.

Source

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

Source§

fn clone(&self) -> WindTracker

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for WindTracker

Source§

impl Debug for WindTracker

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for WindTracker

Source§

fn default() -> WindTracker

Returns the “default value” for a type. Read more
Source§

impl PartialEq for WindTracker

Source§

fn eq(&self, other: &WindTracker) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for WindTracker

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.