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>
impl<'a> GetListResponse<'a>
Sourcepub fn quantity(&self, obis: Obis) -> Option<Quantity>
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?
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
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<'_>
impl GetListResponse<'_>
Sourcepub fn direction(&self, layout: StatusWord) -> Option<Direction>
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?
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}Sourcepub fn signed_power(&self, layout: StatusWord) -> Option<Quantity>
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.