aemo_rs/
daily.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    case_solution: Vec<CaseSolution>,
8}
9
10impl AemoFile for File {
11    fn from_raw(RawAemoFile { header, mut data }: RawAemoFile) -> Result<Self> {
12        Ok(Self {
13            header,
14            case_solution: CaseSolution::from_map(&mut data)?,
15        })
16    }
17}
18
19#[derive(Deserialize, Serialize, Debug, Clone)]
20struct CaseSolution {
21    #[serde(deserialize_with = "crate::au_datetime_deserialize")]
22    settlementdate: chrono::NaiveDateTime,
23    runno: i32,
24    intervention: i32,
25    casesubtype: Option<String>,
26    solutionstatus: i32,
27    spdversion: Option<String>,
28    nonphysicallosses: i32,
29    totalobjective: f64,
30    totalareagenviolation: Option<f64>,
31    totalinterconnectorviolation: Option<f64>,
32    totalgenericviolation: Option<f64>,
33    totalramprateviolation: Option<f64>,
34    totalunitmwcapacityviolation: Option<f64>,
35    total5minviolation: Option<f64>,
36    totalregviolation: Option<f64>,
37    total6secviolation: Option<f64>,
38    total60secviolation: Option<f64>,
39    totalasprofileviolation: Option<f64>,
40    totalfaststartviolation: Option<f64>,
41    totalenergyofferviolation: Option<f64>,
42    #[serde(deserialize_with = "crate::au_datetime_deserialize")]
43    lastchanged: chrono::NaiveDateTime,
44}
45
46impl FileKeyable for CaseSolution {
47    fn key() -> crate::FileKey {
48        ("DISPATCH".into(), "CASESOLUTION".into(), 1)
49    }
50}
51
52impl GetFromRawAemo for CaseSolution {
53    type Output = Self;
54}
55
56#[derive(Deserialize, Serialize, Debug, Clone)]
57struct DRegion {
58    #[serde(deserialize_with = "crate::au_datetime_deserialize")]
59    settlementdate: chrono::NaiveDateTime,
60    runno: i32,
61    regionid: String,
62    intervention: i32,
63    rrp: f64,
64    eep: f64,
65    rop: f64,
66    apcflag: i32,
67    marketsuspendedflag: i32,
68    totaldemand: f64,
69    demandforecast: f64,
70    dispatchablegeneration: f64,
71    dispatchableload: f64,
72    netinterchange: f64,
73    excessgeneration: f64,
74    lower5mindispatch: Option<f64>,
75    lower5minimport: Option<f64>,
76    lower5minlocaldispatch: f64,
77    lower5minlocalprice: Option<f64>,
78    lower5minlocalreq: Option<f64>,
79    lower5minprice: Option<f64>,
80    lower5minreq: Option<f64>,
81    lower5minsupplyprice: Option<f64>,
82    lower60secdispatch: Option<f64>,
83    lower60secimport: Option<f64>,
84    lower60seclocaldispatch: f64,
85    lower60seclocalprice: Option<f64>,
86    lower60seclocalreq: Option<f64>,
87    lower60secprice: Option<f64>,
88    lower60secreq: Option<f64>,
89    lower60secsupplyprice: Option<f64>,
90    lower6secdispatch: Option<f64>,
91    lower6secimport: Option<f64>,
92    lower6seclocaldispatch: f64,
93    lower6seclocalprice: Option<f64>,
94    lower6seclocalreq: Option<f64>,
95    lower6secprice: Option<f64>,
96    lower6secreq: Option<f64>,
97    lower6secsupplyprice: Option<f64>,
98    raise5mindispatch: Option<f64>,
99    raise5minimport: Option<f64>,
100    raise5minlocaldispatch: f64,
101    raise5minlocalprice: Option<f64>,
102    raise5minlocalreq: Option<f64>,
103    raise5minprice: Option<f64>,
104    raise5minreq: Option<f64>,
105    raise5minsupplyprice: Option<f64>,
106    raise60secdispatch: Option<f64>,
107    raise60secimport: Option<f64>,
108    raise60seclocaldispatch: f64,
109    raise60seclocalprice: Option<f64>,
110    raise60seclocalreq: Option<f64>,
111    raise60secprice: Option<f64>,
112    raise60secreq: Option<f64>,
113    raise60secsupplyprice: Option<f64>,
114    raise6secdispatch: Option<f64>,
115    raise6secimport: Option<f64>,
116    raise6seclocaldispatch: f64,
117    raise6seclocalprice: Option<f64>,
118    raise6seclocalreq: Option<f64>,
119    raise6secprice: Option<f64>,
120    raise6secreq: Option<f64>,
121    raise6secsupplyprice: Option<f64>,
122    aggregatedispatcherror: f64,
123    availablegeneration: f64,
124    availableload: f64,
125    initialsupply: f64,
126    clearedsupply: f64,
127    lowerregimport: Option<f64>,
128    lowerreglocaldispatch: f64,
129    lowerreglocalreq: Option<f64>,
130    lowerregreq: Option<f64>,
131    raiseregimport: Option<f64>,
132    raisereglocaldispatch: f64,
133    raisereglocalreq: Option<f64>,
134    raiseregreq: Option<f64>,
135    raise5minlocalviolation: Option<f64>,
136    raisereglocalviolation: Option<f64>,
137    raise60seclocalviolation: Option<f64>,
138    raise6seclocalviolation: Option<f64>,
139    lower5minlocalviolation: Option<f64>,
140    lowerreglocalviolation: Option<f64>,
141    lower60seclocalviolation: Option<f64>,
142    lower6seclocalviolation: Option<f64>,
143    raise5minviolation: Option<f64>,
144    raiseregviolation: Option<f64>,
145    raise60secviolation: Option<f64>,
146    raise6secviolation: Option<f64>,
147    lower5minviolation: Option<f64>,
148    lowerregviolation: Option<f64>,
149    lower60secviolation: Option<f64>,
150    lower6secviolation: Option<f64>,
151    raise6secrrp: f64,
152    raise6secrop: f64,
153    raise6secapcflag: i32,
154    raise60secrrp: f64,
155    raise60secrop: f64,
156    raise60secapcflag: i32,
157    raise5minrrp: f64,
158    raise5minrop: f64,
159    raise5minapcflag: i32,
160    raiseregrrp: f64,
161    raiseregrop: f64,
162    raiseregapcflag: i32,
163    lower6secrrp: f64,
164    lower6secrop: f64,
165    lower6secapcflag: i32,
166    lower60secrrp: f64,
167    lower60secrop: f64,
168    lower60secapcflag: i32,
169    lower5minrrp: f64,
170    lower5minrop: f64,
171    lower5minapcflag: i32,
172    lowerregrrp: f64,
173    lowerregrop: f64,
174    lowerregapcflag: i32,
175    raise6secactualavailability: f64,
176    raise60secactualavailability: f64,
177    raise5minactualavailability: f64,
178    raiseregactualavailability: f64,
179    lower6secactualavailability: f64,
180    lower60secactualavailability: f64,
181    lower5minactualavailability: f64,
182    lowerregactualavailability: f64,
183    lorsurplus: Option<f64>,
184    lrcsurplus: Option<f64>,
185}
186
187impl FileKeyable for DRegion {
188    fn key() -> crate::FileKey {
189        ("DREGION".into(), "".into(), 3)
190    }
191}
192
193impl GetFromRawAemo for DRegion {
194    type Output = Self;
195}
196
197#[derive(Deserialize, Serialize, Debug, Clone)]
198struct DUnit {
199    #[serde(deserialize_with = "crate::au_datetime_deserialize")]
200    settlementdate: chrono::NaiveDateTime,
201    runno: i32,
202    duid: String,
203    intervention: i32,
204    dispatchmode: i32,
205    agcstatus: i32,
206    initialmw: f64,
207    totalcleared: f64,
208    rampdownrate: f64,
209    rampuprate: f64,
210    lower5min: f64,
211    lower60sec: f64,
212    lower6sec: f64,
213    raise5min: f64,
214    raise60sec: f64,
215    raise6sec: f64,
216    marginal5minvalue: Option<f64>,
217    marginal60secvalue: Option<f64>,
218    marginal6secvalue: Option<f64>,
219    marginalvalue: Option<f64>,
220    violation5mindegree: Option<f64>,
221    violation60secdegree: Option<f64>,
222    violation6secdegree: Option<f64>,
223    violationdegree: Option<f64>,
224    lowerreg: f64,
225    raisereg: f64,
226    availability: f64,
227    raise6secflags: i32,
228    raise60secflags: i32,
229    raise5minflags: i32,
230    raiseregflags: i32,
231    lower6secflags: i32,
232    lower60secflags: i32,
233    lower5minflags: i32,
234    lowerregflags: i32,
235    raiseregavailability: f64,
236    raiseregenablementmax: f64,
237    raiseregenablementmin: f64,
238    lowerregavailability: f64,
239    lowerregenablementmax: f64,
240    lowerregenablementmin: f64,
241    raise6secactualavailability: f64,
242    raise60secactualavailability: f64,
243    raise5minactualavailability: f64,
244    raiseregactualavailability: f64,
245    lower6secactualavailability: f64,
246    lower60secactualavailability: f64,
247    lower5minactualavailability: f64,
248    lowerregactualavailability: f64,
249    semidispatchcap: i32,
250}
251
252impl FileKeyable for DUnit {
253    fn key() -> crate::FileKey {
254        ("DUNIT".into(), "".into(), 3)
255    }
256}
257
258impl GetFromRawAemo for DUnit {
259    type Output = Self;
260}
261
262#[derive(Deserialize, Serialize, Debug, Clone)]
263struct RegionFcasRequirement {
264    #[serde(deserialize_with = "crate::au_datetime_deserialize")]
265    settlementdate: chrono::NaiveDateTime,
266    runno: i32,
267    intervention: i32,
268    genconid: String,
269    regionid: String,
270    bidtype: String,
271    #[serde(deserialize_with = "crate::au_datetime_deserialize")]
272    genconeffectivedate: chrono::NaiveDateTime,
273    genconversionno: i32,
274    marginalvalue: f64,
275    #[serde(deserialize_with = "crate::au_datetime_deserialize")]
276    lastchanged: chrono::NaiveDateTime,
277}
278
279impl FileKeyable for RegionFcasRequirement {
280    fn key() -> crate::FileKey {
281        ("DISPATCH".into(), "REGIONFCASREQUIREMENT".into(), 1)
282    }
283}
284
285impl GetFromRawAemo for RegionFcasRequirement {
286    type Output = Self;
287}
288
289#[derive(Deserialize, Serialize, Debug, Clone)]
290struct TRegion {
291    #[serde(deserialize_with = "crate::au_datetime_deserialize")]
292    settlementdate: chrono::NaiveDateTime,
293    runno: i32,
294    regionid: String,
295    rrp: f64,
296    eep: f64,
297    invalidflag: String,
298    totaldemand: f64,
299    demandforecast: f64,
300    dispatchablegeneration: f64,
301    dispatchableload: f64,
302    netinterchange: f64,
303    excessgeneration: f64,
304    lower5mindispatch: Option<f64>,
305    lower5minimport: Option<f64>,
306    lower5minlocaldispatch: f64,
307    lower5minlocalprice: Option<f64>,
308    lower5minlocalreq: Option<f64>,
309    lower5minprice: Option<f64>,
310    lower5minreq: Option<f64>,
311    lower5minsupplyprice: Option<f64>,
312    lower60secdispatch: Option<f64>,
313    lower60secimport: Option<f64>,
314    lower60seclocaldispatch: f64,
315    lower60seclocalprice: Option<f64>,
316    lower60seclocalreq: Option<f64>,
317    lower60secprice: Option<f64>,
318    lower60secreq: Option<f64>,
319    lower60secsupplyprice: Option<f64>,
320    lower6secdispatch: Option<f64>,
321    lower6secimport: Option<f64>,
322    lower6seclocaldispatch: f64,
323    lower6seclocalprice: Option<f64>,
324    lower6seclocalreq: Option<f64>,
325    lower6secprice: Option<f64>,
326    lower6secreq: Option<f64>,
327    lower6secsupplyprice: Option<f64>,
328    raise5mindispatch: Option<f64>,
329    raise5minimport: Option<f64>,
330    raise5minlocaldispatch: f64,
331    raise5minlocalprice: Option<f64>,
332    raise5minlocalreq: Option<f64>,
333    raise5minprice: Option<f64>,
334    raise5minreq: Option<f64>,
335    raise5minsupplyprice: Option<f64>,
336    raise60secdispatch: Option<f64>,
337    raise60secimport: Option<f64>,
338    raise60seclocaldispatch: f64,
339    raise60seclocalprice: Option<f64>,
340    raise60seclocalreq: Option<f64>,
341    raise60secprice: Option<f64>,
342    raise60secreq: Option<f64>,
343    raise60secsupplyprice: Option<f64>,
344    raise6secdispatch: Option<f64>,
345    raise6secimport: Option<f64>,
346    raise6seclocaldispatch: f64,
347    raise6seclocalprice: Option<f64>,
348    raise6seclocalreq: Option<f64>,
349    raise6secprice: Option<f64>,
350    raise6secreq: Option<f64>,
351    raise6secsupplyprice: Option<f64>,
352    availablegeneration: f64,
353    availableload: f64,
354    initialsupply: f64,
355    clearedsupply: f64,
356    lowerregimport: Option<f64>,
357    lowerreglocaldispatch: f64,
358    lowerreglocalreq: Option<f64>,
359    lowerregreq: Option<f64>,
360    raiseregimport: Option<f64>,
361    raisereglocaldispatch: f64,
362    raisereglocalreq: Option<f64>,
363    raiseregreq: Option<f64>,
364    raise5minlocalviolation: Option<f64>,
365    raisereglocalviolation: Option<f64>,
366    raise60seclocalviolation: Option<f64>,
367    raise6seclocalviolation: Option<f64>,
368    lower5minlocalviolation: Option<f64>,
369    lowerreglocalviolation: Option<f64>,
370    lower60seclocalviolation: Option<f64>,
371    lower6seclocalviolation: Option<f64>,
372    raise5minviolation: Option<f64>,
373    raiseregviolation: Option<f64>,
374    raise60secviolation: Option<f64>,
375    raise6secviolation: Option<f64>,
376    lower5minviolation: Option<f64>,
377    lowerregviolation: Option<f64>,
378    lower60secviolation: Option<f64>,
379    lower6secviolation: Option<f64>,
380    raise6secrrp: f64,
381    raise60secrrp: f64,
382    raise5minrrp: f64,
383    raiseregrrp: f64,
384    lower6secrrp: f64,
385    lower60secrrp: f64,
386    lower5minrrp: f64,
387    lowerregrrp: f64,
388}
389
390impl FileKeyable for TRegion {
391    fn key() -> crate::FileKey {
392        ("TREGION".into(), "".into(), 2)
393    }
394}
395
396impl GetFromRawAemo for TRegion {
397    type Output = Self;
398}
399
400#[derive(Deserialize, Serialize, Debug, Clone)]
401struct TUnit {
402    #[serde(deserialize_with = "crate::au_datetime_deserialize")]
403    settlementdate: chrono::NaiveDateTime,
404    runno: i32,
405    duid: String,
406    initialmw: f64,
407    totalcleared: f64,
408    rampdownrate: f64,
409    rampuprate: f64,
410    lower5min: f64,
411    lower60sec: f64,
412    lower6sec: f64,
413    raise5min: f64,
414    raise60sec: f64,
415    raise6sec: f64,
416    lowerreg: f64,
417    raisereg: f64,
418    availability: f64,
419}
420
421impl FileKeyable for TUnit {
422    fn key() -> crate::FileKey {
423        ("TUNIT".into(), "".into(), 2)
424    }
425}
426
427impl GetFromRawAemo for TUnit {
428    type Output = Self;
429}