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§
- Asset
Now - 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).
- Pool
Live - A pool’s live totals.
- Quality
Counts - Assets by quality.
- Quarter
Aggregate - 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
nowcannot 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 atat, when read atnow. 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
valueis physically possible forquantityon an asset ratedrated_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).