Skip to main content

Crate flexpool_telemetry

Crate flexpool_telemetry 

Source
Expand description

Live telemetry for flexpool.

Measurements arrive from devices (or the sandbox simulator) as power in kW — generator convention: feed-in and battery discharge positive — and battery state of charge in percent. This crate decides their Quality, keeps them in a bounded Store, aggregates them per quarter hour and sums them per pool. It reads no clock: every function takes now.

Times are Unix seconds (i64); values are measurements (f64 at the API, f32 in the rings). Nothing here becomes a market quantity, so no value crosses the quantisation boundary.

Modules§

sim
The sandbox simulator: telemetry as a pure function of asset, seed, faults and time.

Structs§

AssetNow
An asset now: its readings and its overall quality (that of its power).
Flags
Quality flags a source attaches to a value (IEC 104: IV → invalid; NT, SB, BL, OV → questionable).
PoolLive
A pool’s live totals.
QualityCounts
Assets by quality.
QuarterAggregate
One quarter hour of an asset.
Reading
One value with its source time and its quality at the instant it was read.
Recent
One recent instant: power and state of charge taken at the same source time.
Store
The live store for the declared assets.

Enums§

Pushed
What happened to a pushed value.
Quality
How far a value can be trusted, from best to worst.
Quantity
What is measured.

Constants§

CLOCK_STEP_SECS
A sample this much older than the latest means the receiving clock stepped back: the series starts again instead of freezing on a value from the “future”.
FUTURE_TOLERANCE_SECS
A source time this far ahead of now cannot be trusted (a clock stepped back, or a device ahead).
QUARTERS_MAX
At most this many quarter aggregates per asset (two days).
QUARTER_BYTES
Bytes one stored quarter takes.
QUARTER_SECS
Seconds in a quarter hour.
RECENT_MAX
At most this many recent values per asset and quantity.
RECENT_SECS
Recent values are kept for this long.

Functions§

classify
The quality of value, taken at at, when read at now. A value from the future is stale.
energy_kwh
A battery’s usable energy in kWh as a float, if it has one.
plausible
Whether value is physically possible for quantity on an asset rated rated_kw.
quarter_start
The start of the quarter hour containing t (Berlin quarters align with UTC quarters).
rated_kw
An asset’s rated power in kW as a float (for plausibility and simulation only).
stale_limit
The stale limit for a source read every poll_secs: three intervals, at least 10 s.
summarise
Sums assets: (state now, usable energy in kWh for batteries).