use crate::traits::{
SEIdentifiedObject, SEList, SEResource, SESubscribableList, SESubscribableResource, Validate,
};
use sep2_common_derive::{
SEIdentifiedObject, SEList, SEResource, SESubscribableList, SESubscribableResource,
};
use yaserde::{YaDeserialize, YaSerialize};
use super::{
links::{
AccountBalanceLink, ActiveCreditRegisterListLink, ActiveSupplyInterruptionOverrideListLink,
CreditRegisterListLink, PrepayOperationStatusLink, SupplyInterruptionOverrideListLink,
UsagePointLink,
},
metering::UsagePoint,
primitives::{Int32, String32, Uint32},
types::{
CurrencyCode, DateTimeInterval, MRIDType, PowerOfTenMultiplierType, RealEnergy,
SubscribableType, TimeType, VersionType,
},
};
#[derive(Default, PartialEq, Eq, Debug, Clone, YaSerialize, YaDeserialize, SEResource)]
#[yaserde(rename = "AccountBalance")]
#[yaserde(namespace = "urn:ieee:std:2030.5:ns")]
pub struct AccountBalance {
#[yaserde(rename = "availableCredit")]
pub available_credit: AccountingUnit,
#[yaserde(rename = "creditStatus")]
pub credit_status: Option<CreditStatusType>,
#[yaserde(rename = "emergencyCredit")]
pub emergency_credit: Option<AccountingUnit>,
#[yaserde(rename = "emergencyCreditStatus")]
pub emergency_credit_status: Option<CreditStatusType>,
#[yaserde(attribute, rename = "href")]
pub href: Option<String>,
}
impl Validate for AccountBalance {}
#[derive(Default, PartialEq, Eq, Debug, Clone, YaSerialize, YaDeserialize)]
#[yaserde(rename = "AccountingUnit")]
#[yaserde(namespace = "urn:ieee:std:2030.5:ns")]
pub struct AccountingUnit {
#[yaserde(rename = "energyUnit")]
pub energy_unit: Option<RealEnergy>,
#[yaserde(rename = "monetaryUnit")]
pub monetary_unit: CurrencyCode,
#[yaserde(rename = "multiplier")]
pub multiplier: PowerOfTenMultiplierType,
#[yaserde(rename = "value")]
pub value: Int32,
}
impl Validate for AccountingUnit {}
#[derive(
Default, PartialEq, Eq, Debug, Clone, YaSerialize, YaDeserialize, SEIdentifiedObject, SEResource,
)]
#[yaserde(rename = "CreditRegister")]
#[yaserde(namespace = "urn:ieee:std:2030.5:ns")]
pub struct CreditRegister {
#[yaserde(rename = "creditAmount")]
pub credit_amount: AccountingUnit,
#[yaserde(rename = "creditType")]
pub credit_type: Option<CreditTypeType>,
#[yaserde(rename = "effectiveTime")]
pub effective_time: TimeType,
#[yaserde(rename = "token")]
pub token: String32,
#[yaserde(rename = "mRID")]
pub mrid: MRIDType,
#[yaserde(rename = "description")]
pub description: Option<String32>,
#[yaserde(rename = "version")]
pub version: Option<VersionType>,
#[yaserde(attribute, rename = "href")]
pub href: Option<String>,
}
impl PartialOrd for CreditRegister {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
Some(self.cmp(other))
}
}
impl Ord for CreditRegister {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
match self.effective_time.cmp(&other.effective_time).reverse() {
core::cmp::Ordering::Equal => {}
ord => return ord,
}
self.mrid.cmp(&other.mrid).reverse()
}
}
impl Validate for CreditRegister {}
#[derive(Default, PartialEq, Eq, Debug, Clone, YaSerialize, YaDeserialize, SEList, SEResource)]
#[yaserde(rename = "CreditRegisterList")]
#[yaserde(namespace = "urn:ieee:std:2030.5:ns")]
pub struct CreditRegisterList {
#[yaserde(rename = "CreditRegister")]
pub credit_register: Vec<CreditRegister>,
#[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 CreditRegisterList {}
#[derive(
Default, PartialEq, Eq, Debug, Clone, YaSerialize, YaDeserialize, SEIdentifiedObject, SEResource,
)]
#[yaserde(rename = "Prepayment")]
#[yaserde(namespace = "urn:ieee:std:2030.5:ns")]
pub struct Prepayment {
#[yaserde(rename = "AccountBalanceLink")]
pub account_balance_link: AccountBalanceLink,
#[yaserde(rename = "ActiveCreditRegisterListLink")]
pub active_credit_register_list_link: Option<ActiveCreditRegisterListLink>,
#[yaserde(rename = "ActiveSupplyInterruptionOverrideListLink")]
pub active_supply_interruption_override_list_link:
Option<ActiveSupplyInterruptionOverrideListLink>,
#[yaserde(rename = "creditExpiryLevel")]
pub credit_expiry_level: Option<AccountingUnit>,
#[yaserde(rename = "CreditRegisterListLink")]
pub credit_register_list_link: CreditRegisterListLink,
#[yaserde(rename = "lowCreditWarningLevel")]
pub low_credit_warning_level: Option<AccountingUnit>,
#[yaserde(rename = "lowEmergencyCreditWarningLevel")]
pub low_emergency_credit_warning_level: Option<AccountingUnit>,
#[yaserde(rename = "prepayMode")]
pub prepay_mode: PrepayModeType,
#[yaserde(rename = "PrepayOperationStatusLink")]
pub prepay_operation_status_link: PrepayOperationStatusLink,
#[yaserde(rename = "SupplyInterruptionOverrideListLink")]
pub supply_interruption_override_list_link: SupplyInterruptionOverrideListLink,
#[yaserde(rename = "UsagePoint")]
pub usage_point: Vec<UsagePoint>,
#[yaserde(rename = "UsagePointLink")]
pub usage_point_link: Option<UsagePointLink>,
#[yaserde(rename = "mRID")]
pub mrid: MRIDType,
#[yaserde(rename = "description")]
pub description: Option<String32>,
#[yaserde(rename = "version")]
pub version: Option<VersionType>,
#[yaserde(attribute, rename = "href")]
pub href: Option<String>,
}
impl PartialOrd for Prepayment {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
Some(self.cmp(other))
}
}
impl Ord for Prepayment {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.mrid.cmp(&other.mrid).reverse()
}
}
impl Validate for Prepayment {}
#[derive(
Default,
PartialEq,
Eq,
Debug,
Clone,
YaSerialize,
YaDeserialize,
SESubscribableList,
SEList,
SESubscribableResource,
SEResource,
)]
#[yaserde(rename = "PrepaymentList")]
#[yaserde(namespace = "urn:ieee:std:2030.5:ns")]
pub struct PrepaymentList {
#[yaserde(rename = "Prepayment")]
pub prepayment: Vec<Prepayment>,
#[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 PrepaymentList {}
#[derive(Default, PartialEq, Eq, Debug, Clone, Copy, YaSerialize, YaDeserialize)]
#[yaserde(rename = "PrepayModeType")]
#[yaserde(namespace = "urn:ieee:std:2030.5:ns")]
#[repr(u8)]
pub enum PrepayModeType {
#[default]
CentralWallet = 0,
ESI = 1,
Local = 2,
Credit = 3,
}
impl Validate for PrepayModeType {}
#[derive(Default, PartialEq, Eq, Debug, Clone, YaSerialize, YaDeserialize, SEResource)]
#[yaserde(rename = "PrepayOperationStatus")]
#[yaserde(namespace = "urn:ieee:std:2030.5:ns")]
pub struct PrepayOperationStatus {
#[yaserde(rename = "creditTypeChange")]
pub credit_type_change: Option<CreditTypeChange>,
#[yaserde(rename = "creditTypeInUse")]
pub credit_type_in_use: Option<CreditTypeType>,
#[yaserde(rename = "serviceChange")]
pub service_change: Option<ServiceChange>,
#[yaserde(rename = "serviceStatus")]
pub service_status: ServiceStatusType,
#[yaserde(attribute, rename = "href")]
pub href: Option<String>,
}
impl Validate for PrepayOperationStatus {}
#[derive(Default, PartialEq, Eq, Debug, Clone, YaSerialize, YaDeserialize)]
#[yaserde(rename = "ServiceChange")]
#[yaserde(namespace = "urn:ieee:std:2030.5:ns")]
pub struct ServiceChange {
#[yaserde(rename = "newStatus")]
pub new_status: ServiceStatusType,
#[yaserde(rename = "startTime")]
pub start_time: TimeType,
}
impl Validate for ServiceChange {}
#[derive(Default, PartialEq, Eq, Debug, Clone, YaSerialize, YaDeserialize, SEResource)]
#[yaserde(rename = "SupplyInterruptionOverride")]
#[yaserde(namespace = "urn:ieee:std:2030.5:ns")]
pub struct SupplyInterruptionOverride {
#[yaserde(rename = "description")]
pub description: Option<String32>,
#[yaserde(rename = "interval")]
pub interval: DateTimeInterval,
#[yaserde(attribute, rename = "href")]
pub href: Option<String>,
}
impl PartialOrd for SupplyInterruptionOverride {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
Some(self.cmp(other))
}
}
impl Ord for SupplyInterruptionOverride {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
match self.interval.start.cmp(&other.interval.start) {
core::cmp::Ordering::Equal => {}
ord => return ord,
}
self.interval.duration.cmp(&other.interval.duration)
}
}
impl Validate for SupplyInterruptionOverride {}
#[derive(Default, PartialEq, Eq, Debug, Clone, YaSerialize, YaDeserialize, SEList, SEResource)]
#[yaserde(rename = "SupplyInterruptionOverrideList")]
#[yaserde(namespace = "urn:ieee:std:2030.5:ns")]
pub struct SupplyInterruptionOverrideList {
#[yaserde(rename = "SupplyInterruptionOverride")]
pub supply_interruption_override: Vec<SupplyInterruptionOverride>,
#[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 SupplyInterruptionOverrideList {}
#[derive(Default, PartialEq, Eq, Debug, Clone, Copy, YaSerialize, YaDeserialize)]
#[yaserde(rename = "CreditStatusType")]
#[yaserde(namespace = "urn:ieee:std:2030.5:ns")]
#[repr(u8)]
pub enum CreditStatusType {
#[default]
Ok = 0,
Low = 1,
Exhausted = 2,
Negative = 3,
}
impl Validate for CreditStatusType {}
#[derive(Default, PartialEq, Eq, Debug, Clone, Copy, YaSerialize, YaDeserialize)]
#[yaserde(rename = "CreditTypeType")]
#[yaserde(namespace = "urn:ieee:std:2030.5:ns")]
#[repr(u8)]
pub enum CreditTypeType {
#[default]
Regular = 0,
Emergency = 1,
RegularThenEmergency = 2,
EmergencyThenRegular = 3,
}
impl Validate for CreditTypeType {}
#[derive(Default, PartialEq, Eq, Debug, Clone, YaSerialize, YaDeserialize)]
#[yaserde(rename = "CreditTypeChange")]
#[yaserde(namespace = "urn:ieee:std:2030.5:ns")]
pub struct CreditTypeChange {
#[yaserde(rename = "newType")]
pub new_type: CreditTypeType,
#[yaserde(rename = "startTime")]
pub start_time: TimeType,
}
impl Validate for CreditTypeChange {}
#[derive(Default, PartialEq, Eq, Debug, Clone, Copy, YaSerialize, YaDeserialize)]
#[yaserde(rename = "ServiceStatusType")]
#[yaserde(namespace = "urn:ieee:std:2030.5:ns")]
#[repr(u8)]
pub enum ServiceStatusType {
#[default]
Connected = 0,
Disconnected = 1,
ArmedForConnect = 2,
ArmedForDisconnect = 3,
NoContactor = 4,
LoadLimited = 5,
}
impl Validate for ServiceStatusType {}