Skip to main content

Module observation

Module observation 

Source
Expand description

Observed value: time and quality.

A sensor reading is a statement about the world at an instant, with an uncertainty, from a source that may be degraded. Displays, estimators and alarms all need the same three facts, so they are kept in one wrapper instead of repeated on every reading type.

Age is not stored: it depends on the evaluation time and would be wrong immediately. Use Observed::age_at.

use core::time::Duration;
use kinavis_kernel::observation::{Observed, ObservationStatus, Quality};
use kinavis_kernel::time::{Civil, Instant, Utc};
use kinavis_kernel::{Distance, Position};

let taken_at = Instant::<Utc>::from_civil(Civil::date(2026, 9, 11))?;
let fix = Observed::new(
    "50°45.3'N 001°20.0'W".parse::<Position>()?,
    taken_at,
    Quality::new(ObservationStatus::Valid).with_sigma(Distance::from_metres(5.0)?),
);

let now = taken_at.saturating_add(Duration::from_secs(90));
assert_eq!(fix.age_at(now)?, Duration::from_secs(90));
assert!(fix.is_stale_at(now, Duration::from_secs(60)));
assert!(!fix.is_stale_at(now, Duration::from_secs(120)));

Structs§

Observed
Value with its observation time and quality.
Quality
Reading quality: status and optional 1σ uncertainty.

Enums§

ObservationStatus
Source-reported validity of a reading.