signalk-server
Version:
An implementation of a [Signal K](http://signalk.org) server for boats.
36 lines • 1.49 kB
TypeScript
/**
* LatestValuesAccumulator - Accumulates Signal K delta values during backpressure,
* keeping only the latest value for each unique context:path:$source combination.
*/
import { Context, Delta, Path, SourceRef, Timestamp } from '@signalk/server-api';
export interface AccumulatedItem {
context: Context;
path: Path;
value: unknown;
$source: SourceRef | undefined;
timestamp: Timestamp | undefined;
}
export interface BackpressureDelta extends Delta {
$backpressure: {
accumulated: number;
duration: number;
};
}
/**
* Accumulate latest value per context:path:$source during backpressure.
* Only keeps the most recent value for each unique combination, dropping intermediate updates.
*
* @param accumulator - Map to store accumulated values, keyed by context:path:$source
* @param delta - Signal K delta to accumulate
*/
export declare function accumulateLatestValue(accumulator: Map<string, AccumulatedItem>, delta: Delta): void;
/**
* Convert accumulated values to spec-compliant deltas.
* Groups values by context and $source for proper delta structure.
*
* @param accumulator - Map of accumulated values
* @param duration - How long backpressure was active in milliseconds
* @returns Array of deltas, one per context, with $backpressure indicator
*/
export declare function buildFlushDeltas(accumulator: Map<string, AccumulatedItem>, duration: number): BackpressureDelta[];
//# sourceMappingURL=LatestValuesAccumulator.d.ts.map