pub struct ExportFilter<T> {
settings: ChannelFilterSettings,
block: usize,
probe: VecDeque<(i64, f64, T)>,
segment: Option<Segment>,
queue: VecDeque<Entry<T>>,
ready: usize,
scratch: Vec<f64>,
}Expand description
Rows of one channel, in time order, filtered with the zero-phase pipeline.
Rows go in one at a time with Self::push and come out, in the same order, with
their filtered value once it is settled. The sample interval is taken as the median
step of the first rows of each segment. A step of up to
MAX_FILLED_GAP_SAMPLES missing samples is filled with NaN; a longer gap, a
step that is not close to a whole number of intervals, or a new rate ends the
segment and every filter (templates included) starts over. Rows whose timestamp is
not after the previous one are passed through with NaN.
Memory stays bounded: once block + margin samples wait, the backward pass runs
from the newest sample (its state settled over margin samples) and the oldest
block rows come out.
Fields§
§settings: ChannelFilterSettings§block: usize§probe: VecDeque<(i64, f64, T)>Rows waiting for the interval to be estimated.
segment: Option<Segment>§queue: VecDeque<Entry<T>>§ready: usizeEntries at the front of queue whose forward value is known.
scratch: Vec<f64>Implementations§
Source§impl<T> ExportFilter<T>
impl<T> ExportFilter<T>
pub fn new(settings: ChannelFilterSettings) -> Self
pub fn with_block(settings: ChannelFilterSettings, block: usize) -> Self
Sourcepub fn push(
&mut self,
timestamp_ns: i64,
raw: f64,
row: T,
calibrate: &dyn Fn(&T, f64) -> f64,
out: &mut Vec<FilteredRow<T>>,
)
pub fn push( &mut self, timestamp_ns: i64, raw: f64, row: T, calibrate: &dyn Fn(&T, f64) -> f64, out: &mut Vec<FilteredRow<T>>, )
Adds one row and appends the rows that are done to out.
timestamp_ns- Sample time.raw- Raw value.row- The caller’s row, handed back with the filtered value.calibrate- Converts a (filtered) raw value of a row into its unit.
Sourcepub fn finish(
&mut self,
calibrate: &dyn Fn(&T, f64) -> f64,
out: &mut Vec<FilteredRow<T>>,
)
pub fn finish( &mut self, calibrate: &dyn Fn(&T, f64) -> f64, out: &mut Vec<FilteredRow<T>>, )
Filters and hands back every row still held.
Sourcefn start_from_probe(
&mut self,
calibrate: &dyn Fn(&T, f64) -> f64,
out: &mut Vec<FilteredRow<T>>,
)
fn start_from_probe( &mut self, calibrate: &dyn Fn(&T, f64) -> f64, out: &mut Vec<FilteredRow<T>>, )
Starts a segment with the interval estimated from the probe rows, then feeds them.
fn begin_segment(&mut self, interval_ns: i64, first_ns: i64)
fn push_in_segment( &mut self, timestamp_ns: i64, raw: f64, row: T, calibrate: &dyn Fn(&T, f64) -> f64, out: &mut Vec<FilteredRow<T>>, )
Sourcefn feed(&mut self, raw: f64, row: Option<T>, calibrate: &dyn Fn(&T, f64) -> f64)
fn feed(&mut self, raw: f64, row: Option<T>, calibrate: &dyn Fn(&T, f64) -> f64)
Queues one sample and runs it through the causal part.
Sourcefn apply_forward(&mut self, values: &[f64], calibrate: &dyn Fn(&T, f64) -> f64)
fn apply_forward(&mut self, values: &[f64], calibrate: &dyn Fn(&T, f64) -> f64)
Stores forward values for the oldest fed entries that lack one.
Sourcefn advance_ready(&mut self)
fn advance_ready(&mut self)
Moves ready over unfed entries that directly follow the ready ones.
Sourcefn drain_settled(
&mut self,
_calibrate: &dyn Fn(&T, f64) -> f64,
out: &mut Vec<FilteredRow<T>>,
all: bool,
)
fn drain_settled( &mut self, _calibrate: &dyn Fn(&T, f64) -> f64, out: &mut Vec<FilteredRow<T>>, all: bool, )
Runs the backward pass and hands back settled rows: block of them once
block + margin are ready, or all of them when all is set.
Sourcefn end_segment(
&mut self,
calibrate: &dyn Fn(&T, f64) -> f64,
out: &mut Vec<FilteredRow<T>>,
)
fn end_segment( &mut self, calibrate: &dyn Fn(&T, f64) -> f64, out: &mut Vec<FilteredRow<T>>, )
Flushes the causal part, hands back every queued row and forgets the segment.