#![allow(unused_imports)]
use crate::dm::conformance::{Clause, Condition, Conform, Conformance};
use crate::dm::meta::{EventPriority, Reporting};
use crate::dm::spec::{Attribute, Cluster, Command, Event, Feature};
use crate::dm::{Access, AccessQualities, AttributeQualities, Privilege};
use crate::error::Result;
use crate::im::{AttributeId, ClusterId, CommandId, EventId};
use crate::tlv::{
ContainerKind, Element, FromTlv, Nullable, Tag, TlvList, TlvReader, TlvWriter, ToTlv, Value,
};
pub const ID: ClusterId = 0x0099;
pub const REVISION: u16 = 4;
pub const PICS: &str = "EEVSE";
pub mod feature {
pub const CHARGING_PREFERENCES: u32 = 1 << 0;
pub const SO_C_REPORTING: u32 = 1 << 1;
pub const PLUG_AND_CHARGE: u32 = 1 << 2;
pub const RFID: u32 = 1 << 3;
pub const V2_X: u32 = 1 << 4;
}
pub const FEATURES: &[Feature] = &[
Feature {
bit: 0,
code: "PREF",
name: "ChargingPreferences",
conform: Conform::MANDATORY,
},
Feature {
bit: 1,
code: "SOC",
name: "SoCReporting",
conform: Conform::OPTIONAL,
},
Feature {
bit: 2,
code: "PNC",
name: "PlugAndCharge",
conform: Conform::OPTIONAL,
},
Feature {
bit: 3,
code: "RFID",
name: "RFID",
conform: Conform::OPTIONAL,
},
Feature {
bit: 4,
code: "V2X",
name: "V2X",
conform: Conform::OPTIONAL,
},
];
pub mod attribute {
use crate::im::AttributeId;
pub const STATE: AttributeId = 0x00;
pub const SUPPLY_STATE: AttributeId = 0x01;
pub const FAULT_STATE: AttributeId = 0x02;
pub const CHARGING_ENABLED_UNTIL: AttributeId = 0x03;
pub const DISCHARGING_ENABLED_UNTIL: AttributeId = 0x04;
pub const CIRCUIT_CAPACITY: AttributeId = 0x05;
pub const MINIMUM_CHARGE_CURRENT: AttributeId = 0x06;
pub const MAXIMUM_CHARGE_CURRENT: AttributeId = 0x07;
pub const MAXIMUM_DISCHARGE_CURRENT: AttributeId = 0x08;
pub const USER_MAXIMUM_CHARGE_CURRENT: AttributeId = 0x09;
pub const RANDOMIZATION_DELAY_WINDOW: AttributeId = 0x0A;
pub const NEXT_CHARGE_START_TIME: AttributeId = 0x23;
pub const NEXT_CHARGE_TARGET_TIME: AttributeId = 0x24;
pub const NEXT_CHARGE_REQUIRED_ENERGY: AttributeId = 0x25;
pub const NEXT_CHARGE_TARGET_SO_C: AttributeId = 0x26;
pub const APPROXIMATE_EV_EFFICIENCY: AttributeId = 0x27;
pub const STATE_OF_CHARGE: AttributeId = 0x30;
pub const BATTERY_CAPACITY: AttributeId = 0x31;
pub const VEHICLE_ID: AttributeId = 0x32;
pub const SESSION_ID: AttributeId = 0x40;
pub const SESSION_DURATION: AttributeId = 0x41;
pub const SESSION_ENERGY_CHARGED: AttributeId = 0x42;
pub const SESSION_ENERGY_DISCHARGED: AttributeId = 0x43;
}
pub mod command {
use crate::im::CommandId;
pub const GET_TARGETS_RESPONSE: CommandId = 0x00;
pub const DISABLE: CommandId = 0x01;
pub const ENABLE_CHARGING: CommandId = 0x02;
pub const ENABLE_DISCHARGING: CommandId = 0x03;
pub const START_DIAGNOSTICS: CommandId = 0x04;
pub const SET_TARGETS: CommandId = 0x05;
pub const GET_TARGETS: CommandId = 0x06;
pub const CLEAR_TARGETS: CommandId = 0x07;
}
pub mod event {
use crate::im::EventId;
pub const EV_CONNECTED: EventId = 0x00;
pub const EV_NOT_DETECTED: EventId = 0x01;
pub const ENERGY_TRANSFER_STARTED: EventId = 0x02;
pub const ENERGY_TRANSFER_STOPPED: EventId = 0x03;
pub const FAULT: EventId = 0x04;
pub const RFID: EventId = 0x05;
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(u8)]
pub enum EnergyTransferStoppedReasonEnum {
EVStopped = 0,
EVSEStopped = 1,
Other = 2,
}
impl EnergyTransferStoppedReasonEnum {
#[must_use]
pub const fn from_value(value: u8) -> Option<Self> {
match value {
0 => Some(Self::EVStopped),
1 => Some(Self::EVSEStopped),
2 => Some(Self::Other),
_ => None,
}
}
#[must_use]
pub const fn value(self) -> u8 {
self as u8
}
}
impl ToTlv for EnergyTransferStoppedReasonEnum {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
self.value().to_tlv(w, tag)
}
}
impl<'a> FromTlv<'a> for EnergyTransferStoppedReasonEnum {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(u8)]
pub enum FaultStateEnum {
NoError = 0,
MeterFailure = 1,
OverVoltage = 2,
UnderVoltage = 3,
OverCurrent = 4,
ContactWetFailure = 5,
ContactDryFailure = 6,
GroundFault = 7,
PowerLoss = 8,
PowerQuality = 9,
PilotShortCircuit = 10,
EmergencyStop = 11,
EVDisconnected = 12,
WrongPowerSupply = 13,
LiveNeutralSwap = 14,
OverTemperature = 15,
Other = 255,
}
impl FaultStateEnum {
#[must_use]
pub const fn from_value(value: u8) -> Option<Self> {
match value {
0 => Some(Self::NoError),
1 => Some(Self::MeterFailure),
2 => Some(Self::OverVoltage),
3 => Some(Self::UnderVoltage),
4 => Some(Self::OverCurrent),
5 => Some(Self::ContactWetFailure),
6 => Some(Self::ContactDryFailure),
7 => Some(Self::GroundFault),
8 => Some(Self::PowerLoss),
9 => Some(Self::PowerQuality),
10 => Some(Self::PilotShortCircuit),
11 => Some(Self::EmergencyStop),
12 => Some(Self::EVDisconnected),
13 => Some(Self::WrongPowerSupply),
14 => Some(Self::LiveNeutralSwap),
15 => Some(Self::OverTemperature),
255 => Some(Self::Other),
_ => None,
}
}
#[must_use]
pub const fn value(self) -> u8 {
self as u8
}
}
impl ToTlv for FaultStateEnum {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
self.value().to_tlv(w, tag)
}
}
impl<'a> FromTlv<'a> for FaultStateEnum {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(u8)]
pub enum StateEnum {
NotPluggedIn = 0,
PluggedInNoDemand = 1,
PluggedInDemand = 2,
PluggedInCharging = 3,
PluggedInDischarging = 4,
SessionEnding = 5,
Fault = 6,
}
impl StateEnum {
#[must_use]
pub const fn from_value(value: u8) -> Option<Self> {
match value {
0 => Some(Self::NotPluggedIn),
1 => Some(Self::PluggedInNoDemand),
2 => Some(Self::PluggedInDemand),
3 => Some(Self::PluggedInCharging),
4 => Some(Self::PluggedInDischarging),
5 => Some(Self::SessionEnding),
6 => Some(Self::Fault),
_ => None,
}
}
#[must_use]
pub const fn value(self) -> u8 {
self as u8
}
}
impl ToTlv for StateEnum {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
self.value().to_tlv(w, tag)
}
}
impl<'a> FromTlv<'a> for StateEnum {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(u8)]
pub enum SupplyStateEnum {
Disabled = 0,
ChargingEnabled = 1,
DischargingEnabled = 2,
DisabledError = 3,
DisabledDiagnostics = 4,
Enabled = 5,
}
impl SupplyStateEnum {
#[must_use]
pub const fn from_value(value: u8) -> Option<Self> {
match value {
0 => Some(Self::Disabled),
1 => Some(Self::ChargingEnabled),
2 => Some(Self::DischargingEnabled),
3 => Some(Self::DisabledError),
4 => Some(Self::DisabledDiagnostics),
5 => Some(Self::Enabled),
_ => None,
}
}
#[must_use]
pub const fn value(self) -> u8 {
self as u8
}
}
impl ToTlv for SupplyStateEnum {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
self.value().to_tlv(w, tag)
}
}
impl<'a> FromTlv<'a> for SupplyStateEnum {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
}
}
bitflags::bitflags! {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub struct TargetDayOfWeekBitmap: u8 {
const SUNDAY = 1 << 0;
const MONDAY = 1 << 1;
const TUESDAY = 1 << 2;
const WEDNESDAY = 1 << 3;
const THURSDAY = 1 << 4;
const FRIDAY = 1 << 5;
const SATURDAY = 1 << 6;
}
}
impl ToTlv for TargetDayOfWeekBitmap {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
self.bits().to_tlv(w, tag)
}
}
impl<'a> FromTlv<'a> for TargetDayOfWeekBitmap {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
let bits = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
Self::from_bits(bits).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct ChargingTargetScheduleStruct<'a> {
pub day_of_week_for_sequence: TargetDayOfWeekBitmap,
pub charging_targets: TlvList<'a, ChargingTargetStruct>,
}
impl<'a> ToTlv for ChargingTargetScheduleStruct<'a> {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.day_of_week_for_sequence.to_tlv(w, Tag::Context(0))?;
self.charging_targets.to_tlv(w, Tag::Context(1))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for ChargingTargetScheduleStruct<'a> {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut day_of_week_for_sequence = None;
let mut charging_targets = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => {
day_of_week_for_sequence =
Some(<TargetDayOfWeekBitmap>::from_tlv(reader, &field)?)
}
Some(1) => {
charging_targets = Some(<TlvList<'a, ChargingTargetStruct>>::from_tlv(
reader, &field,
)?)
}
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
day_of_week_for_sequence: day_of_week_for_sequence
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
charging_targets: charging_targets
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct ChargingTargetStruct {
pub target_time_minutes_past_midnight: u16,
pub target_so_c: Option<u8>,
pub added_energy: Option<i64>,
}
impl ToTlv for ChargingTargetStruct {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.target_time_minutes_past_midnight
.to_tlv(w, Tag::Context(0))?;
if let Some(value) = &self.target_so_c {
value.to_tlv(w, Tag::Context(1))?;
}
if let Some(value) = &self.added_energy {
value.to_tlv(w, Tag::Context(2))?;
}
w.end_container()
}
}
impl<'a> FromTlv<'a> for ChargingTargetStruct {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut target_time_minutes_past_midnight = None;
let mut target_so_c = None;
let mut added_energy = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => {
target_time_minutes_past_midnight = Some(<u16>::from_tlv(reader, &field)?)
}
Some(1) => target_so_c = Some(<u8>::from_tlv(reader, &field)?),
Some(2) => added_energy = Some(<i64>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
target_time_minutes_past_midnight: target_time_minutes_past_midnight
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
target_so_c,
added_energy,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct GetTargetsResponseFields<'a> {
pub charging_target_schedules: TlvList<'a, ChargingTargetScheduleStruct<'a>>,
}
impl<'a> ToTlv for GetTargetsResponseFields<'a> {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.charging_target_schedules.to_tlv(w, Tag::Context(0))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for GetTargetsResponseFields<'a> {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut charging_target_schedules = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => {
charging_target_schedules = Some(
<TlvList<'a, ChargingTargetScheduleStruct<'a>>>::from_tlv(reader, &field)?,
)
}
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
charging_target_schedules: charging_target_schedules
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct EnableChargingFields {
pub charging_enabled_until: Nullable<u32>,
pub minimum_charge_current: i32,
pub maximum_charge_current: i32,
}
impl ToTlv for EnableChargingFields {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.charging_enabled_until.to_tlv(w, Tag::Context(0))?;
self.minimum_charge_current.to_tlv(w, Tag::Context(1))?;
self.maximum_charge_current.to_tlv(w, Tag::Context(2))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for EnableChargingFields {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut charging_enabled_until = None;
let mut minimum_charge_current = None;
let mut maximum_charge_current = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => {
charging_enabled_until = Some(<Nullable<u32>>::from_tlv(reader, &field)?)
}
Some(1) => minimum_charge_current = Some(<i32>::from_tlv(reader, &field)?),
Some(2) => maximum_charge_current = Some(<i32>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
charging_enabled_until: charging_enabled_until
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
minimum_charge_current: minimum_charge_current
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
maximum_charge_current: maximum_charge_current
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct EnableDischargingFields {
pub discharging_enabled_until: Nullable<u32>,
pub maximum_discharge_current: i32,
}
impl ToTlv for EnableDischargingFields {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.discharging_enabled_until.to_tlv(w, Tag::Context(0))?;
self.maximum_discharge_current.to_tlv(w, Tag::Context(1))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for EnableDischargingFields {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut discharging_enabled_until = None;
let mut maximum_discharge_current = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => {
discharging_enabled_until = Some(<Nullable<u32>>::from_tlv(reader, &field)?)
}
Some(1) => maximum_discharge_current = Some(<i32>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
discharging_enabled_until: discharging_enabled_until
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
maximum_discharge_current: maximum_discharge_current
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct SetTargetsFields<'a> {
pub charging_target_schedules: TlvList<'a, ChargingTargetScheduleStruct<'a>>,
}
impl<'a> ToTlv for SetTargetsFields<'a> {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.charging_target_schedules.to_tlv(w, Tag::Context(0))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for SetTargetsFields<'a> {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut charging_target_schedules = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => {
charging_target_schedules = Some(
<TlvList<'a, ChargingTargetScheduleStruct<'a>>>::from_tlv(reader, &field)?,
)
}
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
charging_target_schedules: charging_target_schedules
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
pub const ATTRIBUTES: &[Attribute] = &[
Attribute {
id: 0x0000,
name: "State",
kind: "StateEnum",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NULLABLE,
reporting: Reporting::OnChange,
conform: Conform::MANDATORY,
},
Attribute {
id: 0x0001,
name: "SupplyState",
kind: "SupplyStateEnum",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::empty(),
reporting: Reporting::OnChange,
conform: Conform::MANDATORY,
},
Attribute {
id: 0x0002,
name: "FaultState",
kind: "FaultStateEnum",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::empty(),
reporting: Reporting::OnChange,
conform: Conform::MANDATORY,
},
Attribute {
id: 0x0003,
name: "ChargingEnabledUntil",
kind: "epoch-s",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NULLABLE.union(AttributeQualities::NON_VOLATILE),
reporting: Reporting::OnChange,
conform: Conform::MANDATORY,
},
Attribute {
id: 0x0004,
name: "DischargingEnabledUntil",
kind: "epoch-s",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NULLABLE.union(AttributeQualities::NON_VOLATILE),
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(4),
}],
},
},
Attribute {
id: 0x0005,
name: "CircuitCapacity",
kind: "amperage-mA",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NON_VOLATILE,
reporting: Reporting::OnChange,
conform: Conform::MANDATORY,
},
Attribute {
id: 0x0006,
name: "MinimumChargeCurrent",
kind: "amperage-mA",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NON_VOLATILE,
reporting: Reporting::OnChange,
conform: Conform::MANDATORY,
},
Attribute {
id: 0x0007,
name: "MaximumChargeCurrent",
kind: "amperage-mA",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NON_VOLATILE,
reporting: Reporting::OnChange,
conform: Conform::MANDATORY,
},
Attribute {
id: 0x0008,
name: "MaximumDischargeCurrent",
kind: "amperage-mA",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NON_VOLATILE,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(4),
}],
},
},
Attribute {
id: 0x0009,
name: "UserMaximumChargeCurrent",
kind: "amperage-mA",
access: Access::read_write_with(Privilege::View, Privilege::Manage),
qualities: AttributeQualities::NON_VOLATILE,
reporting: Reporting::OnChange,
conform: Conform::OPTIONAL,
},
Attribute {
id: 0x000A,
name: "RandomizationDelayWindow",
kind: "elapsed-s",
access: Access::read_write_with(Privilege::View, Privilege::Manage),
qualities: AttributeQualities::NON_VOLATILE,
reporting: Reporting::OnChange,
conform: Conform::OPTIONAL,
},
Attribute {
id: 0x0023,
name: "NextChargeStartTime",
kind: "epoch-s",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NULLABLE,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(0),
}],
},
},
Attribute {
id: 0x0024,
name: "NextChargeTargetTime",
kind: "epoch-s",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NULLABLE,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(0),
}],
},
},
Attribute {
id: 0x0025,
name: "NextChargeRequiredEnergy",
kind: "energy-mWh",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NULLABLE,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(0),
}],
},
},
Attribute {
id: 0x0026,
name: "NextChargeTargetSoC",
kind: "percent",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NULLABLE,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(0),
}],
},
},
Attribute {
id: 0x0027,
name: "ApproximateEVEfficiency",
kind: "uint16",
access: Access::read_write_with(Privilege::View, Privilege::Manage),
qualities: AttributeQualities::NULLABLE.union(AttributeQualities::NON_VOLATILE),
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Optional,
when: Condition::Feature(0),
}],
},
},
Attribute {
id: 0x0030,
name: "StateOfCharge",
kind: "percent",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NULLABLE,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(1),
}],
},
},
Attribute {
id: 0x0031,
name: "BatteryCapacity",
kind: "energy-mWh",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NULLABLE,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(1),
}],
},
},
Attribute {
id: 0x0032,
name: "VehicleID",
kind: "string",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NULLABLE,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(2),
}],
},
},
Attribute {
id: 0x0040,
name: "SessionID",
kind: "uint32",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NULLABLE.union(AttributeQualities::NON_VOLATILE),
reporting: Reporting::OnChange,
conform: Conform::MANDATORY,
},
Attribute {
id: 0x0041,
name: "SessionDuration",
kind: "elapsed-s",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NULLABLE.union(AttributeQualities::NON_VOLATILE),
reporting: Reporting::Quieter,
conform: Conform::MANDATORY,
},
Attribute {
id: 0x0042,
name: "SessionEnergyCharged",
kind: "energy-mWh",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NULLABLE.union(AttributeQualities::NON_VOLATILE),
reporting: Reporting::Quieter,
conform: Conform::MANDATORY,
},
Attribute {
id: 0x0043,
name: "SessionEnergyDischarged",
kind: "energy-mWh",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NULLABLE.union(AttributeQualities::NON_VOLATILE),
reporting: Reporting::Quieter,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(4),
}],
},
},
];
pub const COMMANDS: &[Command] = &[
Command {
id: 0x00,
name: "GetTargetsResponse",
to_server: false,
response: None,
access: Access::invoke(Privilege::Operate),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(0),
}],
},
},
Command {
id: 0x01,
name: "Disable",
to_server: true,
response: None,
access: Access::invoke(Privilege::Operate).with_qualities(AccessQualities::TIMED),
conform: Conform::MANDATORY,
},
Command {
id: 0x02,
name: "EnableCharging",
to_server: true,
response: None,
access: Access::invoke(Privilege::Operate).with_qualities(AccessQualities::TIMED),
conform: Conform::MANDATORY,
},
Command {
id: 0x03,
name: "EnableDischarging",
to_server: true,
response: None,
access: Access::invoke(Privilege::Operate).with_qualities(AccessQualities::TIMED),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(4),
}],
},
},
Command {
id: 0x04,
name: "StartDiagnostics",
to_server: true,
response: None,
access: Access::invoke(Privilege::Operate).with_qualities(AccessQualities::TIMED),
conform: Conform::OPTIONAL,
},
Command {
id: 0x05,
name: "SetTargets",
to_server: true,
response: None,
access: Access::invoke(Privilege::Operate).with_qualities(AccessQualities::TIMED),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(0),
}],
},
},
Command {
id: 0x06,
name: "GetTargets",
to_server: true,
response: Some(0x00),
access: Access::invoke(Privilege::Operate).with_qualities(AccessQualities::TIMED),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(0),
}],
},
},
Command {
id: 0x07,
name: "ClearTargets",
to_server: true,
response: None,
access: Access::invoke(Privilege::Operate).with_qualities(AccessQualities::TIMED),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(0),
}],
},
},
];
pub const EVENTS: &[Event] = &[
Event {
id: 0x00,
name: "EVConnected",
priority: EventPriority::Info,
access: Access::read_only(Privilege::View),
conform: Conform::MANDATORY,
},
Event {
id: 0x01,
name: "EVNotDetected",
priority: EventPriority::Info,
access: Access::read_only(Privilege::View),
conform: Conform::MANDATORY,
},
Event {
id: 0x02,
name: "EnergyTransferStarted",
priority: EventPriority::Info,
access: Access::read_only(Privilege::View),
conform: Conform::MANDATORY,
},
Event {
id: 0x03,
name: "EnergyTransferStopped",
priority: EventPriority::Info,
access: Access::read_only(Privilege::View),
conform: Conform::MANDATORY,
},
Event {
id: 0x04,
name: "Fault",
priority: EventPriority::Critical,
access: Access::read_only(Privilege::View),
conform: Conform::MANDATORY,
},
Event {
id: 0x05,
name: "RFID",
priority: EventPriority::Info,
access: Access::read_only(Privilege::View),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Optional,
when: Condition::Feature(3),
}],
},
},
];
pub const CLUSTER: Cluster = Cluster {
id: ID,
name: "Energy EVSE",
revision: REVISION,
pics: "EEVSE",
derived_from: None,
features: FEATURES,
attributes: ATTRIBUTES,
commands: COMMANDS,
events: EVENTS,
};