redispatch_xml/types/period.rs
1use serde::{Deserialize, Serialize};
2
3use crate::types::{AttrV, Decimal3, TimeInterval};
4
5// ── Quarter-hour Reason ───────────────────────────────────────────────────────
6
7/// A reason code + optional free-text explanation, attached to an
8/// `ActivationDocument` interval (within a `Period`).
9///
10/// Up to 2 `Reason` elements may appear per `Interval` in an
11/// `ActivationDocument`.
12#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
13pub struct Reason {
14 /// ENTSO-E reason code (e.g. `"A44"`, `"A95"`, `"Z05"`).
15 #[serde(rename = "ReasonCode")]
16 pub code: AttrV<String>,
17 /// Optional free-text reason description (max 512 chars).
18 #[serde(
19 rename = "ReasonText",
20 default,
21 skip_serializing_if = "Option::is_none"
22 )]
23 pub text: Option<String>,
24}
25
26// ── Quarter-hour Interval ─────────────────────────────────────────────────────
27
28/// A single quarter-hour (or longer) power value within a `Period`.
29///
30/// `pos` is 1-indexed (1–100 for a 25-hour DST day). `qty` is the power or
31/// percentage value for the interval, in the unit specified by the parent
32/// time series (`MeasureUnit`).
33#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
34pub struct Interval {
35 /// Quarter-hour position within the day (1–100).
36 #[serde(rename = "Pos")]
37 pub pos: AttrV<u8>,
38 /// Power or percentage quantity for this interval.
39 #[serde(rename = "Qty")]
40 pub qty: AttrV<Decimal3>,
41 /// Optional reason codes (0–2); present only in `ActivationDocument`.
42 #[serde(rename = "Reason", default, skip_serializing_if = "Vec::is_empty")]
43 pub reasons: Vec<Reason>,
44}
45
46// ── Period (attr-v document family) ──────────────────────────────────────────
47
48/// A quarter-hour delivery period used in `ActivationDocument`,
49/// `PlannedResourceScheduleDocument`, `NetworkConstraintDocument`, and
50/// `Kostenblatt`.
51///
52/// The `time_interval` covers one complete calendar day (UTC).
53/// `resolution` is always `"PT15M"` (15-minute granularity), giving 92–100
54/// intervals per day depending on DST transitions.
55#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
56pub struct Period {
57 /// The UTC day this period covers (`yyyy-mm-ddThh:mmZ/yyyy-mm-ddThh:mmZ`).
58 #[serde(rename = "TimeInterval")]
59 pub time_interval: AttrV<TimeInterval>,
60 /// Sampling resolution; always `"PT15M"`.
61 #[serde(rename = "Resolution")]
62 pub resolution: AttrV<String>,
63 /// Quarter-hour intervals for this period (92–100 per standard day).
64 #[serde(rename = "Interval", default)]
65 pub intervals: Vec<Interval>,
66}