use crate::traits::{
SEEvent, SEIdentifiedObject, SEList, SERandomizableEvent, SEResource, SERespondableResource,
SERespondableSubscribableIdentifiedObject, SESubscribableList, SESubscribableResource,
Validate,
};
use sep2_common_derive::{
SEEvent, SEIdentifiedObject, SEList, SERandomizableEvent, SEResource, SERespondableResource,
SERespondableSubscribableIdentifiedObject, SESubscribableList, SESubscribableResource,
};
use super::{
der::ActivePower,
identification::ResponseRequired,
links::{ActiveEndDeviceControlListLink, DemandResponseProgramLink, EndDeviceControlListLink},
objects::EventStatus,
primitives::{Int16, String32, Uint16, Uint32, Uint8},
types::{
ApplianceLoadReductionType, DateTimeInterval, DeviceCategoryType, MRIDType,
OneHourRangeType, Percent, PrimacyType, SubscribableType, TimeType, UnitType, VersionType,
},
};
use sepserde::{YaDeserialize, YaSerialize};
#[derive(Default, PartialEq, Eq, Debug, Clone, YaSerialize, YaDeserialize, SEList, SEResource)]
#[yaserde(rename = "LoadShedAvailabilityList")]
#[yaserde(namespace = "urn:ieee:std:2030.5:ns")]
pub struct LoadShedAvailabilityList {
#[yaserde(rename = "LoadShedAvailability")]
pub load_shed_availability: Vec<LoadShedAvailability>,
#[yaserde(attribute, rename = "pollRate")]
pub poll_rate: Option<Uint32>,
#[yaserde(attribute, rename = "all")]
pub all: Uint32,
#[yaserde(attribute, rename = "results")]
pub results: Uint32,
#[yaserde(attribute, rename = "href")]
pub href: Option<String>,
}
impl Validate for LoadShedAvailabilityList {}
#[derive(Default, PartialEq, Eq, Debug, Clone, Copy, YaSerialize, YaDeserialize)]
#[yaserde(rename = "ApplianceLoadReduction")]
#[yaserde(namespace = "urn:ieee:std:2030.5:ns")]
pub struct ApplianceLoadReduction {
#[yaserde(rename = "type")]
pub _type: ApplianceLoadReductionType,
}
impl Validate for ApplianceLoadReduction {}
#[derive(
Default, PartialEq, Eq, Debug, Clone, YaSerialize, YaDeserialize, SEIdentifiedObject, SEResource,
)]
#[yaserde(rename = "DemandResponseProgram")]
#[yaserde(namespace = "urn:ieee:std:2030.5:ns")]
pub struct DemandResponseProgram {
#[yaserde(rename = "mRID")]
pub mrid: MRIDType,
#[yaserde(rename = "description")]
pub description: Option<String32>,
#[yaserde(rename = "version")]
pub version: Option<VersionType>,
#[yaserde(rename = "ActiveEndDeviceControlListLink")]
pub active_end_device_control_list_link: Option<ActiveEndDeviceControlListLink>,
#[yaserde(rename = "availabilityUpdatePercentChangeThreshold")]
pub availability_update_percent_change_threshold: Option<Percent>,
#[yaserde(rename = "availabilityUpdatePowerChangeThreshold")]
pub availability_update_power_change_threshold: Option<ActivePower>,
#[yaserde(rename = "EndDeviceControlListLink")]
pub end_device_control_list_link: Option<EndDeviceControlListLink>,
#[yaserde(rename = "primacy")]
pub primacy: PrimacyType,
#[yaserde(attribute, rename = "href")]
pub href: Option<String>,
}
impl PartialOrd for DemandResponseProgram {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
Some(self.cmp(other))
}
}
impl Ord for DemandResponseProgram {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
match self.primacy.cmp(&other.primacy) {
core::cmp::Ordering::Equal => {}
ord => return ord,
}
self.mrid.cmp(&other.mrid).reverse()
}
}
impl Validate for DemandResponseProgram {}
#[derive(
Default,
PartialEq,
Eq,
Debug,
Clone,
YaSerialize,
YaDeserialize,
SESubscribableList,
SEList,
SESubscribableResource,
SEResource,
)]
#[yaserde(rename = "DemandResponseProgramList")]
#[yaserde(namespace = "urn:ieee:std:2030.5:ns")]
pub struct DemandResponseProgramList {
#[yaserde(rename = "DemandResponseProgram")]
pub demand_response_program: Vec<DemandResponseProgram>,
#[yaserde(attribute, rename = "pollRate")]
pub poll_rate: Option<Uint32>,
#[yaserde(attribute, rename = "all")]
pub all: Uint32,
#[yaserde(attribute, rename = "results")]
pub results: Uint32,
#[yaserde(attribute, rename = "subscribable")]
pub subscribable: Option<SubscribableType>,
#[yaserde(attribute, rename = "href")]
pub href: Option<String>,
}
impl Validate for DemandResponseProgramList {}
#[derive(Default, PartialEq, Eq, Debug, Clone, Copy, YaSerialize, YaDeserialize)]
#[yaserde(rename = "DutyCycle")]
#[yaserde(namespace = "urn:ieee:std:2030.5:ns")]
pub struct DutyCycle {
#[yaserde(rename = "normalValue")]
pub normal_value: Uint8,
}
impl Validate for DutyCycle {}
#[derive(
Default,
PartialEq,
Eq,
Debug,
Clone,
YaSerialize,
YaDeserialize,
SERandomizableEvent,
SEEvent,
SERespondableSubscribableIdentifiedObject,
SEIdentifiedObject,
SESubscribableResource,
SERespondableResource,
SEResource,
)]
#[yaserde(rename = "EndDeviceControl")]
#[yaserde(namespace = "urn:ieee:std:2030.5:ns")]
pub struct EndDeviceControl {
#[yaserde(rename = "mRID")]
pub mrid: MRIDType,
#[yaserde(rename = "description")]
pub description: Option<String32>,
#[yaserde(rename = "version")]
pub version: Option<VersionType>,
#[yaserde(rename = "creationTime")]
pub creation_time: TimeType,
#[yaserde(rename = "EventStatus")]
pub event_status: EventStatus,
#[yaserde(rename = "interval")]
pub interval: DateTimeInterval,
#[yaserde(rename = "randomizeDuration")]
pub randomize_duration: Option<OneHourRangeType>,
#[yaserde(rename = "randomizeStart")]
pub randomize_start: Option<OneHourRangeType>,
#[yaserde(rename = "ApplianceLoadReduction")]
pub appliance_load_reduction: Option<ApplianceLoadReduction>,
#[yaserde(rename = "deviceCategory")]
pub device_category: DeviceCategoryType,
#[yaserde(rename = "drProgramMandatory")]
pub dr_program_mandatory: bool,
#[yaserde(rename = "DutyCycle")]
pub duty_cycle: Option<DutyCycle>,
#[yaserde(rename = "loadShiftForward")]
pub load_shift_forward: bool,
#[yaserde(rename = "Offset")]
pub offset: Option<Offset>,
#[yaserde(rename = "overrideDuration")]
pub override_duration: Option<Uint16>,
#[yaserde(rename = "SetPoint")]
pub set_point: Option<SetPoint>,
#[yaserde(rename = "TargetReduction")]
pub target_reduction: Option<TargetReduction>,
#[yaserde(attribute, rename = "subscribable")]
pub subscribable: Option<SubscribableType>,
#[yaserde(attribute, rename = "replyTo")]
pub reply_to: Option<String>,
#[yaserde(attribute, rename = "responseRequired")]
pub response_required: Option<ResponseRequired>,
#[yaserde(attribute, rename = "href")]
pub href: Option<String>,
}
impl PartialOrd for EndDeviceControl {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
Some(self.cmp(other))
}
}
impl Ord for EndDeviceControl {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
match self.interval.start.cmp(&other.interval.start) {
core::cmp::Ordering::Equal => {}
ord => return ord,
}
match self.creation_time.cmp(&other.creation_time).reverse() {
core::cmp::Ordering::Equal => {}
ord => return ord,
}
self.mrid.cmp(&other.mrid).reverse()
}
}
impl Validate for EndDeviceControl {}
#[derive(
Default,
PartialEq,
Eq,
Debug,
Clone,
YaSerialize,
YaDeserialize,
SESubscribableList,
SEList,
SESubscribableResource,
SEResource,
)]
#[yaserde(rename = "EndDeviceControlList")]
#[yaserde(namespace = "urn:ieee:std:2030.5:ns")]
pub struct EndDeviceControlList {
#[yaserde(rename = "EndDeviceControl")]
pub end_device_control: Vec<EndDeviceControl>,
#[yaserde(attribute, rename = "all")]
pub all: Uint32,
#[yaserde(attribute, rename = "results")]
pub results: Uint32,
#[yaserde(attribute, rename = "subscribable")]
pub subscribable: Option<SubscribableType>,
#[yaserde(attribute, rename = "href")]
pub href: Option<String>,
}
impl Validate for EndDeviceControlList {}
#[derive(Default, PartialEq, Eq, Debug, Clone, YaSerialize, YaDeserialize, SEResource)]
#[yaserde(rename = "LoadShedAvailability")]
#[yaserde(namespace = "urn:ieee:std:2030.5:ns")]
pub struct LoadShedAvailability {
#[yaserde(rename = "availabilityDuration")]
pub availability_duration: Option<Uint32>,
#[yaserde(rename = "DemandResponseProgramLink")]
pub demand_response_program_link: Option<DemandResponseProgramLink>,
#[yaserde(rename = "sheddablePercent")]
pub sheddable_percent: Option<Percent>,
#[yaserde(rename = "sheddablePower")]
pub sheddable_power: Option<ActivePower>,
#[yaserde(attribute, rename = "href")]
pub href: Option<String>,
}
impl PartialOrd for LoadShedAvailability {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
Some(self.cmp(other))
}
}
impl Ord for LoadShedAvailability {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.href.cmp(&other.href).reverse()
}
}
impl Validate for LoadShedAvailability {}
#[derive(Default, PartialEq, Eq, Debug, Clone, YaSerialize, YaDeserialize)]
#[yaserde(rename = "Offset")]
#[yaserde(namespace = "urn:ieee:std:2030.5:ns")]
pub struct Offset {
#[yaserde(rename = "coolingOffset")]
pub cooling_offset: Option<Uint8>,
#[yaserde(rename = "heatingOffset")]
pub heating_offset: Option<Uint8>,
#[yaserde(rename = "loadAdjustmentPercentageOffset")]
pub load_adjustment_percentage_offset: Option<Percent>,
}
impl Validate for Offset {}
#[derive(Default, PartialEq, Eq, Debug, Clone, YaSerialize, YaDeserialize)]
#[yaserde(rename = "SetPoint")]
#[yaserde(namespace = "urn:ieee:std:2030.5:ns")]
pub struct SetPoint {
#[yaserde(rename = "coolingSetpoint")]
pub cooling_setpoint: Option<Int16>,
#[yaserde(rename = "heatingSetpoint")]
pub heating_setpoint: Option<Int16>,
}
impl Validate for SetPoint {}
#[derive(Default, PartialEq, Eq, Debug, Clone, YaSerialize, YaDeserialize)]
#[yaserde(rename = "TargetReduction")]
#[yaserde(namespace = "urn:ieee:std:2030.5:ns")]
pub struct TargetReduction {
#[yaserde(rename = "type")]
pub _type: UnitType,
#[yaserde(rename = "value")]
pub value: Uint16,
}
impl Validate for TargetReduction {}