Skip to main content

GetListResponse

Struct GetListResponse 

Source
pub struct GetListResponse<'a> {
    pub client_id: Option<&'a [u8]>,
    pub server_id: ServerId<'a>,
    pub list_name: Option<&'a [u8]>,
    pub act_sensor_time: Option<Time>,
    pub entries: ListEntries<'a>,
    pub list_signature: Option<&'a [u8]>,
    pub act_gateway_time: Option<Time>,
}
Expand description

SML_GetList.Res: the readings.

Fields§

§client_id: Option<&'a [u8]>

The client the response is for.

§server_id: ServerId<'a>

The device that answered, usually the meter’s server ID.

§list_name: Option<&'a [u8]>

The list’s name, an OBIS code when present.

§act_sensor_time: Option<Time>

The sensor’s time when the values were captured.

§entries: ListEntries<'a>

The entries. Parsed lazily: iterate to read them.

§list_signature: Option<&'a [u8]>

A signature over the list, when the device signs. Not verified by this crate.

§act_gateway_time: Option<Time>

The gateway’s time, when a gateway relayed the list.

Implementations§

Source§

impl<'a> GetListResponse<'a>

Source

pub fn get(&self, obis: Obis) -> Option<ListEntry<'a>>

The first entry named obis, if any.

Source

pub fn quantity(&self, obis: Obis) -> Option<Quantity>

The exact value of the first entry named obis, when it is numeric.

Examples found in repository?
examples/decode.rs (line 244)
236fn dzg_suspect(frame: &[u8], options: ParseOptions) -> Dzg {
237    let (Ok(as_sent), Ok(corrected)) =
238        (readout_with(frame, options), readout_with(frame, options.with_dzg_power(true)))
239    else {
240        return Dzg::Unchanged;
241    };
242    let changed = [Obis::POWER, Obis::POWER_L1, Obis::POWER_L2, Obis::POWER_L3]
243        .into_iter()
244        .any(|o| as_sent.quantity(o) != corrected.quantity(o));
245    match (changed, as_sent.direction(StatusWord::Mme)) {
246        (false, _) | (true, Some(Direction::Export)) => Dzg::Unchanged,
247        (true, Some(Direction::Import)) => Dzg::Confirmed,
248        (true, None) => Dzg::Possible,
249    }
250}
More examples
Hide additional examples
examples/serial.rs (line 40)
18fn main() -> std::io::Result<()> {
19    let source: Box<dyn Read> = match std::env::args().nth(1) {
20        Some(path) => Box::new(std::fs::File::open(path)?),
21        None => Box::new(std::io::stdin()),
22    };
23    for frame in FrameReader::new(source) {
24        let frame = match frame {
25            Ok(frame) => frame,
26            Err(ReadError::Frame(e)) => {
27                eprintln!("skipped a damaged frame: {e}");
28                continue;
29            }
30            // A quiet line: keep reading.
31            Err(ReadError::Io(e))
32                if matches!(e.kind(), std::io::ErrorKind::TimedOut | std::io::ErrorKind::WouldBlock) =>
33            {
34                continue;
35            }
36            Err(ReadError::Io(e)) => return Err(e),
37        };
38        match readout(&frame) {
39            Ok(list) => {
40                let show = |obis| list.quantity(obis).map_or_else(|| "-".to_owned(), |q| q.to_string());
41                println!(
42                    "{}  A+ {}  A- {}  P {}",
43                    list.server_id,
44                    show(Obis::ENERGY_IMPORT),
45                    show(Obis::ENERGY_EXPORT),
46                    show(Obis::POWER)
47                );
48            }
49            Err(e) => eprintln!("no readings: {e} (try `cargo run --example decode` on a capture)"),
50        }
51    }
52    Ok(())
53}
Source§

impl GetListResponse<'_>

Source

pub fn direction(&self, layout: StatusWord) -> Option<Direction>

The direction the status word of 1.8.0 reports (of 2.8.0 when 1.8.0 has none), read in layout. None when neither register carries a status.

The meter samples the bit with its registers and reports import at standstill.

Examples found in repository?
examples/decode.rs (line 245)
236fn dzg_suspect(frame: &[u8], options: ParseOptions) -> Dzg {
237    let (Ok(as_sent), Ok(corrected)) =
238        (readout_with(frame, options), readout_with(frame, options.with_dzg_power(true)))
239    else {
240        return Dzg::Unchanged;
241    };
242    let changed = [Obis::POWER, Obis::POWER_L1, Obis::POWER_L2, Obis::POWER_L3]
243        .into_iter()
244        .any(|o| as_sent.quantity(o) != corrected.quantity(o));
245    match (changed, as_sent.direction(StatusWord::Mme)) {
246        (false, _) | (true, Some(Direction::Export)) => Dzg::Unchanged,
247        (true, Some(Direction::Import)) => Dzg::Confirmed,
248        (true, None) => Dzg::Possible,
249    }
250}
Source

pub fn signed_power(&self, layout: StatusWord) -> Option<Quantity>

The power (16.7.0) with the sign from the status word: a power without a sign is negated when the meter reports export.

A value the meter already sent negative is returned as sent. If the status then says import, the two disagree: on a DZG meter that is the DVS74 sign bug (ParseOptions::with_dzg_power), see the Meter quirks page.

Trait Implementations§

Source§

impl<'a> Clone for GetListResponse<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for GetListResponse<'a>

Source§

impl<'a> Debug for GetListResponse<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Eq for GetListResponse<'a>

Source§

impl<'a> PartialEq for GetListResponse<'a>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<'a> StructuralPartialEq for GetListResponse<'a>

Auto Trait Implementations§

§

impl<'a> Forget for GetListResponse<'a>

§

impl<'a> Freeze for GetListResponse<'a>
where &'a [u8]: Freeze, &'a [ListEntry<'a>]: Freeze,

§

impl<'a> Move for GetListResponse<'a>

§

impl<'a> RefUnwindSafe for GetListResponse<'a>

§

impl<'a> Send for GetListResponse<'a>
where &'a [u8]: Send, &'a [ListEntry<'a>]: Send,

§

impl<'a> Sync for GetListResponse<'a>

§

impl<'a> Unpin for GetListResponse<'a>
where &'a [u8]: Unpin, &'a [ListEntry<'a>]: Unpin,

§

impl<'a> UnsafeUnpin for GetListResponse<'a>
where &'a [u8]: UnsafeUnpin, &'a [ListEntry<'a>]: UnsafeUnpin,

§

impl<'a> UnwindSafe for GetListResponse<'a>
where &'a [u8]: UnwindSafe, &'a [ListEntry<'a>]: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.