- Preview
- A schematic cutaway of a fictional reservoir. Normal pool is below the configured reference, and High pool is above it.
- Inputs
- Supply site, levelM, scaleMinM and scaleMaxM. Use metres on the same vertical datum for the level, bounds and optional referenceM. Set datum to a short datum label such as ASL. Optional inflowM3s and outflowM3s use m³/s, and gateOpeningM is a non-negative opening in metres. observedAt uses Unix milliseconds and stale flags an out-of-date snapshot.
- Source options
- Map the most recent telemetry, configured chart bounds and approved reference supplied by the host. Preserve the original datum. The host refreshes snapshots and decides when they are stale. The downstream pool and dam geometry are schematic.
- Actions
- Use the centered Normal pool and High pool tabs in the built-in example. The reservoir surface transitions between reported levels and snaps to the new reading with reduced motion. Connected data is read-only.
- Integration requirements
- Bounds must be finite and strictly increasing. A missing or non-finite level makes the diagram unavailable. An out-of-scale level keeps its true numeric reading and is marked at the corresponding chart edge. A reference outside the scale stays in the readout. Zero is valid. Optional unknown readings can be omitted or set to null. Net flow is inflow minus outflow and requires both finite readings. The reference comparison is a numeric offset, even on a labeled stale snapshot.
{
"site": "Alder Reach Reservoir",
"datum": "ASL",
"levelM": 428.36,
"scaleMinM": 422,
"scaleMaxM": 438,
"referenceM": 432.5,
"inflowM3s": 386,
"outflowM3s": 351,
"gateOpeningM": 0.85,
"observedAt": 1795861800000
}
import { DamSectionWidget, type ReservoirSectionSnapshot } from "@lumo/widgets/catalog/water/dam-section";
type Report = { elevationCm: number; inflowLitresPerSecond?: number | null; outflowLitresPerSecond?: number | null;
gateOpeningCm?: number | null; measuredAtMs: number };
type Scale = Pick<ReservoirSectionSnapshot, "site" | "datum" | "scaleMinM" | "scaleMaxM" | "referenceM">;
const divide = (value: number | null | undefined, divisor: number) => value == null ? null : value / divisor;
export function ReservoirMonitor({ report, scale, stale }: { report: Report | null; scale: Scale; stale?: boolean }) {
const snapshot: ReservoirSectionSnapshot | null = report && {
...scale, stale, observedAt: report.measuredAtMs, levelM: report.elevationCm / 100,
inflowM3s: divide(report.inflowLitresPerSecond, 1000), outflowM3s: divide(report.outflowLitresPerSecond, 1000),
gateOpeningM: divide(report.gateOpeningCm, 100),
};
return <DamSectionWidget snapshot={snapshot} />;
}