Skip to main content

Crate mme

Crate mme 

Source
Expand description

§mme

Model the cumulative import register of a virtual German moderne Messeinrichtung (mME). Supply observation times and exact energy increments in tenths of a watt-hour. The meter retains the latest N observations in a fixed-size ring, independently of gateway connectivity. It builds on bare metal with zero dependencies.

use mme::Meter;

let mut meter = Meter::<96>::new("bench-meter", 0, 12_340)?;
meter.advance(900, 15)?;
meter.advance(1800, 25)?;
assert_eq!(meter.current().import_dwh, 12_380);
assert_eq!(meter.usage(0, 1800), Some(40)); // 4.0 Wh consumed

Usage requires both endpoints to be present. Each accepted observation advances time, including intervals with zero consumption. Meter restarts begin with the opening register supplied by the caller.

DisplayPeriod::window gives the two register timestamps for a completed consumption period. Age 1 is the newest. A week is seven powered days, a month is 30 and a year is 365. Windows refresh after each whole 24 hours since the supplied opening time.

use mme::DisplayPeriod;

let day = 86_400;
assert_eq!(DisplayPeriod::Week.window(0, 8 * day, 1), Some(day..=8 * day));
assert_eq!(DisplayPeriod::Year.window(0, 300 * day, 1), None);

The daemon archives daily endpoints and subtracts their exact register values. Its local display uses the May 2018 FNN Basiszähler profile, sections FBZ_0482 and FBZ_0431. Profile, pp. 63–64

Run the loopback meter with cargo run -p mme-sim -- --interactive. Operator guide

Structs§

Meter
A virtual electricity meter with an exact import register and N retained observations.
Reading
A cumulative import register observation. One deci-Wh equals 0.1 Wh.

Enums§

DisplayPeriod
The four display periods in the May 2018 FNN Basiszähler profile.
Error
A rejected operation leaves every existing observation intact.