aemo_rs/
dispatch_scada.rs

1use crate::{AemoFile, FileKeyable, GetFromRawAemo, RawAemoFile, Result};
2use serde::{Deserialize, Serialize};
3
4#[derive(Clone, Debug, Deserialize, Serialize)]
5pub struct File {
6    header: crate::AemoHeader,
7    scada: Vec<UnitScada>,
8}
9
10impl AemoFile for File {
11    fn from_raw(RawAemoFile { header, mut data }: RawAemoFile) -> Result<Self> {
12        Ok(Self {
13            header,
14            scada: UnitScada::from_map(&mut data)?,
15        })
16    }
17}
18
19#[derive(Deserialize, Serialize, Debug, Clone)]
20pub struct UnitScada {
21    #[serde(deserialize_with = "crate::au_datetime_deserialize")]
22    settlementdate: chrono::NaiveDateTime,
23    duid: String,
24    scadavalue: f64,
25}
26
27impl FileKeyable for UnitScada {
28    fn key() -> crate::FileKey {
29        ("DISPATCH".into(), "UNIT_SCADA".into(), 1)
30    }
31}
32
33impl GetFromRawAemo for UnitScada {
34    type Output = Self;
35}