1use crate::{FileKeyable, GetFromRawAemo, RawAemoFile, Result};
2use serde::{Deserialize, Serialize};
3
4#[derive(Clone, Debug, Deserialize, Serialize)]
5pub struct File {
6 header: crate::AemoHeader,
7 price: Vec<BidDayOffer>,
8 volume: Vec<BidPerOffer>,
9}
10
11impl crate::AemoFile for File {
12 fn from_raw(RawAemoFile { header, mut data }: RawAemoFile) -> Result<Self> {
13 Ok(Self {
14 header,
15 price: BidDayOffer::from_map(&mut data)?,
16 volume: BidPerOffer::from_map(&mut data)?,
17 })
18 }
19}
20
21impl File {
22 pub fn get_price(&self) -> &'_ Vec<BidDayOffer> {
23 &self.price
24 }
25}
26
27#[derive(Clone, Debug, Deserialize, Serialize)]
28enum BidType {
29 RAISEREG,
30 RAISE6SEC,
31 RAISE60SEC,
32 RAISE5MIN,
33 ENERGY,
34 LOWERREG,
35 LOWER6SEC,
36 LOWER60SEC,
37 LOWER5MIN,
38}
39
40#[derive(Clone, Debug, Deserialize, Serialize)]
41enum EntryType {
42 DAILY,
43 REBID,
44}
45
46#[derive(Clone, Debug, Deserialize, Serialize)]
47pub struct BidDayOffer {
48 #[serde(deserialize_with = "crate::au_datetime_deserialize")]
49 settlement_date: chrono::NaiveDateTime,
50 duid: String,
51 bid_type: Option<BidType>,
52 #[serde(deserialize_with = "crate::au_datetime_deserialize")]
53 bid_settlement_date: chrono::NaiveDateTime,
54 #[serde(deserialize_with = "crate::au_datetime_deserialize")]
55 bid_offer_date: chrono::NaiveDateTime,
56 #[serde(deserialize_with = "crate::opt_au_datetime_deserialize")]
57 first_dispatch: Option<chrono::NaiveDateTime>,
58 #[serde(deserialize_with = "crate::opt_au_datetime_deserialize")]
59 first_predispatch: Option<chrono::NaiveDateTime>,
60 daily_energy_constraint: Option<i32>,
61 rebid_explanation: String,
62 pub price_band_1: f64,
63 price_band_2: f64,
64 price_band_3: f64,
65 price_band_4: f64,
66 price_band_5: f64,
67 price_band_6: f64,
68 price_band_7: f64,
69 price_band_8: f64,
70 price_band_9: f64,
71 price_band_10: f64,
72 minimum_load: Option<i32>,
73 t1: Option<i32>,
74 t2: Option<i32>,
75 t3: Option<i32>,
76 t4: Option<i32>,
77 normal_status: Option<i32>,
78 #[serde(deserialize_with = "crate::au_datetime_deserialize")]
79 last_changed: chrono::NaiveDateTime,
80 bid_version_no: i32,
81 mr_factor: Option<i32>,
82 entry_type: Option<EntryType>,
83}
84
85impl FileKeyable for BidDayOffer {
86 fn key() -> crate::FileKey {
87 ("YESTBID".into(), "BIDDAYOFFER".into(), 5)
88 }
89}
90
91impl GetFromRawAemo for BidDayOffer {
92 type Output = Self;
93}
94
95#[derive(Clone, Debug, Deserialize, Serialize)]
96struct BidPerOffer {
97 #[serde(deserialize_with = "crate::au_datetime_deserialize")]
98 settlement_date: chrono::NaiveDateTime,
99 duid: String,
100 bid_type: BidType,
101 #[serde(deserialize_with = "crate::au_datetime_deserialize")]
102 bid_settlement_date: chrono::NaiveDateTime,
103 #[serde(deserialize_with = "crate::au_datetime_deserialize")]
104 bid_offer_date: chrono::NaiveDateTime,
105 #[serde(deserialize_with = "crate::au_datetime_deserialize")]
106 trading_period: chrono::NaiveDateTime,
107 max_availability: i32,
108 fixed_load: Option<i32>,
109 roc_up: Option<i32>,
110 roc_down: Option<i32>,
111 enablement_min: i32,
112 enablement_max: i32,
113 low_break_point: i32,
114 high_break_point: i32,
115 band_availability_1: i32,
116 band_availability_2: i32,
117 band_availability_3: i32,
118 band_availability_4: i32,
119 band_availability_5: i32,
120 band_availability_6: i32,
121 band_availability_7: i32,
122 band_availability_8: i32,
123 band_availability_9: i32,
124 band_availability_10: i32,
125 pasa_availability: Option<i32>,
126 period_id: i32,
127 #[serde(deserialize_with = "crate::au_datetime_deserialize")]
128 last_changed: chrono::NaiveDateTime,
129 bid_version_no: i32,
130 mr_capacity: Option<i32>,
131}
132
133impl FileKeyable for BidPerOffer {
134 fn key() -> crate::FileKey {
135 ("YESTBID".into(), "BIDPEROFFER".into(), 3)
136 }
137}
138
139impl GetFromRawAemo for BidPerOffer {
140 type Output = Self;
141}