Skip to main content

meter_snapshot

Function meter_snapshot 

Source
pub fn meter_snapshot(
    profile: MeterProfile,
    id: &str,
    id_type: Option<&str>,
    descriptions: &CmdData,
    connection: &CmdData,
    parameters: &CmdData,
    values: &CmdData,
) -> Result<Meter, MeterError>
Expand description

Project complete SPINE snapshots for one electrical boundary into a fresh meter.

The caller authenticates the peer, correlates the four full reads to its paired Measurement and ElectricalConnection features, and checks freshness. Supply updated full snapshots after any partial notification or catalogue change. The connection must use the load convention, with consumption positive. Only MPC maps per-phase active power. Both profiles retain signed produced Wh. Phase-to-neutral voltage requires an explicit neutral reference.

The released SPINE monitoring publisher omits supplementary AC measurement type and variant. This projection accepts omissions for a recognized scope, commodity, unit and AC connection, and checks explicit qualifiers. Unknown scopes and unsupported channels such as line-to-line voltage are skipped. Missing values, non-instantaneous value types, unknown or invalid quality, and directionally invalid magnitudes yield absent readings. A meter with no readings can replace an earlier observation to withdraw all its values.

use cls_eedi::eebus::{meter_snapshot, MeterProfile};
use eebus::usecases::{mgcp, monitoring::{Measurand, MonitoredUnit}};
let mut unit = MonitoredUnit::new(1).naming(mgcp::NAMING);
unit.add(Measurand::total_power());
unit.set(&Measurand::total_power(), -450.);
let meter = meter_snapshot(MeterProfile::Mgcp, "house", None,
    &unit.measurement_descriptions(), &unit.connection_description(),
    &unit.parameter_descriptions(), &unit.measurements())?;
assert_eq!(meter.power.unwrap().total.unwrap().value.to_string(), "-450");