#![allow(
unused_imports,
clippy::doc_markdown,
clippy::too_many_lines,
clippy::needless_range_loop,
clippy::similar_names,
clippy::upper_case_acronyms,
clippy::struct_excessive_bools,
clippy::module_name_repetitions,
clippy::enum_variant_names,
clippy::never_loop,
clippy::cast_possible_truncation,
clippy::cast_lossless,
clippy::manual_range_contains,
clippy::useless_conversion,
clippy::unnecessary_cast,
clippy::redundant_closure_for_method_calls,
clippy::wildcard_imports,
clippy::match_same_arms,
clippy::single_match_else,
clippy::large_enum_variant,
clippy::result_large_err,
clippy::unreadable_literal
)]
use alloc::string::String;
use alloc::vec::Vec;
use crate::exi::seq::{SIMPLE_WIDTH, SeqReader, SeqWriter, Shape, Step};
use crate::exi::{
DateTime, Decimal, Decoder, Encoder, ExiError, ExiResult, Float, Lengths, ValueCtx,
};
pub const SCHEMA: &str = "V2G_CI_AC";
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ACCPDReqEnergyTransferMode {
pub ev_maximum_charge_power: super::common::RationalNumber,
pub ev_maximum_charge_power_l2: Option<super::common::RationalNumber>,
pub ev_maximum_charge_power_l3: Option<super::common::RationalNumber>,
pub ev_minimum_charge_power: super::common::RationalNumber,
pub ev_minimum_charge_power_l2: Option<super::common::RationalNumber>,
pub ev_minimum_charge_power_l3: Option<super::common::RationalNumber>,
}
impl ACCPDReqEnergyTransferMode {
const SHAPE: Shape = Shape {
prod_before: &[0, 1, 2, 3, 4, 5, 6],
width: &[1, 2, 2, 1, 2, 2, 1],
repeat_width: &[0, 0, 0, 0, 0, 0],
min: &[1, 0, 0, 1, 0, 0],
max: &[1, 1, 1, 1, 1, 1],
};
}
impl ACCPDReqEnergyTransferMode {
pub fn encode_body(&self, e: &mut Encoder<'_>) -> ExiResult<()> {
e.enter()?;
let mut w = SeqWriter::new(Self::SHAPE);
{
let item = &self.ev_maximum_charge_power;
w.start(e, 0, 0)?;
item.encode_body(e)?;
w.finish(0, 1);
}
if let Some(item) = &self.ev_maximum_charge_power_l2 {
w.start(e, 1, 0)?;
item.encode_body(e)?;
w.finish(1, 1);
}
if let Some(item) = &self.ev_maximum_charge_power_l3 {
w.start(e, 2, 0)?;
item.encode_body(e)?;
w.finish(2, 1);
}
{
let item = &self.ev_minimum_charge_power;
w.start(e, 3, 0)?;
item.encode_body(e)?;
w.finish(3, 1);
}
if let Some(item) = &self.ev_minimum_charge_power_l2 {
w.start(e, 4, 0)?;
item.encode_body(e)?;
w.finish(4, 1);
}
if let Some(item) = &self.ev_minimum_charge_power_l3 {
w.start(e, 5, 0)?;
item.encode_body(e)?;
w.finish(5, 1);
}
w.end(e)?;
e.leave();
Ok(())
}
}
impl ACCPDReqEnergyTransferMode {
pub fn decode_body(d: &mut Decoder<'_>) -> ExiResult<Self> {
d.enter()?;
let mut r = SeqReader::new(Self::SHAPE);
let mut f_0 = None;
let mut f_1 = None;
let mut f_2 = None;
let mut f_3 = None;
let mut f_4 = None;
let mut f_5 = None;
loop {
match r.next(d)? {
Step::End => break,
Step::Item { index: 0, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_0 = Some(value);
}
Step::Item { index: 1, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_1 = Some(value);
}
Step::Item { index: 2, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_2 = Some(value);
}
Step::Item { index: 3, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_3 = Some(value);
}
Step::Item { index: 4, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_4 = Some(value);
}
Step::Item { index: 5, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_5 = Some(value);
}
Step::Item { .. } => return Err(ExiError::UnknownEventCode),
}
}
d.leave();
Ok(Self {
ev_maximum_charge_power: f_0.ok_or(ExiError::MissingElement)?,
ev_maximum_charge_power_l2: f_1,
ev_maximum_charge_power_l3: f_2,
ev_minimum_charge_power: f_3.ok_or(ExiError::MissingElement)?,
ev_minimum_charge_power_l2: f_4,
ev_minimum_charge_power_l3: f_5,
})
}
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ACCPDResEnergyTransferMode {
pub evse_maximum_charge_power: super::common::RationalNumber,
pub evse_maximum_charge_power_l2: Option<super::common::RationalNumber>,
pub evse_maximum_charge_power_l3: Option<super::common::RationalNumber>,
pub evse_minimum_charge_power: super::common::RationalNumber,
pub evse_minimum_charge_power_l2: Option<super::common::RationalNumber>,
pub evse_minimum_charge_power_l3: Option<super::common::RationalNumber>,
pub evse_nominal_frequency: super::common::RationalNumber,
pub maximum_power_asymmetry: Option<super::common::RationalNumber>,
pub evse_power_ramp_limitation: Option<super::common::RationalNumber>,
pub evse_present_active_power: Option<super::common::RationalNumber>,
pub evse_present_active_power_l2: Option<super::common::RationalNumber>,
pub evse_present_active_power_l3: Option<super::common::RationalNumber>,
}
impl ACCPDResEnergyTransferMode {
const SHAPE: Shape = Shape {
prod_before: &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
width: &[1, 2, 2, 1, 2, 2, 1, 3, 3, 3, 2, 2, 1],
repeat_width: &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
min: &[1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0],
max: &[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
};
}
impl ACCPDResEnergyTransferMode {
pub fn encode_body(&self, e: &mut Encoder<'_>) -> ExiResult<()> {
e.enter()?;
let mut w = SeqWriter::new(Self::SHAPE);
{
let item = &self.evse_maximum_charge_power;
w.start(e, 0, 0)?;
item.encode_body(e)?;
w.finish(0, 1);
}
if let Some(item) = &self.evse_maximum_charge_power_l2 {
w.start(e, 1, 0)?;
item.encode_body(e)?;
w.finish(1, 1);
}
if let Some(item) = &self.evse_maximum_charge_power_l3 {
w.start(e, 2, 0)?;
item.encode_body(e)?;
w.finish(2, 1);
}
{
let item = &self.evse_minimum_charge_power;
w.start(e, 3, 0)?;
item.encode_body(e)?;
w.finish(3, 1);
}
if let Some(item) = &self.evse_minimum_charge_power_l2 {
w.start(e, 4, 0)?;
item.encode_body(e)?;
w.finish(4, 1);
}
if let Some(item) = &self.evse_minimum_charge_power_l3 {
w.start(e, 5, 0)?;
item.encode_body(e)?;
w.finish(5, 1);
}
{
let item = &self.evse_nominal_frequency;
w.start(e, 6, 0)?;
item.encode_body(e)?;
w.finish(6, 1);
}
if let Some(item) = &self.maximum_power_asymmetry {
w.start(e, 7, 0)?;
item.encode_body(e)?;
w.finish(7, 1);
}
if let Some(item) = &self.evse_power_ramp_limitation {
w.start(e, 8, 0)?;
item.encode_body(e)?;
w.finish(8, 1);
}
if let Some(item) = &self.evse_present_active_power {
w.start(e, 9, 0)?;
item.encode_body(e)?;
w.finish(9, 1);
}
if let Some(item) = &self.evse_present_active_power_l2 {
w.start(e, 10, 0)?;
item.encode_body(e)?;
w.finish(10, 1);
}
if let Some(item) = &self.evse_present_active_power_l3 {
w.start(e, 11, 0)?;
item.encode_body(e)?;
w.finish(11, 1);
}
w.end(e)?;
e.leave();
Ok(())
}
}
impl ACCPDResEnergyTransferMode {
pub fn decode_body(d: &mut Decoder<'_>) -> ExiResult<Self> {
d.enter()?;
let mut r = SeqReader::new(Self::SHAPE);
let mut f_0 = None;
let mut f_1 = None;
let mut f_2 = None;
let mut f_3 = None;
let mut f_4 = None;
let mut f_5 = None;
let mut f_6 = None;
let mut f_7 = None;
let mut f_8 = None;
let mut f_9 = None;
let mut f_10 = None;
let mut f_11 = None;
loop {
match r.next(d)? {
Step::End => break,
Step::Item { index: 0, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_0 = Some(value);
}
Step::Item { index: 1, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_1 = Some(value);
}
Step::Item { index: 2, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_2 = Some(value);
}
Step::Item { index: 3, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_3 = Some(value);
}
Step::Item { index: 4, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_4 = Some(value);
}
Step::Item { index: 5, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_5 = Some(value);
}
Step::Item { index: 6, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_6 = Some(value);
}
Step::Item { index: 7, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_7 = Some(value);
}
Step::Item { index: 8, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_8 = Some(value);
}
Step::Item { index: 9, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_9 = Some(value);
}
Step::Item { index: 10, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_10 = Some(value);
}
Step::Item { index: 11, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_11 = Some(value);
}
Step::Item { .. } => return Err(ExiError::UnknownEventCode),
}
}
d.leave();
Ok(Self {
evse_maximum_charge_power: f_0.ok_or(ExiError::MissingElement)?,
evse_maximum_charge_power_l2: f_1,
evse_maximum_charge_power_l3: f_2,
evse_minimum_charge_power: f_3.ok_or(ExiError::MissingElement)?,
evse_minimum_charge_power_l2: f_4,
evse_minimum_charge_power_l3: f_5,
evse_nominal_frequency: f_6.ok_or(ExiError::MissingElement)?,
maximum_power_asymmetry: f_7,
evse_power_ramp_limitation: f_8,
evse_present_active_power: f_9,
evse_present_active_power_l2: f_10,
evse_present_active_power_l3: f_11,
})
}
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum ACChargeLoopReqChoice {
BPTDynamicACCLReqControlMode(BPTDynamicACCLReqControlMode),
BPTScheduledACCLReqControlMode(BPTScheduledACCLReqControlMode),
CLReqControlMode(super::common::CLReqControlMode),
DynamicACCLReqControlMode(DynamicACCLReqControlMode),
ScheduledACCLReqControlMode(ScheduledACCLReqControlMode),
}
impl ACChargeLoopReqChoice {
#[must_use]
pub const fn name(&self) -> &'static str {
match self {
Self::BPTDynamicACCLReqControlMode(_) => "BPT_Dynamic_AC_CLReqControlMode",
Self::BPTScheduledACCLReqControlMode(_) => "BPT_Scheduled_AC_CLReqControlMode",
Self::CLReqControlMode(_) => "CLReqControlMode",
Self::DynamicACCLReqControlMode(_) => "Dynamic_AC_CLReqControlMode",
Self::ScheduledACCLReqControlMode(_) => "Scheduled_AC_CLReqControlMode",
}
}
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ACChargeLoopReq {
pub header: super::common::MessageHeader,
pub display_parameters: Option<super::common::DisplayParameters>,
pub meter_info_requested: bool,
pub choice: ACChargeLoopReqChoice,
}
impl ACChargeLoopReq {
const SHAPE: Shape = Shape {
prod_before: &[0, 1, 2, 3, 8],
width: &[1, 2, 1, 3, 1],
repeat_width: &[0, 0, 0, 0],
min: &[1, 0, 1, 1],
max: &[1, 1, 1, 1],
};
}
impl ACChargeLoopReq {
pub fn encode_body(&self, e: &mut Encoder<'_>) -> ExiResult<()> {
e.enter()?;
let mut w = SeqWriter::new(Self::SHAPE);
{
let item = &self.header;
w.start(e, 0, 0)?;
item.encode_body(e)?;
w.finish(0, 1);
}
if let Some(item) = &self.display_parameters {
w.start(e, 1, 0)?;
item.encode_body(e)?;
w.finish(1, 1);
}
{
let item = &self.meter_info_requested;
w.start(e, 2, 0)?;
e.event(0, SIMPLE_WIDTH)?; e.boolean(*item)?;
e.event(0, SIMPLE_WIDTH)?; w.finish(2, 1);
}
{
let item = &self.choice;
match item {
ACChargeLoopReqChoice::BPTDynamicACCLReqControlMode(value) => {
w.start_branch(e, 3, 0, 0)?;
value.encode_body(e)?;
}
ACChargeLoopReqChoice::BPTScheduledACCLReqControlMode(value) => {
w.start_branch(e, 3, 0, 1)?;
value.encode_body(e)?;
}
ACChargeLoopReqChoice::CLReqControlMode(value) => {
w.start_branch(e, 3, 0, 2)?;
value.encode_body(e)?;
}
ACChargeLoopReqChoice::DynamicACCLReqControlMode(value) => {
w.start_branch(e, 3, 0, 3)?;
value.encode_body(e)?;
}
ACChargeLoopReqChoice::ScheduledACCLReqControlMode(value) => {
w.start_branch(e, 3, 0, 4)?;
value.encode_body(e)?;
}
}
w.finish(3, 1);
}
w.end(e)?;
e.leave();
Ok(())
}
}
impl ACChargeLoopReq {
pub fn decode_body(d: &mut Decoder<'_>) -> ExiResult<Self> {
d.enter()?;
let mut r = SeqReader::new(Self::SHAPE);
let mut f_0 = None;
let mut f_1 = None;
let mut f_2 = None;
let mut f_3 = None;
loop {
match r.next(d)? {
Step::End => break,
Step::Item { index: 0, .. } => {
let value = super::common::MessageHeader::decode_body(d)?;
f_0 = Some(value);
}
Step::Item { index: 1, .. } => {
let value = super::common::DisplayParameters::decode_body(d)?;
f_1 = Some(value);
}
Step::Item { index: 2, .. } => {
d.expect_event(0, SIMPLE_WIDTH)?; let value = d.boolean()?;
d.expect_event(0, SIMPLE_WIDTH)?; f_2 = Some(value);
}
Step::Item { index: 3, branch, .. } => {
let value = match branch {
0 => {
let value = BPTDynamicACCLReqControlMode::decode_body(d)?;
ACChargeLoopReqChoice::BPTDynamicACCLReqControlMode(value)
}
1 => {
let value = BPTScheduledACCLReqControlMode::decode_body(d)?;
ACChargeLoopReqChoice::BPTScheduledACCLReqControlMode(value)
}
2 => {
let value = super::common::CLReqControlMode::decode_body(d)?;
ACChargeLoopReqChoice::CLReqControlMode(value)
}
3 => {
let value = DynamicACCLReqControlMode::decode_body(d)?;
ACChargeLoopReqChoice::DynamicACCLReqControlMode(value)
}
4 => {
let value = ScheduledACCLReqControlMode::decode_body(d)?;
ACChargeLoopReqChoice::ScheduledACCLReqControlMode(value)
}
_ => return Err(ExiError::UnknownEventCode),
};
f_3 = Some(value);
}
Step::Item { .. } => return Err(ExiError::UnknownEventCode),
}
}
d.leave();
Ok(Self {
header: f_0.ok_or(ExiError::MissingElement)?,
display_parameters: f_1,
meter_info_requested: f_2.ok_or(ExiError::MissingElement)?,
choice: f_3.ok_or(ExiError::MissingElement)?,
})
}
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum ACChargeLoopResChoice {
BPTDynamicACCLResControlMode(BPTDynamicACCLResControlMode),
BPTScheduledACCLResControlMode(BPTScheduledACCLResControlMode),
CLResControlMode(super::common::CLResControlMode),
DynamicACCLResControlMode(DynamicACCLResControlMode),
ScheduledACCLResControlMode(ScheduledACCLResControlMode),
}
impl ACChargeLoopResChoice {
#[must_use]
pub const fn name(&self) -> &'static str {
match self {
Self::BPTDynamicACCLResControlMode(_) => "BPT_Dynamic_AC_CLResControlMode",
Self::BPTScheduledACCLResControlMode(_) => "BPT_Scheduled_AC_CLResControlMode",
Self::CLResControlMode(_) => "CLResControlMode",
Self::DynamicACCLResControlMode(_) => "Dynamic_AC_CLResControlMode",
Self::ScheduledACCLResControlMode(_) => "Scheduled_AC_CLResControlMode",
}
}
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ACChargeLoopRes {
pub header: super::common::MessageHeader,
pub response_code: super::common::ResponseCode,
pub evse_status: Option<super::common::EVSEStatus>,
pub meter_info: Option<super::common::MeterInfo>,
pub receipt: Option<super::common::Receipt>,
pub evse_target_frequency: Option<super::common::RationalNumber>,
pub choice: ACChargeLoopResChoice,
}
impl ACChargeLoopRes {
const SHAPE: Shape = Shape {
prod_before: &[0, 1, 2, 3, 4, 5, 6, 11],
width: &[1, 1, 4, 4, 3, 3, 3, 1],
repeat_width: &[0, 0, 0, 0, 0, 0, 0],
min: &[1, 1, 0, 0, 0, 0, 1],
max: &[1, 1, 1, 1, 1, 1, 1],
};
}
impl ACChargeLoopRes {
pub fn encode_body(&self, e: &mut Encoder<'_>) -> ExiResult<()> {
e.enter()?;
let mut w = SeqWriter::new(Self::SHAPE);
{
let item = &self.header;
w.start(e, 0, 0)?;
item.encode_body(e)?;
w.finish(0, 1);
}
{
let item = &self.response_code;
w.start(e, 1, 0)?;
e.event(0, SIMPLE_WIDTH)?; e.nbit(item.as_index(), super::common::ResponseCode::WIDTH)?;
e.event(0, SIMPLE_WIDTH)?; w.finish(1, 1);
}
if let Some(item) = &self.evse_status {
w.start(e, 2, 0)?;
item.encode_body(e)?;
w.finish(2, 1);
}
if let Some(item) = &self.meter_info {
w.start(e, 3, 0)?;
item.encode_body(e)?;
w.finish(3, 1);
}
if let Some(item) = &self.receipt {
w.start(e, 4, 0)?;
item.encode_body(e)?;
w.finish(4, 1);
}
if let Some(item) = &self.evse_target_frequency {
w.start(e, 5, 0)?;
item.encode_body(e)?;
w.finish(5, 1);
}
{
let item = &self.choice;
match item {
ACChargeLoopResChoice::BPTDynamicACCLResControlMode(value) => {
w.start_branch(e, 6, 0, 0)?;
value.encode_body(e)?;
}
ACChargeLoopResChoice::BPTScheduledACCLResControlMode(value) => {
w.start_branch(e, 6, 0, 1)?;
value.encode_body(e)?;
}
ACChargeLoopResChoice::CLResControlMode(value) => {
w.start_branch(e, 6, 0, 2)?;
value.encode_body(e)?;
}
ACChargeLoopResChoice::DynamicACCLResControlMode(value) => {
w.start_branch(e, 6, 0, 3)?;
value.encode_body(e)?;
}
ACChargeLoopResChoice::ScheduledACCLResControlMode(value) => {
w.start_branch(e, 6, 0, 4)?;
value.encode_body(e)?;
}
}
w.finish(6, 1);
}
w.end(e)?;
e.leave();
Ok(())
}
}
impl ACChargeLoopRes {
pub fn decode_body(d: &mut Decoder<'_>) -> ExiResult<Self> {
d.enter()?;
let mut r = SeqReader::new(Self::SHAPE);
let mut f_0 = None;
let mut f_1 = None;
let mut f_2 = None;
let mut f_3 = None;
let mut f_4 = None;
let mut f_5 = None;
let mut f_6 = None;
loop {
match r.next(d)? {
Step::End => break,
Step::Item { index: 0, .. } => {
let value = super::common::MessageHeader::decode_body(d)?;
f_0 = Some(value);
}
Step::Item { index: 1, .. } => {
d.expect_event(0, SIMPLE_WIDTH)?; let value = super::common::ResponseCode::from_index(
d.nbit(super::common::ResponseCode::WIDTH)?,
)?;
d.expect_event(0, SIMPLE_WIDTH)?; f_1 = Some(value);
}
Step::Item { index: 2, .. } => {
let value = super::common::EVSEStatus::decode_body(d)?;
f_2 = Some(value);
}
Step::Item { index: 3, .. } => {
let value = super::common::MeterInfo::decode_body(d)?;
f_3 = Some(value);
}
Step::Item { index: 4, .. } => {
let value = super::common::Receipt::decode_body(d)?;
f_4 = Some(value);
}
Step::Item { index: 5, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_5 = Some(value);
}
Step::Item { index: 6, branch, .. } => {
let value = match branch {
0 => {
let value = BPTDynamicACCLResControlMode::decode_body(d)?;
ACChargeLoopResChoice::BPTDynamicACCLResControlMode(value)
}
1 => {
let value = BPTScheduledACCLResControlMode::decode_body(d)?;
ACChargeLoopResChoice::BPTScheduledACCLResControlMode(value)
}
2 => {
let value = super::common::CLResControlMode::decode_body(d)?;
ACChargeLoopResChoice::CLResControlMode(value)
}
3 => {
let value = DynamicACCLResControlMode::decode_body(d)?;
ACChargeLoopResChoice::DynamicACCLResControlMode(value)
}
4 => {
let value = ScheduledACCLResControlMode::decode_body(d)?;
ACChargeLoopResChoice::ScheduledACCLResControlMode(value)
}
_ => return Err(ExiError::UnknownEventCode),
};
f_6 = Some(value);
}
Step::Item { .. } => return Err(ExiError::UnknownEventCode),
}
}
d.leave();
Ok(Self {
header: f_0.ok_or(ExiError::MissingElement)?,
response_code: f_1.ok_or(ExiError::MissingElement)?,
evse_status: f_2,
meter_info: f_3,
receipt: f_4,
evse_target_frequency: f_5,
choice: f_6.ok_or(ExiError::MissingElement)?,
})
}
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum ACChargeParameterDiscoveryReqChoice {
ACCPDReqEnergyTransferMode(ACCPDReqEnergyTransferMode),
BPTACCPDReqEnergyTransferMode(BPTACCPDReqEnergyTransferMode),
}
impl ACChargeParameterDiscoveryReqChoice {
#[must_use]
pub const fn name(&self) -> &'static str {
match self {
Self::ACCPDReqEnergyTransferMode(_) => "AC_CPDReqEnergyTransferMode",
Self::BPTACCPDReqEnergyTransferMode(_) => "BPT_AC_CPDReqEnergyTransferMode",
}
}
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ACChargeParameterDiscoveryReq {
pub header: super::common::MessageHeader,
pub choice: ACChargeParameterDiscoveryReqChoice,
}
impl ACChargeParameterDiscoveryReq {
const SHAPE: Shape = Shape {
prod_before: &[0, 1, 3],
width: &[1, 2, 1],
repeat_width: &[0, 0],
min: &[1, 1],
max: &[1, 1],
};
}
impl ACChargeParameterDiscoveryReq {
pub fn encode_body(&self, e: &mut Encoder<'_>) -> ExiResult<()> {
e.enter()?;
let mut w = SeqWriter::new(Self::SHAPE);
{
let item = &self.header;
w.start(e, 0, 0)?;
item.encode_body(e)?;
w.finish(0, 1);
}
{
let item = &self.choice;
match item {
ACChargeParameterDiscoveryReqChoice::ACCPDReqEnergyTransferMode(value) => {
w.start_branch(e, 1, 0, 0)?;
value.encode_body(e)?;
}
ACChargeParameterDiscoveryReqChoice::BPTACCPDReqEnergyTransferMode(value) => {
w.start_branch(e, 1, 0, 1)?;
value.encode_body(e)?;
}
}
w.finish(1, 1);
}
w.end(e)?;
e.leave();
Ok(())
}
}
impl ACChargeParameterDiscoveryReq {
pub fn decode_body(d: &mut Decoder<'_>) -> ExiResult<Self> {
d.enter()?;
let mut r = SeqReader::new(Self::SHAPE);
let mut f_0 = None;
let mut f_1 = None;
loop {
match r.next(d)? {
Step::End => break,
Step::Item { index: 0, .. } => {
let value = super::common::MessageHeader::decode_body(d)?;
f_0 = Some(value);
}
Step::Item { index: 1, branch, .. } => {
let value = match branch {
0 => {
let value = ACCPDReqEnergyTransferMode::decode_body(d)?;
ACChargeParameterDiscoveryReqChoice::ACCPDReqEnergyTransferMode(value)
}
1 => {
let value = BPTACCPDReqEnergyTransferMode::decode_body(d)?;
ACChargeParameterDiscoveryReqChoice::BPTACCPDReqEnergyTransferMode(
value,
)
}
_ => return Err(ExiError::UnknownEventCode),
};
f_1 = Some(value);
}
Step::Item { .. } => return Err(ExiError::UnknownEventCode),
}
}
d.leave();
Ok(Self {
header: f_0.ok_or(ExiError::MissingElement)?,
choice: f_1.ok_or(ExiError::MissingElement)?,
})
}
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum ACChargeParameterDiscoveryResChoice {
ACCPDResEnergyTransferMode(ACCPDResEnergyTransferMode),
BPTACCPDResEnergyTransferMode(BPTACCPDResEnergyTransferMode),
}
impl ACChargeParameterDiscoveryResChoice {
#[must_use]
pub const fn name(&self) -> &'static str {
match self {
Self::ACCPDResEnergyTransferMode(_) => "AC_CPDResEnergyTransferMode",
Self::BPTACCPDResEnergyTransferMode(_) => "BPT_AC_CPDResEnergyTransferMode",
}
}
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ACChargeParameterDiscoveryRes {
pub header: super::common::MessageHeader,
pub response_code: super::common::ResponseCode,
pub choice: ACChargeParameterDiscoveryResChoice,
}
impl ACChargeParameterDiscoveryRes {
const SHAPE: Shape = Shape {
prod_before: &[0, 1, 2, 4],
width: &[1, 1, 2, 1],
repeat_width: &[0, 0, 0],
min: &[1, 1, 1],
max: &[1, 1, 1],
};
}
impl ACChargeParameterDiscoveryRes {
pub fn encode_body(&self, e: &mut Encoder<'_>) -> ExiResult<()> {
e.enter()?;
let mut w = SeqWriter::new(Self::SHAPE);
{
let item = &self.header;
w.start(e, 0, 0)?;
item.encode_body(e)?;
w.finish(0, 1);
}
{
let item = &self.response_code;
w.start(e, 1, 0)?;
e.event(0, SIMPLE_WIDTH)?; e.nbit(item.as_index(), super::common::ResponseCode::WIDTH)?;
e.event(0, SIMPLE_WIDTH)?; w.finish(1, 1);
}
{
let item = &self.choice;
match item {
ACChargeParameterDiscoveryResChoice::ACCPDResEnergyTransferMode(value) => {
w.start_branch(e, 2, 0, 0)?;
value.encode_body(e)?;
}
ACChargeParameterDiscoveryResChoice::BPTACCPDResEnergyTransferMode(value) => {
w.start_branch(e, 2, 0, 1)?;
value.encode_body(e)?;
}
}
w.finish(2, 1);
}
w.end(e)?;
e.leave();
Ok(())
}
}
impl ACChargeParameterDiscoveryRes {
pub fn decode_body(d: &mut Decoder<'_>) -> ExiResult<Self> {
d.enter()?;
let mut r = SeqReader::new(Self::SHAPE);
let mut f_0 = None;
let mut f_1 = None;
let mut f_2 = None;
loop {
match r.next(d)? {
Step::End => break,
Step::Item { index: 0, .. } => {
let value = super::common::MessageHeader::decode_body(d)?;
f_0 = Some(value);
}
Step::Item { index: 1, .. } => {
d.expect_event(0, SIMPLE_WIDTH)?; let value = super::common::ResponseCode::from_index(
d.nbit(super::common::ResponseCode::WIDTH)?,
)?;
d.expect_event(0, SIMPLE_WIDTH)?; f_1 = Some(value);
}
Step::Item { index: 2, branch, .. } => {
let value = match branch {
0 => {
let value = ACCPDResEnergyTransferMode::decode_body(d)?;
ACChargeParameterDiscoveryResChoice::ACCPDResEnergyTransferMode(value)
}
1 => {
let value = BPTACCPDResEnergyTransferMode::decode_body(d)?;
ACChargeParameterDiscoveryResChoice::BPTACCPDResEnergyTransferMode(
value,
)
}
_ => return Err(ExiError::UnknownEventCode),
};
f_2 = Some(value);
}
Step::Item { .. } => return Err(ExiError::UnknownEventCode),
}
}
d.leave();
Ok(Self {
header: f_0.ok_or(ExiError::MissingElement)?,
response_code: f_1.ok_or(ExiError::MissingElement)?,
choice: f_2.ok_or(ExiError::MissingElement)?,
})
}
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct BPTACCPDReqEnergyTransferMode {
pub ev_maximum_charge_power: super::common::RationalNumber,
pub ev_maximum_charge_power_l2: Option<super::common::RationalNumber>,
pub ev_maximum_charge_power_l3: Option<super::common::RationalNumber>,
pub ev_minimum_charge_power: super::common::RationalNumber,
pub ev_minimum_charge_power_l2: Option<super::common::RationalNumber>,
pub ev_minimum_charge_power_l3: Option<super::common::RationalNumber>,
pub ev_maximum_discharge_power: super::common::RationalNumber,
pub ev_maximum_discharge_power_l2: Option<super::common::RationalNumber>,
pub ev_maximum_discharge_power_l3: Option<super::common::RationalNumber>,
pub ev_minimum_discharge_power: super::common::RationalNumber,
pub ev_minimum_discharge_power_l2: Option<super::common::RationalNumber>,
pub ev_minimum_discharge_power_l3: Option<super::common::RationalNumber>,
}
impl BPTACCPDReqEnergyTransferMode {
const SHAPE: Shape = Shape {
prod_before: &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
width: &[1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1],
repeat_width: &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
min: &[1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0],
max: &[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
};
}
impl BPTACCPDReqEnergyTransferMode {
pub fn encode_body(&self, e: &mut Encoder<'_>) -> ExiResult<()> {
e.enter()?;
let mut w = SeqWriter::new(Self::SHAPE);
{
let item = &self.ev_maximum_charge_power;
w.start(e, 0, 0)?;
item.encode_body(e)?;
w.finish(0, 1);
}
if let Some(item) = &self.ev_maximum_charge_power_l2 {
w.start(e, 1, 0)?;
item.encode_body(e)?;
w.finish(1, 1);
}
if let Some(item) = &self.ev_maximum_charge_power_l3 {
w.start(e, 2, 0)?;
item.encode_body(e)?;
w.finish(2, 1);
}
{
let item = &self.ev_minimum_charge_power;
w.start(e, 3, 0)?;
item.encode_body(e)?;
w.finish(3, 1);
}
if let Some(item) = &self.ev_minimum_charge_power_l2 {
w.start(e, 4, 0)?;
item.encode_body(e)?;
w.finish(4, 1);
}
if let Some(item) = &self.ev_minimum_charge_power_l3 {
w.start(e, 5, 0)?;
item.encode_body(e)?;
w.finish(5, 1);
}
{
let item = &self.ev_maximum_discharge_power;
w.start(e, 6, 0)?;
item.encode_body(e)?;
w.finish(6, 1);
}
if let Some(item) = &self.ev_maximum_discharge_power_l2 {
w.start(e, 7, 0)?;
item.encode_body(e)?;
w.finish(7, 1);
}
if let Some(item) = &self.ev_maximum_discharge_power_l3 {
w.start(e, 8, 0)?;
item.encode_body(e)?;
w.finish(8, 1);
}
{
let item = &self.ev_minimum_discharge_power;
w.start(e, 9, 0)?;
item.encode_body(e)?;
w.finish(9, 1);
}
if let Some(item) = &self.ev_minimum_discharge_power_l2 {
w.start(e, 10, 0)?;
item.encode_body(e)?;
w.finish(10, 1);
}
if let Some(item) = &self.ev_minimum_discharge_power_l3 {
w.start(e, 11, 0)?;
item.encode_body(e)?;
w.finish(11, 1);
}
w.end(e)?;
e.leave();
Ok(())
}
}
impl BPTACCPDReqEnergyTransferMode {
pub fn decode_body(d: &mut Decoder<'_>) -> ExiResult<Self> {
d.enter()?;
let mut r = SeqReader::new(Self::SHAPE);
let mut f_0 = None;
let mut f_1 = None;
let mut f_2 = None;
let mut f_3 = None;
let mut f_4 = None;
let mut f_5 = None;
let mut f_6 = None;
let mut f_7 = None;
let mut f_8 = None;
let mut f_9 = None;
let mut f_10 = None;
let mut f_11 = None;
loop {
match r.next(d)? {
Step::End => break,
Step::Item { index: 0, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_0 = Some(value);
}
Step::Item { index: 1, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_1 = Some(value);
}
Step::Item { index: 2, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_2 = Some(value);
}
Step::Item { index: 3, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_3 = Some(value);
}
Step::Item { index: 4, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_4 = Some(value);
}
Step::Item { index: 5, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_5 = Some(value);
}
Step::Item { index: 6, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_6 = Some(value);
}
Step::Item { index: 7, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_7 = Some(value);
}
Step::Item { index: 8, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_8 = Some(value);
}
Step::Item { index: 9, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_9 = Some(value);
}
Step::Item { index: 10, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_10 = Some(value);
}
Step::Item { index: 11, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_11 = Some(value);
}
Step::Item { .. } => return Err(ExiError::UnknownEventCode),
}
}
d.leave();
Ok(Self {
ev_maximum_charge_power: f_0.ok_or(ExiError::MissingElement)?,
ev_maximum_charge_power_l2: f_1,
ev_maximum_charge_power_l3: f_2,
ev_minimum_charge_power: f_3.ok_or(ExiError::MissingElement)?,
ev_minimum_charge_power_l2: f_4,
ev_minimum_charge_power_l3: f_5,
ev_maximum_discharge_power: f_6.ok_or(ExiError::MissingElement)?,
ev_maximum_discharge_power_l2: f_7,
ev_maximum_discharge_power_l3: f_8,
ev_minimum_discharge_power: f_9.ok_or(ExiError::MissingElement)?,
ev_minimum_discharge_power_l2: f_10,
ev_minimum_discharge_power_l3: f_11,
})
}
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct BPTACCPDResEnergyTransferMode {
pub evse_maximum_charge_power: super::common::RationalNumber,
pub evse_maximum_charge_power_l2: Option<super::common::RationalNumber>,
pub evse_maximum_charge_power_l3: Option<super::common::RationalNumber>,
pub evse_minimum_charge_power: super::common::RationalNumber,
pub evse_minimum_charge_power_l2: Option<super::common::RationalNumber>,
pub evse_minimum_charge_power_l3: Option<super::common::RationalNumber>,
pub evse_nominal_frequency: super::common::RationalNumber,
pub maximum_power_asymmetry: Option<super::common::RationalNumber>,
pub evse_power_ramp_limitation: Option<super::common::RationalNumber>,
pub evse_present_active_power: Option<super::common::RationalNumber>,
pub evse_present_active_power_l2: Option<super::common::RationalNumber>,
pub evse_present_active_power_l3: Option<super::common::RationalNumber>,
pub evse_maximum_discharge_power: super::common::RationalNumber,
pub evse_maximum_discharge_power_l2: Option<super::common::RationalNumber>,
pub evse_maximum_discharge_power_l3: Option<super::common::RationalNumber>,
pub evse_minimum_discharge_power: super::common::RationalNumber,
pub evse_minimum_discharge_power_l2: Option<super::common::RationalNumber>,
pub evse_minimum_discharge_power_l3: Option<super::common::RationalNumber>,
}
impl BPTACCPDResEnergyTransferMode {
const SHAPE: Shape = Shape {
prod_before: &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18],
width: &[1, 2, 2, 1, 2, 2, 1, 3, 3, 3, 2, 2, 1, 2, 2, 1, 2, 2, 1],
repeat_width: &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
min: &[1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0],
max: &[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
};
}
impl BPTACCPDResEnergyTransferMode {
pub fn encode_body(&self, e: &mut Encoder<'_>) -> ExiResult<()> {
e.enter()?;
let mut w = SeqWriter::new(Self::SHAPE);
{
let item = &self.evse_maximum_charge_power;
w.start(e, 0, 0)?;
item.encode_body(e)?;
w.finish(0, 1);
}
if let Some(item) = &self.evse_maximum_charge_power_l2 {
w.start(e, 1, 0)?;
item.encode_body(e)?;
w.finish(1, 1);
}
if let Some(item) = &self.evse_maximum_charge_power_l3 {
w.start(e, 2, 0)?;
item.encode_body(e)?;
w.finish(2, 1);
}
{
let item = &self.evse_minimum_charge_power;
w.start(e, 3, 0)?;
item.encode_body(e)?;
w.finish(3, 1);
}
if let Some(item) = &self.evse_minimum_charge_power_l2 {
w.start(e, 4, 0)?;
item.encode_body(e)?;
w.finish(4, 1);
}
if let Some(item) = &self.evse_minimum_charge_power_l3 {
w.start(e, 5, 0)?;
item.encode_body(e)?;
w.finish(5, 1);
}
{
let item = &self.evse_nominal_frequency;
w.start(e, 6, 0)?;
item.encode_body(e)?;
w.finish(6, 1);
}
if let Some(item) = &self.maximum_power_asymmetry {
w.start(e, 7, 0)?;
item.encode_body(e)?;
w.finish(7, 1);
}
if let Some(item) = &self.evse_power_ramp_limitation {
w.start(e, 8, 0)?;
item.encode_body(e)?;
w.finish(8, 1);
}
if let Some(item) = &self.evse_present_active_power {
w.start(e, 9, 0)?;
item.encode_body(e)?;
w.finish(9, 1);
}
if let Some(item) = &self.evse_present_active_power_l2 {
w.start(e, 10, 0)?;
item.encode_body(e)?;
w.finish(10, 1);
}
if let Some(item) = &self.evse_present_active_power_l3 {
w.start(e, 11, 0)?;
item.encode_body(e)?;
w.finish(11, 1);
}
{
let item = &self.evse_maximum_discharge_power;
w.start(e, 12, 0)?;
item.encode_body(e)?;
w.finish(12, 1);
}
if let Some(item) = &self.evse_maximum_discharge_power_l2 {
w.start(e, 13, 0)?;
item.encode_body(e)?;
w.finish(13, 1);
}
if let Some(item) = &self.evse_maximum_discharge_power_l3 {
w.start(e, 14, 0)?;
item.encode_body(e)?;
w.finish(14, 1);
}
{
let item = &self.evse_minimum_discharge_power;
w.start(e, 15, 0)?;
item.encode_body(e)?;
w.finish(15, 1);
}
if let Some(item) = &self.evse_minimum_discharge_power_l2 {
w.start(e, 16, 0)?;
item.encode_body(e)?;
w.finish(16, 1);
}
if let Some(item) = &self.evse_minimum_discharge_power_l3 {
w.start(e, 17, 0)?;
item.encode_body(e)?;
w.finish(17, 1);
}
w.end(e)?;
e.leave();
Ok(())
}
}
impl BPTACCPDResEnergyTransferMode {
pub fn decode_body(d: &mut Decoder<'_>) -> ExiResult<Self> {
d.enter()?;
let mut r = SeqReader::new(Self::SHAPE);
let mut f_0 = None;
let mut f_1 = None;
let mut f_2 = None;
let mut f_3 = None;
let mut f_4 = None;
let mut f_5 = None;
let mut f_6 = None;
let mut f_7 = None;
let mut f_8 = None;
let mut f_9 = None;
let mut f_10 = None;
let mut f_11 = None;
let mut f_12 = None;
let mut f_13 = None;
let mut f_14 = None;
let mut f_15 = None;
let mut f_16 = None;
let mut f_17 = None;
loop {
match r.next(d)? {
Step::End => break,
Step::Item { index: 0, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_0 = Some(value);
}
Step::Item { index: 1, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_1 = Some(value);
}
Step::Item { index: 2, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_2 = Some(value);
}
Step::Item { index: 3, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_3 = Some(value);
}
Step::Item { index: 4, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_4 = Some(value);
}
Step::Item { index: 5, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_5 = Some(value);
}
Step::Item { index: 6, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_6 = Some(value);
}
Step::Item { index: 7, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_7 = Some(value);
}
Step::Item { index: 8, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_8 = Some(value);
}
Step::Item { index: 9, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_9 = Some(value);
}
Step::Item { index: 10, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_10 = Some(value);
}
Step::Item { index: 11, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_11 = Some(value);
}
Step::Item { index: 12, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_12 = Some(value);
}
Step::Item { index: 13, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_13 = Some(value);
}
Step::Item { index: 14, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_14 = Some(value);
}
Step::Item { index: 15, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_15 = Some(value);
}
Step::Item { index: 16, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_16 = Some(value);
}
Step::Item { index: 17, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_17 = Some(value);
}
Step::Item { .. } => return Err(ExiError::UnknownEventCode),
}
}
d.leave();
Ok(Self {
evse_maximum_charge_power: f_0.ok_or(ExiError::MissingElement)?,
evse_maximum_charge_power_l2: f_1,
evse_maximum_charge_power_l3: f_2,
evse_minimum_charge_power: f_3.ok_or(ExiError::MissingElement)?,
evse_minimum_charge_power_l2: f_4,
evse_minimum_charge_power_l3: f_5,
evse_nominal_frequency: f_6.ok_or(ExiError::MissingElement)?,
maximum_power_asymmetry: f_7,
evse_power_ramp_limitation: f_8,
evse_present_active_power: f_9,
evse_present_active_power_l2: f_10,
evse_present_active_power_l3: f_11,
evse_maximum_discharge_power: f_12.ok_or(ExiError::MissingElement)?,
evse_maximum_discharge_power_l2: f_13,
evse_maximum_discharge_power_l3: f_14,
evse_minimum_discharge_power: f_15.ok_or(ExiError::MissingElement)?,
evse_minimum_discharge_power_l2: f_16,
evse_minimum_discharge_power_l3: f_17,
})
}
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct BPTDynamicACCLReqControlMode {
pub departure_time: Option<u32>,
pub ev_target_energy_request: super::common::RationalNumber,
pub ev_maximum_energy_request: super::common::RationalNumber,
pub ev_minimum_energy_request: super::common::RationalNumber,
pub ev_maximum_charge_power: super::common::RationalNumber,
pub ev_maximum_charge_power_l2: Option<super::common::RationalNumber>,
pub ev_maximum_charge_power_l3: Option<super::common::RationalNumber>,
pub ev_minimum_charge_power: super::common::RationalNumber,
pub ev_minimum_charge_power_l2: Option<super::common::RationalNumber>,
pub ev_minimum_charge_power_l3: Option<super::common::RationalNumber>,
pub ev_present_active_power: super::common::RationalNumber,
pub ev_present_active_power_l2: Option<super::common::RationalNumber>,
pub ev_present_active_power_l3: Option<super::common::RationalNumber>,
pub ev_present_reactive_power: super::common::RationalNumber,
pub ev_present_reactive_power_l2: Option<super::common::RationalNumber>,
pub ev_present_reactive_power_l3: Option<super::common::RationalNumber>,
pub ev_maximum_discharge_power: super::common::RationalNumber,
pub ev_maximum_discharge_power_l2: Option<super::common::RationalNumber>,
pub ev_maximum_discharge_power_l3: Option<super::common::RationalNumber>,
pub ev_minimum_discharge_power: super::common::RationalNumber,
pub ev_minimum_discharge_power_l2: Option<super::common::RationalNumber>,
pub ev_minimum_discharge_power_l3: Option<super::common::RationalNumber>,
pub ev_maximum_v2_x_energy_request: Option<super::common::RationalNumber>,
pub ev_minimum_v2_x_energy_request: Option<super::common::RationalNumber>,
}
impl BPTDynamicACCLReqControlMode {
const SHAPE: Shape = Shape {
prod_before: &[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
24,
],
width: &[2, 1, 1, 1, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 3, 3, 2, 2, 1],
repeat_width: &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
min: &[0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0],
max: &[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
};
}
impl BPTDynamicACCLReqControlMode {
pub fn encode_body(&self, e: &mut Encoder<'_>) -> ExiResult<()> {
e.enter()?;
let mut w = SeqWriter::new(Self::SHAPE);
if let Some(item) = &self.departure_time {
w.start(e, 0, 0)?;
e.event(0, SIMPLE_WIDTH)?; e.uint(u64::from(*item))?;
e.event(0, SIMPLE_WIDTH)?; w.finish(0, 1);
}
{
let item = &self.ev_target_energy_request;
w.start(e, 1, 0)?;
item.encode_body(e)?;
w.finish(1, 1);
}
{
let item = &self.ev_maximum_energy_request;
w.start(e, 2, 0)?;
item.encode_body(e)?;
w.finish(2, 1);
}
{
let item = &self.ev_minimum_energy_request;
w.start(e, 3, 0)?;
item.encode_body(e)?;
w.finish(3, 1);
}
{
let item = &self.ev_maximum_charge_power;
w.start(e, 4, 0)?;
item.encode_body(e)?;
w.finish(4, 1);
}
if let Some(item) = &self.ev_maximum_charge_power_l2 {
w.start(e, 5, 0)?;
item.encode_body(e)?;
w.finish(5, 1);
}
if let Some(item) = &self.ev_maximum_charge_power_l3 {
w.start(e, 6, 0)?;
item.encode_body(e)?;
w.finish(6, 1);
}
{
let item = &self.ev_minimum_charge_power;
w.start(e, 7, 0)?;
item.encode_body(e)?;
w.finish(7, 1);
}
if let Some(item) = &self.ev_minimum_charge_power_l2 {
w.start(e, 8, 0)?;
item.encode_body(e)?;
w.finish(8, 1);
}
if let Some(item) = &self.ev_minimum_charge_power_l3 {
w.start(e, 9, 0)?;
item.encode_body(e)?;
w.finish(9, 1);
}
{
let item = &self.ev_present_active_power;
w.start(e, 10, 0)?;
item.encode_body(e)?;
w.finish(10, 1);
}
if let Some(item) = &self.ev_present_active_power_l2 {
w.start(e, 11, 0)?;
item.encode_body(e)?;
w.finish(11, 1);
}
if let Some(item) = &self.ev_present_active_power_l3 {
w.start(e, 12, 0)?;
item.encode_body(e)?;
w.finish(12, 1);
}
{
let item = &self.ev_present_reactive_power;
w.start(e, 13, 0)?;
item.encode_body(e)?;
w.finish(13, 1);
}
if let Some(item) = &self.ev_present_reactive_power_l2 {
w.start(e, 14, 0)?;
item.encode_body(e)?;
w.finish(14, 1);
}
if let Some(item) = &self.ev_present_reactive_power_l3 {
w.start(e, 15, 0)?;
item.encode_body(e)?;
w.finish(15, 1);
}
{
let item = &self.ev_maximum_discharge_power;
w.start(e, 16, 0)?;
item.encode_body(e)?;
w.finish(16, 1);
}
if let Some(item) = &self.ev_maximum_discharge_power_l2 {
w.start(e, 17, 0)?;
item.encode_body(e)?;
w.finish(17, 1);
}
if let Some(item) = &self.ev_maximum_discharge_power_l3 {
w.start(e, 18, 0)?;
item.encode_body(e)?;
w.finish(18, 1);
}
{
let item = &self.ev_minimum_discharge_power;
w.start(e, 19, 0)?;
item.encode_body(e)?;
w.finish(19, 1);
}
if let Some(item) = &self.ev_minimum_discharge_power_l2 {
w.start(e, 20, 0)?;
item.encode_body(e)?;
w.finish(20, 1);
}
if let Some(item) = &self.ev_minimum_discharge_power_l3 {
w.start(e, 21, 0)?;
item.encode_body(e)?;
w.finish(21, 1);
}
if let Some(item) = &self.ev_maximum_v2_x_energy_request {
w.start(e, 22, 0)?;
item.encode_body(e)?;
w.finish(22, 1);
}
if let Some(item) = &self.ev_minimum_v2_x_energy_request {
w.start(e, 23, 0)?;
item.encode_body(e)?;
w.finish(23, 1);
}
w.end(e)?;
e.leave();
Ok(())
}
}
impl BPTDynamicACCLReqControlMode {
pub fn decode_body(d: &mut Decoder<'_>) -> ExiResult<Self> {
d.enter()?;
let mut r = SeqReader::new(Self::SHAPE);
let mut f_0 = None;
let mut f_1 = None;
let mut f_2 = None;
let mut f_3 = None;
let mut f_4 = None;
let mut f_5 = None;
let mut f_6 = None;
let mut f_7 = None;
let mut f_8 = None;
let mut f_9 = None;
let mut f_10 = None;
let mut f_11 = None;
let mut f_12 = None;
let mut f_13 = None;
let mut f_14 = None;
let mut f_15 = None;
let mut f_16 = None;
let mut f_17 = None;
let mut f_18 = None;
let mut f_19 = None;
let mut f_20 = None;
let mut f_21 = None;
let mut f_22 = None;
let mut f_23 = None;
loop {
match r.next(d)? {
Step::End => break,
Step::Item { index: 0, .. } => {
d.expect_event(0, SIMPLE_WIDTH)?; let value = u32::try_from(d.uint()?).map_err(|_| ExiError::IntegerOverflow)?;
d.expect_event(0, SIMPLE_WIDTH)?; f_0 = Some(value);
}
Step::Item { index: 1, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_1 = Some(value);
}
Step::Item { index: 2, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_2 = Some(value);
}
Step::Item { index: 3, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_3 = Some(value);
}
Step::Item { index: 4, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_4 = Some(value);
}
Step::Item { index: 5, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_5 = Some(value);
}
Step::Item { index: 6, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_6 = Some(value);
}
Step::Item { index: 7, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_7 = Some(value);
}
Step::Item { index: 8, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_8 = Some(value);
}
Step::Item { index: 9, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_9 = Some(value);
}
Step::Item { index: 10, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_10 = Some(value);
}
Step::Item { index: 11, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_11 = Some(value);
}
Step::Item { index: 12, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_12 = Some(value);
}
Step::Item { index: 13, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_13 = Some(value);
}
Step::Item { index: 14, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_14 = Some(value);
}
Step::Item { index: 15, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_15 = Some(value);
}
Step::Item { index: 16, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_16 = Some(value);
}
Step::Item { index: 17, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_17 = Some(value);
}
Step::Item { index: 18, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_18 = Some(value);
}
Step::Item { index: 19, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_19 = Some(value);
}
Step::Item { index: 20, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_20 = Some(value);
}
Step::Item { index: 21, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_21 = Some(value);
}
Step::Item { index: 22, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_22 = Some(value);
}
Step::Item { index: 23, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_23 = Some(value);
}
Step::Item { .. } => return Err(ExiError::UnknownEventCode),
}
}
d.leave();
Ok(Self {
departure_time: f_0,
ev_target_energy_request: f_1.ok_or(ExiError::MissingElement)?,
ev_maximum_energy_request: f_2.ok_or(ExiError::MissingElement)?,
ev_minimum_energy_request: f_3.ok_or(ExiError::MissingElement)?,
ev_maximum_charge_power: f_4.ok_or(ExiError::MissingElement)?,
ev_maximum_charge_power_l2: f_5,
ev_maximum_charge_power_l3: f_6,
ev_minimum_charge_power: f_7.ok_or(ExiError::MissingElement)?,
ev_minimum_charge_power_l2: f_8,
ev_minimum_charge_power_l3: f_9,
ev_present_active_power: f_10.ok_or(ExiError::MissingElement)?,
ev_present_active_power_l2: f_11,
ev_present_active_power_l3: f_12,
ev_present_reactive_power: f_13.ok_or(ExiError::MissingElement)?,
ev_present_reactive_power_l2: f_14,
ev_present_reactive_power_l3: f_15,
ev_maximum_discharge_power: f_16.ok_or(ExiError::MissingElement)?,
ev_maximum_discharge_power_l2: f_17,
ev_maximum_discharge_power_l3: f_18,
ev_minimum_discharge_power: f_19.ok_or(ExiError::MissingElement)?,
ev_minimum_discharge_power_l2: f_20,
ev_minimum_discharge_power_l3: f_21,
ev_maximum_v2_x_energy_request: f_22,
ev_minimum_v2_x_energy_request: f_23,
})
}
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct BPTDynamicACCLResControlMode {
pub departure_time: Option<u32>,
pub minimum_soc: Option<u8>,
pub target_soc: Option<u8>,
pub ack_max_delay: Option<u16>,
pub evse_target_active_power: super::common::RationalNumber,
pub evse_target_active_power_l2: Option<super::common::RationalNumber>,
pub evse_target_active_power_l3: Option<super::common::RationalNumber>,
pub evse_target_reactive_power: Option<super::common::RationalNumber>,
pub evse_target_reactive_power_l2: Option<super::common::RationalNumber>,
pub evse_target_reactive_power_l3: Option<super::common::RationalNumber>,
pub evse_present_active_power: Option<super::common::RationalNumber>,
pub evse_present_active_power_l2: Option<super::common::RationalNumber>,
pub evse_present_active_power_l3: Option<super::common::RationalNumber>,
}
impl BPTDynamicACCLResControlMode {
const SHAPE: Shape = Shape {
prod_before: &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],
width: &[3, 3, 2, 2, 1, 4, 4, 3, 3, 3, 3, 2, 2, 1],
repeat_width: &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
min: &[0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0],
max: &[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
};
}
impl BPTDynamicACCLResControlMode {
pub fn encode_body(&self, e: &mut Encoder<'_>) -> ExiResult<()> {
e.enter()?;
let mut w = SeqWriter::new(Self::SHAPE);
if let Some(item) = &self.departure_time {
w.start(e, 0, 0)?;
e.event(0, SIMPLE_WIDTH)?; e.uint(u64::from(*item))?;
e.event(0, SIMPLE_WIDTH)?; w.finish(0, 1);
}
if let Some(item) = &self.minimum_soc {
w.start(e, 1, 0)?;
e.event(0, SIMPLE_WIDTH)?; e.restricted(i64::from(*item), 0, 100)?;
e.event(0, SIMPLE_WIDTH)?; w.finish(1, 1);
}
if let Some(item) = &self.target_soc {
w.start(e, 2, 0)?;
e.event(0, SIMPLE_WIDTH)?; e.restricted(i64::from(*item), 0, 100)?;
e.event(0, SIMPLE_WIDTH)?; w.finish(2, 1);
}
if let Some(item) = &self.ack_max_delay {
w.start(e, 3, 0)?;
e.event(0, SIMPLE_WIDTH)?; e.uint(u64::from(*item))?;
e.event(0, SIMPLE_WIDTH)?; w.finish(3, 1);
}
{
let item = &self.evse_target_active_power;
w.start(e, 4, 0)?;
item.encode_body(e)?;
w.finish(4, 1);
}
if let Some(item) = &self.evse_target_active_power_l2 {
w.start(e, 5, 0)?;
item.encode_body(e)?;
w.finish(5, 1);
}
if let Some(item) = &self.evse_target_active_power_l3 {
w.start(e, 6, 0)?;
item.encode_body(e)?;
w.finish(6, 1);
}
if let Some(item) = &self.evse_target_reactive_power {
w.start(e, 7, 0)?;
item.encode_body(e)?;
w.finish(7, 1);
}
if let Some(item) = &self.evse_target_reactive_power_l2 {
w.start(e, 8, 0)?;
item.encode_body(e)?;
w.finish(8, 1);
}
if let Some(item) = &self.evse_target_reactive_power_l3 {
w.start(e, 9, 0)?;
item.encode_body(e)?;
w.finish(9, 1);
}
if let Some(item) = &self.evse_present_active_power {
w.start(e, 10, 0)?;
item.encode_body(e)?;
w.finish(10, 1);
}
if let Some(item) = &self.evse_present_active_power_l2 {
w.start(e, 11, 0)?;
item.encode_body(e)?;
w.finish(11, 1);
}
if let Some(item) = &self.evse_present_active_power_l3 {
w.start(e, 12, 0)?;
item.encode_body(e)?;
w.finish(12, 1);
}
w.end(e)?;
e.leave();
Ok(())
}
}
impl BPTDynamicACCLResControlMode {
pub fn decode_body(d: &mut Decoder<'_>) -> ExiResult<Self> {
d.enter()?;
let mut r = SeqReader::new(Self::SHAPE);
let mut f_0 = None;
let mut f_1 = None;
let mut f_2 = None;
let mut f_3 = None;
let mut f_4 = None;
let mut f_5 = None;
let mut f_6 = None;
let mut f_7 = None;
let mut f_8 = None;
let mut f_9 = None;
let mut f_10 = None;
let mut f_11 = None;
let mut f_12 = None;
loop {
match r.next(d)? {
Step::End => break,
Step::Item { index: 0, .. } => {
d.expect_event(0, SIMPLE_WIDTH)?; let value = u32::try_from(d.uint()?).map_err(|_| ExiError::IntegerOverflow)?;
d.expect_event(0, SIMPLE_WIDTH)?; f_0 = Some(value);
}
Step::Item { index: 1, .. } => {
d.expect_event(0, SIMPLE_WIDTH)?; let value = u8::try_from(d.restricted(0, 100)?)
.map_err(|_| ExiError::ValueOutOfRange)?;
d.expect_event(0, SIMPLE_WIDTH)?; f_1 = Some(value);
}
Step::Item { index: 2, .. } => {
d.expect_event(0, SIMPLE_WIDTH)?; let value = u8::try_from(d.restricted(0, 100)?)
.map_err(|_| ExiError::ValueOutOfRange)?;
d.expect_event(0, SIMPLE_WIDTH)?; f_2 = Some(value);
}
Step::Item { index: 3, .. } => {
d.expect_event(0, SIMPLE_WIDTH)?; let value = u16::try_from(d.uint()?).map_err(|_| ExiError::IntegerOverflow)?;
d.expect_event(0, SIMPLE_WIDTH)?; f_3 = Some(value);
}
Step::Item { index: 4, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_4 = Some(value);
}
Step::Item { index: 5, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_5 = Some(value);
}
Step::Item { index: 6, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_6 = Some(value);
}
Step::Item { index: 7, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_7 = Some(value);
}
Step::Item { index: 8, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_8 = Some(value);
}
Step::Item { index: 9, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_9 = Some(value);
}
Step::Item { index: 10, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_10 = Some(value);
}
Step::Item { index: 11, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_11 = Some(value);
}
Step::Item { index: 12, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_12 = Some(value);
}
Step::Item { .. } => return Err(ExiError::UnknownEventCode),
}
}
d.leave();
Ok(Self {
departure_time: f_0,
minimum_soc: f_1,
target_soc: f_2,
ack_max_delay: f_3,
evse_target_active_power: f_4.ok_or(ExiError::MissingElement)?,
evse_target_active_power_l2: f_5,
evse_target_active_power_l3: f_6,
evse_target_reactive_power: f_7,
evse_target_reactive_power_l2: f_8,
evse_target_reactive_power_l3: f_9,
evse_present_active_power: f_10,
evse_present_active_power_l2: f_11,
evse_present_active_power_l3: f_12,
})
}
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct BPTScheduledACCLReqControlMode {
pub ev_target_energy_request: Option<super::common::RationalNumber>,
pub ev_maximum_energy_request: Option<super::common::RationalNumber>,
pub ev_minimum_energy_request: Option<super::common::RationalNumber>,
pub ev_maximum_charge_power: Option<super::common::RationalNumber>,
pub ev_maximum_charge_power_l2: Option<super::common::RationalNumber>,
pub ev_maximum_charge_power_l3: Option<super::common::RationalNumber>,
pub ev_minimum_charge_power: Option<super::common::RationalNumber>,
pub ev_minimum_charge_power_l2: Option<super::common::RationalNumber>,
pub ev_minimum_charge_power_l3: Option<super::common::RationalNumber>,
pub ev_present_active_power: super::common::RationalNumber,
pub ev_present_active_power_l2: Option<super::common::RationalNumber>,
pub ev_present_active_power_l3: Option<super::common::RationalNumber>,
pub ev_present_reactive_power: Option<super::common::RationalNumber>,
pub ev_present_reactive_power_l2: Option<super::common::RationalNumber>,
pub ev_present_reactive_power_l3: Option<super::common::RationalNumber>,
pub ev_maximum_discharge_power: Option<super::common::RationalNumber>,
pub ev_maximum_discharge_power_l2: Option<super::common::RationalNumber>,
pub ev_maximum_discharge_power_l3: Option<super::common::RationalNumber>,
pub ev_minimum_discharge_power: Option<super::common::RationalNumber>,
pub ev_minimum_discharge_power_l2: Option<super::common::RationalNumber>,
pub ev_minimum_discharge_power_l3: Option<super::common::RationalNumber>,
}
impl BPTScheduledACCLReqControlMode {
const SHAPE: Shape = Shape {
prod_before: &[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
],
width: &[4, 4, 4, 3, 3, 3, 3, 2, 2, 1, 4, 4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 1],
repeat_width: &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
min: &[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
max: &[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
};
}
impl BPTScheduledACCLReqControlMode {
pub fn encode_body(&self, e: &mut Encoder<'_>) -> ExiResult<()> {
e.enter()?;
let mut w = SeqWriter::new(Self::SHAPE);
if let Some(item) = &self.ev_target_energy_request {
w.start(e, 0, 0)?;
item.encode_body(e)?;
w.finish(0, 1);
}
if let Some(item) = &self.ev_maximum_energy_request {
w.start(e, 1, 0)?;
item.encode_body(e)?;
w.finish(1, 1);
}
if let Some(item) = &self.ev_minimum_energy_request {
w.start(e, 2, 0)?;
item.encode_body(e)?;
w.finish(2, 1);
}
if let Some(item) = &self.ev_maximum_charge_power {
w.start(e, 3, 0)?;
item.encode_body(e)?;
w.finish(3, 1);
}
if let Some(item) = &self.ev_maximum_charge_power_l2 {
w.start(e, 4, 0)?;
item.encode_body(e)?;
w.finish(4, 1);
}
if let Some(item) = &self.ev_maximum_charge_power_l3 {
w.start(e, 5, 0)?;
item.encode_body(e)?;
w.finish(5, 1);
}
if let Some(item) = &self.ev_minimum_charge_power {
w.start(e, 6, 0)?;
item.encode_body(e)?;
w.finish(6, 1);
}
if let Some(item) = &self.ev_minimum_charge_power_l2 {
w.start(e, 7, 0)?;
item.encode_body(e)?;
w.finish(7, 1);
}
if let Some(item) = &self.ev_minimum_charge_power_l3 {
w.start(e, 8, 0)?;
item.encode_body(e)?;
w.finish(8, 1);
}
{
let item = &self.ev_present_active_power;
w.start(e, 9, 0)?;
item.encode_body(e)?;
w.finish(9, 1);
}
if let Some(item) = &self.ev_present_active_power_l2 {
w.start(e, 10, 0)?;
item.encode_body(e)?;
w.finish(10, 1);
}
if let Some(item) = &self.ev_present_active_power_l3 {
w.start(e, 11, 0)?;
item.encode_body(e)?;
w.finish(11, 1);
}
if let Some(item) = &self.ev_present_reactive_power {
w.start(e, 12, 0)?;
item.encode_body(e)?;
w.finish(12, 1);
}
if let Some(item) = &self.ev_present_reactive_power_l2 {
w.start(e, 13, 0)?;
item.encode_body(e)?;
w.finish(13, 1);
}
if let Some(item) = &self.ev_present_reactive_power_l3 {
w.start(e, 14, 0)?;
item.encode_body(e)?;
w.finish(14, 1);
}
if let Some(item) = &self.ev_maximum_discharge_power {
w.start(e, 15, 0)?;
item.encode_body(e)?;
w.finish(15, 1);
}
if let Some(item) = &self.ev_maximum_discharge_power_l2 {
w.start(e, 16, 0)?;
item.encode_body(e)?;
w.finish(16, 1);
}
if let Some(item) = &self.ev_maximum_discharge_power_l3 {
w.start(e, 17, 0)?;
item.encode_body(e)?;
w.finish(17, 1);
}
if let Some(item) = &self.ev_minimum_discharge_power {
w.start(e, 18, 0)?;
item.encode_body(e)?;
w.finish(18, 1);
}
if let Some(item) = &self.ev_minimum_discharge_power_l2 {
w.start(e, 19, 0)?;
item.encode_body(e)?;
w.finish(19, 1);
}
if let Some(item) = &self.ev_minimum_discharge_power_l3 {
w.start(e, 20, 0)?;
item.encode_body(e)?;
w.finish(20, 1);
}
w.end(e)?;
e.leave();
Ok(())
}
}
impl BPTScheduledACCLReqControlMode {
pub fn decode_body(d: &mut Decoder<'_>) -> ExiResult<Self> {
d.enter()?;
let mut r = SeqReader::new(Self::SHAPE);
let mut f_0 = None;
let mut f_1 = None;
let mut f_2 = None;
let mut f_3 = None;
let mut f_4 = None;
let mut f_5 = None;
let mut f_6 = None;
let mut f_7 = None;
let mut f_8 = None;
let mut f_9 = None;
let mut f_10 = None;
let mut f_11 = None;
let mut f_12 = None;
let mut f_13 = None;
let mut f_14 = None;
let mut f_15 = None;
let mut f_16 = None;
let mut f_17 = None;
let mut f_18 = None;
let mut f_19 = None;
let mut f_20 = None;
loop {
match r.next(d)? {
Step::End => break,
Step::Item { index: 0, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_0 = Some(value);
}
Step::Item { index: 1, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_1 = Some(value);
}
Step::Item { index: 2, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_2 = Some(value);
}
Step::Item { index: 3, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_3 = Some(value);
}
Step::Item { index: 4, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_4 = Some(value);
}
Step::Item { index: 5, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_5 = Some(value);
}
Step::Item { index: 6, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_6 = Some(value);
}
Step::Item { index: 7, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_7 = Some(value);
}
Step::Item { index: 8, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_8 = Some(value);
}
Step::Item { index: 9, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_9 = Some(value);
}
Step::Item { index: 10, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_10 = Some(value);
}
Step::Item { index: 11, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_11 = Some(value);
}
Step::Item { index: 12, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_12 = Some(value);
}
Step::Item { index: 13, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_13 = Some(value);
}
Step::Item { index: 14, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_14 = Some(value);
}
Step::Item { index: 15, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_15 = Some(value);
}
Step::Item { index: 16, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_16 = Some(value);
}
Step::Item { index: 17, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_17 = Some(value);
}
Step::Item { index: 18, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_18 = Some(value);
}
Step::Item { index: 19, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_19 = Some(value);
}
Step::Item { index: 20, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_20 = Some(value);
}
Step::Item { .. } => return Err(ExiError::UnknownEventCode),
}
}
d.leave();
Ok(Self {
ev_target_energy_request: f_0,
ev_maximum_energy_request: f_1,
ev_minimum_energy_request: f_2,
ev_maximum_charge_power: f_3,
ev_maximum_charge_power_l2: f_4,
ev_maximum_charge_power_l3: f_5,
ev_minimum_charge_power: f_6,
ev_minimum_charge_power_l2: f_7,
ev_minimum_charge_power_l3: f_8,
ev_present_active_power: f_9.ok_or(ExiError::MissingElement)?,
ev_present_active_power_l2: f_10,
ev_present_active_power_l3: f_11,
ev_present_reactive_power: f_12,
ev_present_reactive_power_l2: f_13,
ev_present_reactive_power_l3: f_14,
ev_maximum_discharge_power: f_15,
ev_maximum_discharge_power_l2: f_16,
ev_maximum_discharge_power_l3: f_17,
ev_minimum_discharge_power: f_18,
ev_minimum_discharge_power_l2: f_19,
ev_minimum_discharge_power_l3: f_20,
})
}
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct BPTScheduledACCLResControlMode {
pub evse_target_active_power: Option<super::common::RationalNumber>,
pub evse_target_active_power_l2: Option<super::common::RationalNumber>,
pub evse_target_active_power_l3: Option<super::common::RationalNumber>,
pub evse_target_reactive_power: Option<super::common::RationalNumber>,
pub evse_target_reactive_power_l2: Option<super::common::RationalNumber>,
pub evse_target_reactive_power_l3: Option<super::common::RationalNumber>,
pub evse_present_active_power: Option<super::common::RationalNumber>,
pub evse_present_active_power_l2: Option<super::common::RationalNumber>,
pub evse_present_active_power_l3: Option<super::common::RationalNumber>,
}
impl BPTScheduledACCLResControlMode {
const SHAPE: Shape = Shape {
prod_before: &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
width: &[4, 4, 4, 3, 3, 3, 3, 2, 2, 1],
repeat_width: &[0, 0, 0, 0, 0, 0, 0, 0, 0],
min: &[0, 0, 0, 0, 0, 0, 0, 0, 0],
max: &[1, 1, 1, 1, 1, 1, 1, 1, 1],
};
}
impl BPTScheduledACCLResControlMode {
pub fn encode_body(&self, e: &mut Encoder<'_>) -> ExiResult<()> {
e.enter()?;
let mut w = SeqWriter::new(Self::SHAPE);
if let Some(item) = &self.evse_target_active_power {
w.start(e, 0, 0)?;
item.encode_body(e)?;
w.finish(0, 1);
}
if let Some(item) = &self.evse_target_active_power_l2 {
w.start(e, 1, 0)?;
item.encode_body(e)?;
w.finish(1, 1);
}
if let Some(item) = &self.evse_target_active_power_l3 {
w.start(e, 2, 0)?;
item.encode_body(e)?;
w.finish(2, 1);
}
if let Some(item) = &self.evse_target_reactive_power {
w.start(e, 3, 0)?;
item.encode_body(e)?;
w.finish(3, 1);
}
if let Some(item) = &self.evse_target_reactive_power_l2 {
w.start(e, 4, 0)?;
item.encode_body(e)?;
w.finish(4, 1);
}
if let Some(item) = &self.evse_target_reactive_power_l3 {
w.start(e, 5, 0)?;
item.encode_body(e)?;
w.finish(5, 1);
}
if let Some(item) = &self.evse_present_active_power {
w.start(e, 6, 0)?;
item.encode_body(e)?;
w.finish(6, 1);
}
if let Some(item) = &self.evse_present_active_power_l2 {
w.start(e, 7, 0)?;
item.encode_body(e)?;
w.finish(7, 1);
}
if let Some(item) = &self.evse_present_active_power_l3 {
w.start(e, 8, 0)?;
item.encode_body(e)?;
w.finish(8, 1);
}
w.end(e)?;
e.leave();
Ok(())
}
}
impl BPTScheduledACCLResControlMode {
pub fn decode_body(d: &mut Decoder<'_>) -> ExiResult<Self> {
d.enter()?;
let mut r = SeqReader::new(Self::SHAPE);
let mut f_0 = None;
let mut f_1 = None;
let mut f_2 = None;
let mut f_3 = None;
let mut f_4 = None;
let mut f_5 = None;
let mut f_6 = None;
let mut f_7 = None;
let mut f_8 = None;
loop {
match r.next(d)? {
Step::End => break,
Step::Item { index: 0, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_0 = Some(value);
}
Step::Item { index: 1, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_1 = Some(value);
}
Step::Item { index: 2, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_2 = Some(value);
}
Step::Item { index: 3, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_3 = Some(value);
}
Step::Item { index: 4, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_4 = Some(value);
}
Step::Item { index: 5, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_5 = Some(value);
}
Step::Item { index: 6, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_6 = Some(value);
}
Step::Item { index: 7, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_7 = Some(value);
}
Step::Item { index: 8, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_8 = Some(value);
}
Step::Item { .. } => return Err(ExiError::UnknownEventCode),
}
}
d.leave();
Ok(Self {
evse_target_active_power: f_0,
evse_target_active_power_l2: f_1,
evse_target_active_power_l3: f_2,
evse_target_reactive_power: f_3,
evse_target_reactive_power_l2: f_4,
evse_target_reactive_power_l3: f_5,
evse_present_active_power: f_6,
evse_present_active_power_l2: f_7,
evse_present_active_power_l3: f_8,
})
}
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct DynamicACCLReqControlMode {
pub departure_time: Option<u32>,
pub ev_target_energy_request: super::common::RationalNumber,
pub ev_maximum_energy_request: super::common::RationalNumber,
pub ev_minimum_energy_request: super::common::RationalNumber,
pub ev_maximum_charge_power: super::common::RationalNumber,
pub ev_maximum_charge_power_l2: Option<super::common::RationalNumber>,
pub ev_maximum_charge_power_l3: Option<super::common::RationalNumber>,
pub ev_minimum_charge_power: super::common::RationalNumber,
pub ev_minimum_charge_power_l2: Option<super::common::RationalNumber>,
pub ev_minimum_charge_power_l3: Option<super::common::RationalNumber>,
pub ev_present_active_power: super::common::RationalNumber,
pub ev_present_active_power_l2: Option<super::common::RationalNumber>,
pub ev_present_active_power_l3: Option<super::common::RationalNumber>,
pub ev_present_reactive_power: super::common::RationalNumber,
pub ev_present_reactive_power_l2: Option<super::common::RationalNumber>,
pub ev_present_reactive_power_l3: Option<super::common::RationalNumber>,
}
impl DynamicACCLReqControlMode {
const SHAPE: Shape = Shape {
prod_before: &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],
width: &[2, 1, 1, 1, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1],
repeat_width: &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
min: &[0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0],
max: &[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
};
}
impl DynamicACCLReqControlMode {
pub fn encode_body(&self, e: &mut Encoder<'_>) -> ExiResult<()> {
e.enter()?;
let mut w = SeqWriter::new(Self::SHAPE);
if let Some(item) = &self.departure_time {
w.start(e, 0, 0)?;
e.event(0, SIMPLE_WIDTH)?; e.uint(u64::from(*item))?;
e.event(0, SIMPLE_WIDTH)?; w.finish(0, 1);
}
{
let item = &self.ev_target_energy_request;
w.start(e, 1, 0)?;
item.encode_body(e)?;
w.finish(1, 1);
}
{
let item = &self.ev_maximum_energy_request;
w.start(e, 2, 0)?;
item.encode_body(e)?;
w.finish(2, 1);
}
{
let item = &self.ev_minimum_energy_request;
w.start(e, 3, 0)?;
item.encode_body(e)?;
w.finish(3, 1);
}
{
let item = &self.ev_maximum_charge_power;
w.start(e, 4, 0)?;
item.encode_body(e)?;
w.finish(4, 1);
}
if let Some(item) = &self.ev_maximum_charge_power_l2 {
w.start(e, 5, 0)?;
item.encode_body(e)?;
w.finish(5, 1);
}
if let Some(item) = &self.ev_maximum_charge_power_l3 {
w.start(e, 6, 0)?;
item.encode_body(e)?;
w.finish(6, 1);
}
{
let item = &self.ev_minimum_charge_power;
w.start(e, 7, 0)?;
item.encode_body(e)?;
w.finish(7, 1);
}
if let Some(item) = &self.ev_minimum_charge_power_l2 {
w.start(e, 8, 0)?;
item.encode_body(e)?;
w.finish(8, 1);
}
if let Some(item) = &self.ev_minimum_charge_power_l3 {
w.start(e, 9, 0)?;
item.encode_body(e)?;
w.finish(9, 1);
}
{
let item = &self.ev_present_active_power;
w.start(e, 10, 0)?;
item.encode_body(e)?;
w.finish(10, 1);
}
if let Some(item) = &self.ev_present_active_power_l2 {
w.start(e, 11, 0)?;
item.encode_body(e)?;
w.finish(11, 1);
}
if let Some(item) = &self.ev_present_active_power_l3 {
w.start(e, 12, 0)?;
item.encode_body(e)?;
w.finish(12, 1);
}
{
let item = &self.ev_present_reactive_power;
w.start(e, 13, 0)?;
item.encode_body(e)?;
w.finish(13, 1);
}
if let Some(item) = &self.ev_present_reactive_power_l2 {
w.start(e, 14, 0)?;
item.encode_body(e)?;
w.finish(14, 1);
}
if let Some(item) = &self.ev_present_reactive_power_l3 {
w.start(e, 15, 0)?;
item.encode_body(e)?;
w.finish(15, 1);
}
w.end(e)?;
e.leave();
Ok(())
}
}
impl DynamicACCLReqControlMode {
pub fn decode_body(d: &mut Decoder<'_>) -> ExiResult<Self> {
d.enter()?;
let mut r = SeqReader::new(Self::SHAPE);
let mut f_0 = None;
let mut f_1 = None;
let mut f_2 = None;
let mut f_3 = None;
let mut f_4 = None;
let mut f_5 = None;
let mut f_6 = None;
let mut f_7 = None;
let mut f_8 = None;
let mut f_9 = None;
let mut f_10 = None;
let mut f_11 = None;
let mut f_12 = None;
let mut f_13 = None;
let mut f_14 = None;
let mut f_15 = None;
loop {
match r.next(d)? {
Step::End => break,
Step::Item { index: 0, .. } => {
d.expect_event(0, SIMPLE_WIDTH)?; let value = u32::try_from(d.uint()?).map_err(|_| ExiError::IntegerOverflow)?;
d.expect_event(0, SIMPLE_WIDTH)?; f_0 = Some(value);
}
Step::Item { index: 1, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_1 = Some(value);
}
Step::Item { index: 2, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_2 = Some(value);
}
Step::Item { index: 3, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_3 = Some(value);
}
Step::Item { index: 4, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_4 = Some(value);
}
Step::Item { index: 5, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_5 = Some(value);
}
Step::Item { index: 6, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_6 = Some(value);
}
Step::Item { index: 7, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_7 = Some(value);
}
Step::Item { index: 8, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_8 = Some(value);
}
Step::Item { index: 9, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_9 = Some(value);
}
Step::Item { index: 10, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_10 = Some(value);
}
Step::Item { index: 11, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_11 = Some(value);
}
Step::Item { index: 12, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_12 = Some(value);
}
Step::Item { index: 13, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_13 = Some(value);
}
Step::Item { index: 14, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_14 = Some(value);
}
Step::Item { index: 15, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_15 = Some(value);
}
Step::Item { .. } => return Err(ExiError::UnknownEventCode),
}
}
d.leave();
Ok(Self {
departure_time: f_0,
ev_target_energy_request: f_1.ok_or(ExiError::MissingElement)?,
ev_maximum_energy_request: f_2.ok_or(ExiError::MissingElement)?,
ev_minimum_energy_request: f_3.ok_or(ExiError::MissingElement)?,
ev_maximum_charge_power: f_4.ok_or(ExiError::MissingElement)?,
ev_maximum_charge_power_l2: f_5,
ev_maximum_charge_power_l3: f_6,
ev_minimum_charge_power: f_7.ok_or(ExiError::MissingElement)?,
ev_minimum_charge_power_l2: f_8,
ev_minimum_charge_power_l3: f_9,
ev_present_active_power: f_10.ok_or(ExiError::MissingElement)?,
ev_present_active_power_l2: f_11,
ev_present_active_power_l3: f_12,
ev_present_reactive_power: f_13.ok_or(ExiError::MissingElement)?,
ev_present_reactive_power_l2: f_14,
ev_present_reactive_power_l3: f_15,
})
}
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct DynamicACCLResControlMode {
pub departure_time: Option<u32>,
pub minimum_soc: Option<u8>,
pub target_soc: Option<u8>,
pub ack_max_delay: Option<u16>,
pub evse_target_active_power: super::common::RationalNumber,
pub evse_target_active_power_l2: Option<super::common::RationalNumber>,
pub evse_target_active_power_l3: Option<super::common::RationalNumber>,
pub evse_target_reactive_power: Option<super::common::RationalNumber>,
pub evse_target_reactive_power_l2: Option<super::common::RationalNumber>,
pub evse_target_reactive_power_l3: Option<super::common::RationalNumber>,
pub evse_present_active_power: Option<super::common::RationalNumber>,
pub evse_present_active_power_l2: Option<super::common::RationalNumber>,
pub evse_present_active_power_l3: Option<super::common::RationalNumber>,
}
impl DynamicACCLResControlMode {
const SHAPE: Shape = Shape {
prod_before: &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],
width: &[3, 3, 2, 2, 1, 4, 4, 3, 3, 3, 3, 2, 2, 1],
repeat_width: &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
min: &[0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0],
max: &[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
};
}
impl DynamicACCLResControlMode {
pub fn encode_body(&self, e: &mut Encoder<'_>) -> ExiResult<()> {
e.enter()?;
let mut w = SeqWriter::new(Self::SHAPE);
if let Some(item) = &self.departure_time {
w.start(e, 0, 0)?;
e.event(0, SIMPLE_WIDTH)?; e.uint(u64::from(*item))?;
e.event(0, SIMPLE_WIDTH)?; w.finish(0, 1);
}
if let Some(item) = &self.minimum_soc {
w.start(e, 1, 0)?;
e.event(0, SIMPLE_WIDTH)?; e.restricted(i64::from(*item), 0, 100)?;
e.event(0, SIMPLE_WIDTH)?; w.finish(1, 1);
}
if let Some(item) = &self.target_soc {
w.start(e, 2, 0)?;
e.event(0, SIMPLE_WIDTH)?; e.restricted(i64::from(*item), 0, 100)?;
e.event(0, SIMPLE_WIDTH)?; w.finish(2, 1);
}
if let Some(item) = &self.ack_max_delay {
w.start(e, 3, 0)?;
e.event(0, SIMPLE_WIDTH)?; e.uint(u64::from(*item))?;
e.event(0, SIMPLE_WIDTH)?; w.finish(3, 1);
}
{
let item = &self.evse_target_active_power;
w.start(e, 4, 0)?;
item.encode_body(e)?;
w.finish(4, 1);
}
if let Some(item) = &self.evse_target_active_power_l2 {
w.start(e, 5, 0)?;
item.encode_body(e)?;
w.finish(5, 1);
}
if let Some(item) = &self.evse_target_active_power_l3 {
w.start(e, 6, 0)?;
item.encode_body(e)?;
w.finish(6, 1);
}
if let Some(item) = &self.evse_target_reactive_power {
w.start(e, 7, 0)?;
item.encode_body(e)?;
w.finish(7, 1);
}
if let Some(item) = &self.evse_target_reactive_power_l2 {
w.start(e, 8, 0)?;
item.encode_body(e)?;
w.finish(8, 1);
}
if let Some(item) = &self.evse_target_reactive_power_l3 {
w.start(e, 9, 0)?;
item.encode_body(e)?;
w.finish(9, 1);
}
if let Some(item) = &self.evse_present_active_power {
w.start(e, 10, 0)?;
item.encode_body(e)?;
w.finish(10, 1);
}
if let Some(item) = &self.evse_present_active_power_l2 {
w.start(e, 11, 0)?;
item.encode_body(e)?;
w.finish(11, 1);
}
if let Some(item) = &self.evse_present_active_power_l3 {
w.start(e, 12, 0)?;
item.encode_body(e)?;
w.finish(12, 1);
}
w.end(e)?;
e.leave();
Ok(())
}
}
impl DynamicACCLResControlMode {
pub fn decode_body(d: &mut Decoder<'_>) -> ExiResult<Self> {
d.enter()?;
let mut r = SeqReader::new(Self::SHAPE);
let mut f_0 = None;
let mut f_1 = None;
let mut f_2 = None;
let mut f_3 = None;
let mut f_4 = None;
let mut f_5 = None;
let mut f_6 = None;
let mut f_7 = None;
let mut f_8 = None;
let mut f_9 = None;
let mut f_10 = None;
let mut f_11 = None;
let mut f_12 = None;
loop {
match r.next(d)? {
Step::End => break,
Step::Item { index: 0, .. } => {
d.expect_event(0, SIMPLE_WIDTH)?; let value = u32::try_from(d.uint()?).map_err(|_| ExiError::IntegerOverflow)?;
d.expect_event(0, SIMPLE_WIDTH)?; f_0 = Some(value);
}
Step::Item { index: 1, .. } => {
d.expect_event(0, SIMPLE_WIDTH)?; let value = u8::try_from(d.restricted(0, 100)?)
.map_err(|_| ExiError::ValueOutOfRange)?;
d.expect_event(0, SIMPLE_WIDTH)?; f_1 = Some(value);
}
Step::Item { index: 2, .. } => {
d.expect_event(0, SIMPLE_WIDTH)?; let value = u8::try_from(d.restricted(0, 100)?)
.map_err(|_| ExiError::ValueOutOfRange)?;
d.expect_event(0, SIMPLE_WIDTH)?; f_2 = Some(value);
}
Step::Item { index: 3, .. } => {
d.expect_event(0, SIMPLE_WIDTH)?; let value = u16::try_from(d.uint()?).map_err(|_| ExiError::IntegerOverflow)?;
d.expect_event(0, SIMPLE_WIDTH)?; f_3 = Some(value);
}
Step::Item { index: 4, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_4 = Some(value);
}
Step::Item { index: 5, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_5 = Some(value);
}
Step::Item { index: 6, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_6 = Some(value);
}
Step::Item { index: 7, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_7 = Some(value);
}
Step::Item { index: 8, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_8 = Some(value);
}
Step::Item { index: 9, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_9 = Some(value);
}
Step::Item { index: 10, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_10 = Some(value);
}
Step::Item { index: 11, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_11 = Some(value);
}
Step::Item { index: 12, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_12 = Some(value);
}
Step::Item { .. } => return Err(ExiError::UnknownEventCode),
}
}
d.leave();
Ok(Self {
departure_time: f_0,
minimum_soc: f_1,
target_soc: f_2,
ack_max_delay: f_3,
evse_target_active_power: f_4.ok_or(ExiError::MissingElement)?,
evse_target_active_power_l2: f_5,
evse_target_active_power_l3: f_6,
evse_target_reactive_power: f_7,
evse_target_reactive_power_l2: f_8,
evse_target_reactive_power_l3: f_9,
evse_present_active_power: f_10,
evse_present_active_power_l2: f_11,
evse_present_active_power_l3: f_12,
})
}
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ScheduledACCLReqControlMode {
pub ev_target_energy_request: Option<super::common::RationalNumber>,
pub ev_maximum_energy_request: Option<super::common::RationalNumber>,
pub ev_minimum_energy_request: Option<super::common::RationalNumber>,
pub ev_maximum_charge_power: Option<super::common::RationalNumber>,
pub ev_maximum_charge_power_l2: Option<super::common::RationalNumber>,
pub ev_maximum_charge_power_l3: Option<super::common::RationalNumber>,
pub ev_minimum_charge_power: Option<super::common::RationalNumber>,
pub ev_minimum_charge_power_l2: Option<super::common::RationalNumber>,
pub ev_minimum_charge_power_l3: Option<super::common::RationalNumber>,
pub ev_present_active_power: super::common::RationalNumber,
pub ev_present_active_power_l2: Option<super::common::RationalNumber>,
pub ev_present_active_power_l3: Option<super::common::RationalNumber>,
pub ev_present_reactive_power: Option<super::common::RationalNumber>,
pub ev_present_reactive_power_l2: Option<super::common::RationalNumber>,
pub ev_present_reactive_power_l3: Option<super::common::RationalNumber>,
}
impl ScheduledACCLReqControlMode {
const SHAPE: Shape = Shape {
prod_before: &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
width: &[4, 4, 4, 3, 3, 3, 3, 2, 2, 1, 3, 3, 3, 2, 2, 1],
repeat_width: &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
min: &[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
max: &[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
};
}
impl ScheduledACCLReqControlMode {
pub fn encode_body(&self, e: &mut Encoder<'_>) -> ExiResult<()> {
e.enter()?;
let mut w = SeqWriter::new(Self::SHAPE);
if let Some(item) = &self.ev_target_energy_request {
w.start(e, 0, 0)?;
item.encode_body(e)?;
w.finish(0, 1);
}
if let Some(item) = &self.ev_maximum_energy_request {
w.start(e, 1, 0)?;
item.encode_body(e)?;
w.finish(1, 1);
}
if let Some(item) = &self.ev_minimum_energy_request {
w.start(e, 2, 0)?;
item.encode_body(e)?;
w.finish(2, 1);
}
if let Some(item) = &self.ev_maximum_charge_power {
w.start(e, 3, 0)?;
item.encode_body(e)?;
w.finish(3, 1);
}
if let Some(item) = &self.ev_maximum_charge_power_l2 {
w.start(e, 4, 0)?;
item.encode_body(e)?;
w.finish(4, 1);
}
if let Some(item) = &self.ev_maximum_charge_power_l3 {
w.start(e, 5, 0)?;
item.encode_body(e)?;
w.finish(5, 1);
}
if let Some(item) = &self.ev_minimum_charge_power {
w.start(e, 6, 0)?;
item.encode_body(e)?;
w.finish(6, 1);
}
if let Some(item) = &self.ev_minimum_charge_power_l2 {
w.start(e, 7, 0)?;
item.encode_body(e)?;
w.finish(7, 1);
}
if let Some(item) = &self.ev_minimum_charge_power_l3 {
w.start(e, 8, 0)?;
item.encode_body(e)?;
w.finish(8, 1);
}
{
let item = &self.ev_present_active_power;
w.start(e, 9, 0)?;
item.encode_body(e)?;
w.finish(9, 1);
}
if let Some(item) = &self.ev_present_active_power_l2 {
w.start(e, 10, 0)?;
item.encode_body(e)?;
w.finish(10, 1);
}
if let Some(item) = &self.ev_present_active_power_l3 {
w.start(e, 11, 0)?;
item.encode_body(e)?;
w.finish(11, 1);
}
if let Some(item) = &self.ev_present_reactive_power {
w.start(e, 12, 0)?;
item.encode_body(e)?;
w.finish(12, 1);
}
if let Some(item) = &self.ev_present_reactive_power_l2 {
w.start(e, 13, 0)?;
item.encode_body(e)?;
w.finish(13, 1);
}
if let Some(item) = &self.ev_present_reactive_power_l3 {
w.start(e, 14, 0)?;
item.encode_body(e)?;
w.finish(14, 1);
}
w.end(e)?;
e.leave();
Ok(())
}
}
impl ScheduledACCLReqControlMode {
pub fn decode_body(d: &mut Decoder<'_>) -> ExiResult<Self> {
d.enter()?;
let mut r = SeqReader::new(Self::SHAPE);
let mut f_0 = None;
let mut f_1 = None;
let mut f_2 = None;
let mut f_3 = None;
let mut f_4 = None;
let mut f_5 = None;
let mut f_6 = None;
let mut f_7 = None;
let mut f_8 = None;
let mut f_9 = None;
let mut f_10 = None;
let mut f_11 = None;
let mut f_12 = None;
let mut f_13 = None;
let mut f_14 = None;
loop {
match r.next(d)? {
Step::End => break,
Step::Item { index: 0, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_0 = Some(value);
}
Step::Item { index: 1, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_1 = Some(value);
}
Step::Item { index: 2, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_2 = Some(value);
}
Step::Item { index: 3, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_3 = Some(value);
}
Step::Item { index: 4, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_4 = Some(value);
}
Step::Item { index: 5, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_5 = Some(value);
}
Step::Item { index: 6, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_6 = Some(value);
}
Step::Item { index: 7, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_7 = Some(value);
}
Step::Item { index: 8, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_8 = Some(value);
}
Step::Item { index: 9, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_9 = Some(value);
}
Step::Item { index: 10, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_10 = Some(value);
}
Step::Item { index: 11, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_11 = Some(value);
}
Step::Item { index: 12, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_12 = Some(value);
}
Step::Item { index: 13, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_13 = Some(value);
}
Step::Item { index: 14, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_14 = Some(value);
}
Step::Item { .. } => return Err(ExiError::UnknownEventCode),
}
}
d.leave();
Ok(Self {
ev_target_energy_request: f_0,
ev_maximum_energy_request: f_1,
ev_minimum_energy_request: f_2,
ev_maximum_charge_power: f_3,
ev_maximum_charge_power_l2: f_4,
ev_maximum_charge_power_l3: f_5,
ev_minimum_charge_power: f_6,
ev_minimum_charge_power_l2: f_7,
ev_minimum_charge_power_l3: f_8,
ev_present_active_power: f_9.ok_or(ExiError::MissingElement)?,
ev_present_active_power_l2: f_10,
ev_present_active_power_l3: f_11,
ev_present_reactive_power: f_12,
ev_present_reactive_power_l2: f_13,
ev_present_reactive_power_l3: f_14,
})
}
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ScheduledACCLResControlMode {
pub evse_target_active_power: Option<super::common::RationalNumber>,
pub evse_target_active_power_l2: Option<super::common::RationalNumber>,
pub evse_target_active_power_l3: Option<super::common::RationalNumber>,
pub evse_target_reactive_power: Option<super::common::RationalNumber>,
pub evse_target_reactive_power_l2: Option<super::common::RationalNumber>,
pub evse_target_reactive_power_l3: Option<super::common::RationalNumber>,
pub evse_present_active_power: Option<super::common::RationalNumber>,
pub evse_present_active_power_l2: Option<super::common::RationalNumber>,
pub evse_present_active_power_l3: Option<super::common::RationalNumber>,
}
impl ScheduledACCLResControlMode {
const SHAPE: Shape = Shape {
prod_before: &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
width: &[4, 4, 4, 3, 3, 3, 3, 2, 2, 1],
repeat_width: &[0, 0, 0, 0, 0, 0, 0, 0, 0],
min: &[0, 0, 0, 0, 0, 0, 0, 0, 0],
max: &[1, 1, 1, 1, 1, 1, 1, 1, 1],
};
}
impl ScheduledACCLResControlMode {
pub fn encode_body(&self, e: &mut Encoder<'_>) -> ExiResult<()> {
e.enter()?;
let mut w = SeqWriter::new(Self::SHAPE);
if let Some(item) = &self.evse_target_active_power {
w.start(e, 0, 0)?;
item.encode_body(e)?;
w.finish(0, 1);
}
if let Some(item) = &self.evse_target_active_power_l2 {
w.start(e, 1, 0)?;
item.encode_body(e)?;
w.finish(1, 1);
}
if let Some(item) = &self.evse_target_active_power_l3 {
w.start(e, 2, 0)?;
item.encode_body(e)?;
w.finish(2, 1);
}
if let Some(item) = &self.evse_target_reactive_power {
w.start(e, 3, 0)?;
item.encode_body(e)?;
w.finish(3, 1);
}
if let Some(item) = &self.evse_target_reactive_power_l2 {
w.start(e, 4, 0)?;
item.encode_body(e)?;
w.finish(4, 1);
}
if let Some(item) = &self.evse_target_reactive_power_l3 {
w.start(e, 5, 0)?;
item.encode_body(e)?;
w.finish(5, 1);
}
if let Some(item) = &self.evse_present_active_power {
w.start(e, 6, 0)?;
item.encode_body(e)?;
w.finish(6, 1);
}
if let Some(item) = &self.evse_present_active_power_l2 {
w.start(e, 7, 0)?;
item.encode_body(e)?;
w.finish(7, 1);
}
if let Some(item) = &self.evse_present_active_power_l3 {
w.start(e, 8, 0)?;
item.encode_body(e)?;
w.finish(8, 1);
}
w.end(e)?;
e.leave();
Ok(())
}
}
impl ScheduledACCLResControlMode {
pub fn decode_body(d: &mut Decoder<'_>) -> ExiResult<Self> {
d.enter()?;
let mut r = SeqReader::new(Self::SHAPE);
let mut f_0 = None;
let mut f_1 = None;
let mut f_2 = None;
let mut f_3 = None;
let mut f_4 = None;
let mut f_5 = None;
let mut f_6 = None;
let mut f_7 = None;
let mut f_8 = None;
loop {
match r.next(d)? {
Step::End => break,
Step::Item { index: 0, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_0 = Some(value);
}
Step::Item { index: 1, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_1 = Some(value);
}
Step::Item { index: 2, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_2 = Some(value);
}
Step::Item { index: 3, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_3 = Some(value);
}
Step::Item { index: 4, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_4 = Some(value);
}
Step::Item { index: 5, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_5 = Some(value);
}
Step::Item { index: 6, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_6 = Some(value);
}
Step::Item { index: 7, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_7 = Some(value);
}
Step::Item { index: 8, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_8 = Some(value);
}
Step::Item { .. } => return Err(ExiError::UnknownEventCode),
}
}
d.leave();
Ok(Self {
evse_target_active_power: f_0,
evse_target_active_power_l2: f_1,
evse_target_active_power_l3: f_2,
evse_target_reactive_power: f_3,
evse_target_reactive_power_l2: f_4,
evse_target_reactive_power_l3: f_5,
evse_present_active_power: f_6,
evse_present_active_power_l2: f_7,
evse_present_active_power_l3: f_8,
})
}
}
pub const DOCUMENT_WIDTH: u32 = 6;
pub const FRAGMENT_WIDTH: u32 = 8;
pub const FRAGMENT_ED_CODE: u64 = 155;
pub const XMLDSIG_FRAGMENT_WIDTH: u32 = 6;
pub const XMLDSIG_FRAGMENT_ED_CODE: u64 = 46;
impl ACCPDReqEnergyTransferMode {
pub const DOCUMENT_CODE: u64 = 0;
}
impl crate::exi::ExiDocument for ACCPDReqEnergyTransferMode {
fn to_slice(&self, buf: &mut [u8]) -> ExiResult<usize> {
let mut e = Encoder::new(buf);
e.write_header(crate::exi::Header::ISO15118)?;
e.event(Self::DOCUMENT_CODE, DOCUMENT_WIDTH)?;
self.encode_body(&mut e)?;
e.finish()
}
fn from_bytes(bytes: &[u8]) -> ExiResult<Self> {
let mut d = Decoder::new(bytes);
d.read_header()?;
d.expect_event(Self::DOCUMENT_CODE, DOCUMENT_WIDTH)?;
let value = Self::decode_body(&mut d)?;
d.finish()?;
Ok(value)
}
}
impl ACCPDResEnergyTransferMode {
pub const DOCUMENT_CODE: u64 = 1;
}
impl crate::exi::ExiDocument for ACCPDResEnergyTransferMode {
fn to_slice(&self, buf: &mut [u8]) -> ExiResult<usize> {
let mut e = Encoder::new(buf);
e.write_header(crate::exi::Header::ISO15118)?;
e.event(Self::DOCUMENT_CODE, DOCUMENT_WIDTH)?;
self.encode_body(&mut e)?;
e.finish()
}
fn from_bytes(bytes: &[u8]) -> ExiResult<Self> {
let mut d = Decoder::new(bytes);
d.read_header()?;
d.expect_event(Self::DOCUMENT_CODE, DOCUMENT_WIDTH)?;
let value = Self::decode_body(&mut d)?;
d.finish()?;
Ok(value)
}
}
impl ACChargeLoopReq {
pub const DOCUMENT_CODE: u64 = 2;
}
impl crate::exi::ExiDocument for ACChargeLoopReq {
fn to_slice(&self, buf: &mut [u8]) -> ExiResult<usize> {
let mut e = Encoder::new(buf);
e.write_header(crate::exi::Header::ISO15118)?;
e.event(Self::DOCUMENT_CODE, DOCUMENT_WIDTH)?;
self.encode_body(&mut e)?;
e.finish()
}
fn from_bytes(bytes: &[u8]) -> ExiResult<Self> {
let mut d = Decoder::new(bytes);
d.read_header()?;
d.expect_event(Self::DOCUMENT_CODE, DOCUMENT_WIDTH)?;
let value = Self::decode_body(&mut d)?;
d.finish()?;
Ok(value)
}
}
impl ACChargeLoopRes {
pub const DOCUMENT_CODE: u64 = 3;
}
impl crate::exi::ExiDocument for ACChargeLoopRes {
fn to_slice(&self, buf: &mut [u8]) -> ExiResult<usize> {
let mut e = Encoder::new(buf);
e.write_header(crate::exi::Header::ISO15118)?;
e.event(Self::DOCUMENT_CODE, DOCUMENT_WIDTH)?;
self.encode_body(&mut e)?;
e.finish()
}
fn from_bytes(bytes: &[u8]) -> ExiResult<Self> {
let mut d = Decoder::new(bytes);
d.read_header()?;
d.expect_event(Self::DOCUMENT_CODE, DOCUMENT_WIDTH)?;
let value = Self::decode_body(&mut d)?;
d.finish()?;
Ok(value)
}
}
impl ACChargeParameterDiscoveryReq {
pub const DOCUMENT_CODE: u64 = 4;
}
impl crate::exi::ExiDocument for ACChargeParameterDiscoveryReq {
fn to_slice(&self, buf: &mut [u8]) -> ExiResult<usize> {
let mut e = Encoder::new(buf);
e.write_header(crate::exi::Header::ISO15118)?;
e.event(Self::DOCUMENT_CODE, DOCUMENT_WIDTH)?;
self.encode_body(&mut e)?;
e.finish()
}
fn from_bytes(bytes: &[u8]) -> ExiResult<Self> {
let mut d = Decoder::new(bytes);
d.read_header()?;
d.expect_event(Self::DOCUMENT_CODE, DOCUMENT_WIDTH)?;
let value = Self::decode_body(&mut d)?;
d.finish()?;
Ok(value)
}
}
impl ACChargeParameterDiscoveryRes {
pub const DOCUMENT_CODE: u64 = 5;
}
impl crate::exi::ExiDocument for ACChargeParameterDiscoveryRes {
fn to_slice(&self, buf: &mut [u8]) -> ExiResult<usize> {
let mut e = Encoder::new(buf);
e.write_header(crate::exi::Header::ISO15118)?;
e.event(Self::DOCUMENT_CODE, DOCUMENT_WIDTH)?;
self.encode_body(&mut e)?;
e.finish()
}
fn from_bytes(bytes: &[u8]) -> ExiResult<Self> {
let mut d = Decoder::new(bytes);
d.read_header()?;
d.expect_event(Self::DOCUMENT_CODE, DOCUMENT_WIDTH)?;
let value = Self::decode_body(&mut d)?;
d.finish()?;
Ok(value)
}
}
impl BPTACCPDReqEnergyTransferMode {
pub const DOCUMENT_CODE: u64 = 6;
}
impl crate::exi::ExiDocument for BPTACCPDReqEnergyTransferMode {
fn to_slice(&self, buf: &mut [u8]) -> ExiResult<usize> {
let mut e = Encoder::new(buf);
e.write_header(crate::exi::Header::ISO15118)?;
e.event(Self::DOCUMENT_CODE, DOCUMENT_WIDTH)?;
self.encode_body(&mut e)?;
e.finish()
}
fn from_bytes(bytes: &[u8]) -> ExiResult<Self> {
let mut d = Decoder::new(bytes);
d.read_header()?;
d.expect_event(Self::DOCUMENT_CODE, DOCUMENT_WIDTH)?;
let value = Self::decode_body(&mut d)?;
d.finish()?;
Ok(value)
}
}
impl BPTACCPDResEnergyTransferMode {
pub const DOCUMENT_CODE: u64 = 7;
}
impl crate::exi::ExiDocument for BPTACCPDResEnergyTransferMode {
fn to_slice(&self, buf: &mut [u8]) -> ExiResult<usize> {
let mut e = Encoder::new(buf);
e.write_header(crate::exi::Header::ISO15118)?;
e.event(Self::DOCUMENT_CODE, DOCUMENT_WIDTH)?;
self.encode_body(&mut e)?;
e.finish()
}
fn from_bytes(bytes: &[u8]) -> ExiResult<Self> {
let mut d = Decoder::new(bytes);
d.read_header()?;
d.expect_event(Self::DOCUMENT_CODE, DOCUMENT_WIDTH)?;
let value = Self::decode_body(&mut d)?;
d.finish()?;
Ok(value)
}
}
impl BPTDynamicACCLReqControlMode {
pub const DOCUMENT_CODE: u64 = 8;
}
impl crate::exi::ExiDocument for BPTDynamicACCLReqControlMode {
fn to_slice(&self, buf: &mut [u8]) -> ExiResult<usize> {
let mut e = Encoder::new(buf);
e.write_header(crate::exi::Header::ISO15118)?;
e.event(Self::DOCUMENT_CODE, DOCUMENT_WIDTH)?;
self.encode_body(&mut e)?;
e.finish()
}
fn from_bytes(bytes: &[u8]) -> ExiResult<Self> {
let mut d = Decoder::new(bytes);
d.read_header()?;
d.expect_event(Self::DOCUMENT_CODE, DOCUMENT_WIDTH)?;
let value = Self::decode_body(&mut d)?;
d.finish()?;
Ok(value)
}
}
impl BPTDynamicACCLResControlMode {
pub const DOCUMENT_CODE: u64 = 9;
}
impl crate::exi::ExiDocument for BPTDynamicACCLResControlMode {
fn to_slice(&self, buf: &mut [u8]) -> ExiResult<usize> {
let mut e = Encoder::new(buf);
e.write_header(crate::exi::Header::ISO15118)?;
e.event(Self::DOCUMENT_CODE, DOCUMENT_WIDTH)?;
self.encode_body(&mut e)?;
e.finish()
}
fn from_bytes(bytes: &[u8]) -> ExiResult<Self> {
let mut d = Decoder::new(bytes);
d.read_header()?;
d.expect_event(Self::DOCUMENT_CODE, DOCUMENT_WIDTH)?;
let value = Self::decode_body(&mut d)?;
d.finish()?;
Ok(value)
}
}
impl BPTScheduledACCLReqControlMode {
pub const DOCUMENT_CODE: u64 = 10;
}
impl crate::exi::ExiDocument for BPTScheduledACCLReqControlMode {
fn to_slice(&self, buf: &mut [u8]) -> ExiResult<usize> {
let mut e = Encoder::new(buf);
e.write_header(crate::exi::Header::ISO15118)?;
e.event(Self::DOCUMENT_CODE, DOCUMENT_WIDTH)?;
self.encode_body(&mut e)?;
e.finish()
}
fn from_bytes(bytes: &[u8]) -> ExiResult<Self> {
let mut d = Decoder::new(bytes);
d.read_header()?;
d.expect_event(Self::DOCUMENT_CODE, DOCUMENT_WIDTH)?;
let value = Self::decode_body(&mut d)?;
d.finish()?;
Ok(value)
}
}
impl BPTScheduledACCLResControlMode {
pub const DOCUMENT_CODE: u64 = 11;
}
impl crate::exi::ExiDocument for BPTScheduledACCLResControlMode {
fn to_slice(&self, buf: &mut [u8]) -> ExiResult<usize> {
let mut e = Encoder::new(buf);
e.write_header(crate::exi::Header::ISO15118)?;
e.event(Self::DOCUMENT_CODE, DOCUMENT_WIDTH)?;
self.encode_body(&mut e)?;
e.finish()
}
fn from_bytes(bytes: &[u8]) -> ExiResult<Self> {
let mut d = Decoder::new(bytes);
d.read_header()?;
d.expect_event(Self::DOCUMENT_CODE, DOCUMENT_WIDTH)?;
let value = Self::decode_body(&mut d)?;
d.finish()?;
Ok(value)
}
}
impl DynamicACCLReqControlMode {
pub const DOCUMENT_CODE: u64 = 18;
}
impl crate::exi::ExiDocument for DynamicACCLReqControlMode {
fn to_slice(&self, buf: &mut [u8]) -> ExiResult<usize> {
let mut e = Encoder::new(buf);
e.write_header(crate::exi::Header::ISO15118)?;
e.event(Self::DOCUMENT_CODE, DOCUMENT_WIDTH)?;
self.encode_body(&mut e)?;
e.finish()
}
fn from_bytes(bytes: &[u8]) -> ExiResult<Self> {
let mut d = Decoder::new(bytes);
d.read_header()?;
d.expect_event(Self::DOCUMENT_CODE, DOCUMENT_WIDTH)?;
let value = Self::decode_body(&mut d)?;
d.finish()?;
Ok(value)
}
}
impl DynamicACCLResControlMode {
pub const DOCUMENT_CODE: u64 = 19;
}
impl crate::exi::ExiDocument for DynamicACCLResControlMode {
fn to_slice(&self, buf: &mut [u8]) -> ExiResult<usize> {
let mut e = Encoder::new(buf);
e.write_header(crate::exi::Header::ISO15118)?;
e.event(Self::DOCUMENT_CODE, DOCUMENT_WIDTH)?;
self.encode_body(&mut e)?;
e.finish()
}
fn from_bytes(bytes: &[u8]) -> ExiResult<Self> {
let mut d = Decoder::new(bytes);
d.read_header()?;
d.expect_event(Self::DOCUMENT_CODE, DOCUMENT_WIDTH)?;
let value = Self::decode_body(&mut d)?;
d.finish()?;
Ok(value)
}
}
impl ScheduledACCLReqControlMode {
pub const DOCUMENT_CODE: u64 = 31;
}
impl crate::exi::ExiDocument for ScheduledACCLReqControlMode {
fn to_slice(&self, buf: &mut [u8]) -> ExiResult<usize> {
let mut e = Encoder::new(buf);
e.write_header(crate::exi::Header::ISO15118)?;
e.event(Self::DOCUMENT_CODE, DOCUMENT_WIDTH)?;
self.encode_body(&mut e)?;
e.finish()
}
fn from_bytes(bytes: &[u8]) -> ExiResult<Self> {
let mut d = Decoder::new(bytes);
d.read_header()?;
d.expect_event(Self::DOCUMENT_CODE, DOCUMENT_WIDTH)?;
let value = Self::decode_body(&mut d)?;
d.finish()?;
Ok(value)
}
}
impl ScheduledACCLResControlMode {
pub const DOCUMENT_CODE: u64 = 32;
}
impl crate::exi::ExiDocument for ScheduledACCLResControlMode {
fn to_slice(&self, buf: &mut [u8]) -> ExiResult<usize> {
let mut e = Encoder::new(buf);
e.write_header(crate::exi::Header::ISO15118)?;
e.event(Self::DOCUMENT_CODE, DOCUMENT_WIDTH)?;
self.encode_body(&mut e)?;
e.finish()
}
fn from_bytes(bytes: &[u8]) -> ExiResult<Self> {
let mut d = Decoder::new(bytes);
d.read_header()?;
d.expect_event(Self::DOCUMENT_CODE, DOCUMENT_WIDTH)?;
let value = Self::decode_body(&mut d)?;
d.finish()?;
Ok(value)
}
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[non_exhaustive]
pub enum Document {
ACCPDReqEnergyTransferMode(ACCPDReqEnergyTransferMode),
ACCPDResEnergyTransferMode(ACCPDResEnergyTransferMode),
ACChargeLoopReq(ACChargeLoopReq),
ACChargeLoopRes(ACChargeLoopRes),
ACChargeParameterDiscoveryReq(ACChargeParameterDiscoveryReq),
ACChargeParameterDiscoveryRes(ACChargeParameterDiscoveryRes),
BPTACCPDReqEnergyTransferMode(BPTACCPDReqEnergyTransferMode),
BPTACCPDResEnergyTransferMode(BPTACCPDResEnergyTransferMode),
BPTDynamicACCLReqControlMode(BPTDynamicACCLReqControlMode),
BPTDynamicACCLResControlMode(BPTDynamicACCLResControlMode),
BPTScheduledACCLReqControlMode(BPTScheduledACCLReqControlMode),
BPTScheduledACCLResControlMode(BPTScheduledACCLResControlMode),
DynamicACCLReqControlMode(DynamicACCLReqControlMode),
DynamicACCLResControlMode(DynamicACCLResControlMode),
ScheduledACCLReqControlMode(ScheduledACCLReqControlMode),
ScheduledACCLResControlMode(ScheduledACCLResControlMode),
}
impl Document {
#[must_use]
pub const fn name(&self) -> &'static str {
match self {
Self::ACCPDReqEnergyTransferMode(_) => "AC_CPDReqEnergyTransferMode",
Self::ACCPDResEnergyTransferMode(_) => "AC_CPDResEnergyTransferMode",
Self::ACChargeLoopReq(_) => "AC_ChargeLoopReq",
Self::ACChargeLoopRes(_) => "AC_ChargeLoopRes",
Self::ACChargeParameterDiscoveryReq(_) => "AC_ChargeParameterDiscoveryReq",
Self::ACChargeParameterDiscoveryRes(_) => "AC_ChargeParameterDiscoveryRes",
Self::BPTACCPDReqEnergyTransferMode(_) => "BPT_AC_CPDReqEnergyTransferMode",
Self::BPTACCPDResEnergyTransferMode(_) => "BPT_AC_CPDResEnergyTransferMode",
Self::BPTDynamicACCLReqControlMode(_) => "BPT_Dynamic_AC_CLReqControlMode",
Self::BPTDynamicACCLResControlMode(_) => "BPT_Dynamic_AC_CLResControlMode",
Self::BPTScheduledACCLReqControlMode(_) => "BPT_Scheduled_AC_CLReqControlMode",
Self::BPTScheduledACCLResControlMode(_) => "BPT_Scheduled_AC_CLResControlMode",
Self::DynamicACCLReqControlMode(_) => "Dynamic_AC_CLReqControlMode",
Self::DynamicACCLResControlMode(_) => "Dynamic_AC_CLResControlMode",
Self::ScheduledACCLReqControlMode(_) => "Scheduled_AC_CLReqControlMode",
Self::ScheduledACCLResControlMode(_) => "Scheduled_AC_CLResControlMode",
}
}
#[must_use]
pub const fn code(&self) -> u64 {
match self {
Self::ACCPDReqEnergyTransferMode(_) => 0,
Self::ACCPDResEnergyTransferMode(_) => 1,
Self::ACChargeLoopReq(_) => 2,
Self::ACChargeLoopRes(_) => 3,
Self::ACChargeParameterDiscoveryReq(_) => 4,
Self::ACChargeParameterDiscoveryRes(_) => 5,
Self::BPTACCPDReqEnergyTransferMode(_) => 6,
Self::BPTACCPDResEnergyTransferMode(_) => 7,
Self::BPTDynamicACCLReqControlMode(_) => 8,
Self::BPTDynamicACCLResControlMode(_) => 9,
Self::BPTScheduledACCLReqControlMode(_) => 10,
Self::BPTScheduledACCLResControlMode(_) => 11,
Self::DynamicACCLReqControlMode(_) => 18,
Self::DynamicACCLResControlMode(_) => 19,
Self::ScheduledACCLReqControlMode(_) => 31,
Self::ScheduledACCLResControlMode(_) => 32,
}
}
}
impl crate::exi::ExiDocument for Document {
fn to_slice(&self, buf: &mut [u8]) -> ExiResult<usize> {
let mut e = Encoder::new(buf);
e.write_header(crate::exi::Header::ISO15118)?;
e.event(self.code(), DOCUMENT_WIDTH)?;
match self {
Self::ACCPDReqEnergyTransferMode(m) => m.encode_body(&mut e)?,
Self::ACCPDResEnergyTransferMode(m) => m.encode_body(&mut e)?,
Self::ACChargeLoopReq(m) => m.encode_body(&mut e)?,
Self::ACChargeLoopRes(m) => m.encode_body(&mut e)?,
Self::ACChargeParameterDiscoveryReq(m) => m.encode_body(&mut e)?,
Self::ACChargeParameterDiscoveryRes(m) => m.encode_body(&mut e)?,
Self::BPTACCPDReqEnergyTransferMode(m) => m.encode_body(&mut e)?,
Self::BPTACCPDResEnergyTransferMode(m) => m.encode_body(&mut e)?,
Self::BPTDynamicACCLReqControlMode(m) => m.encode_body(&mut e)?,
Self::BPTDynamicACCLResControlMode(m) => m.encode_body(&mut e)?,
Self::BPTScheduledACCLReqControlMode(m) => m.encode_body(&mut e)?,
Self::BPTScheduledACCLResControlMode(m) => m.encode_body(&mut e)?,
Self::DynamicACCLReqControlMode(m) => m.encode_body(&mut e)?,
Self::DynamicACCLResControlMode(m) => m.encode_body(&mut e)?,
Self::ScheduledACCLReqControlMode(m) => m.encode_body(&mut e)?,
Self::ScheduledACCLResControlMode(m) => m.encode_body(&mut e)?,
}
e.finish()
}
fn from_bytes(bytes: &[u8]) -> ExiResult<Self> {
let mut d = Decoder::new(bytes);
d.read_header()?;
let value = match d.event(DOCUMENT_WIDTH)? {
0 => Self::ACCPDReqEnergyTransferMode(ACCPDReqEnergyTransferMode::decode_body(&mut d)?),
1 => Self::ACCPDResEnergyTransferMode(ACCPDResEnergyTransferMode::decode_body(&mut d)?),
2 => Self::ACChargeLoopReq(ACChargeLoopReq::decode_body(&mut d)?),
3 => Self::ACChargeLoopRes(ACChargeLoopRes::decode_body(&mut d)?),
4 => Self::ACChargeParameterDiscoveryReq(ACChargeParameterDiscoveryReq::decode_body(
&mut d,
)?),
5 => Self::ACChargeParameterDiscoveryRes(ACChargeParameterDiscoveryRes::decode_body(
&mut d,
)?),
6 => Self::BPTACCPDReqEnergyTransferMode(BPTACCPDReqEnergyTransferMode::decode_body(
&mut d,
)?),
7 => Self::BPTACCPDResEnergyTransferMode(BPTACCPDResEnergyTransferMode::decode_body(
&mut d,
)?),
8 => Self::BPTDynamicACCLReqControlMode(BPTDynamicACCLReqControlMode::decode_body(
&mut d,
)?),
9 => Self::BPTDynamicACCLResControlMode(BPTDynamicACCLResControlMode::decode_body(
&mut d,
)?),
10 => Self::BPTScheduledACCLReqControlMode(
BPTScheduledACCLReqControlMode::decode_body(&mut d)?,
),
11 => Self::BPTScheduledACCLResControlMode(
BPTScheduledACCLResControlMode::decode_body(&mut d)?,
),
18 => Self::DynamicACCLReqControlMode(DynamicACCLReqControlMode::decode_body(&mut d)?),
19 => Self::DynamicACCLResControlMode(DynamicACCLResControlMode::decode_body(&mut d)?),
31 => {
Self::ScheduledACCLReqControlMode(ScheduledACCLReqControlMode::decode_body(&mut d)?)
}
32 => {
Self::ScheduledACCLResControlMode(ScheduledACCLResControlMode::decode_body(&mut d)?)
}
_ => return Err(ExiError::UnknownEventCode),
};
d.finish()?;
Ok(value)
}
}
impl Document {
#[must_use]
pub const fn header(&self) -> Option<&super::common::MessageHeader> {
match self {
Self::ACChargeLoopReq(m) => Some(&m.header),
Self::ACChargeLoopRes(m) => Some(&m.header),
Self::ACChargeParameterDiscoveryReq(m) => Some(&m.header),
Self::ACChargeParameterDiscoveryRes(m) => Some(&m.header),
_ => None,
}
}
pub const fn header_mut(&mut self) -> Option<&mut super::common::MessageHeader> {
match self {
Self::ACChargeLoopReq(m) => Some(&mut m.header),
Self::ACChargeLoopRes(m) => Some(&mut m.header),
Self::ACChargeParameterDiscoveryReq(m) => Some(&mut m.header),
Self::ACChargeParameterDiscoveryRes(m) => Some(&mut m.header),
_ => None,
}
}
}
impl Document {
#[must_use]
pub const fn response_code(&self) -> Option<super::common::ResponseCode> {
match self {
Self::ACChargeLoopRes(m) => Some(m.response_code),
Self::ACChargeParameterDiscoveryRes(m) => Some(m.response_code),
_ => None,
}
}
}
impl Document {
#[must_use]
pub const fn fragment_code(&self) -> u64 {
match self {
Self::ACCPDReqEnergyTransferMode(_) => 0,
Self::ACCPDResEnergyTransferMode(_) => 1,
Self::ACChargeLoopReq(_) => 2,
Self::ACChargeLoopRes(_) => 3,
Self::ACChargeParameterDiscoveryReq(_) => 4,
Self::ACChargeParameterDiscoveryRes(_) => 5,
Self::BPTACCPDReqEnergyTransferMode(_) => 9,
Self::BPTACCPDResEnergyTransferMode(_) => 10,
Self::BPTDynamicACCLReqControlMode(_) => 12,
Self::BPTDynamicACCLResControlMode(_) => 13,
Self::BPTScheduledACCLReqControlMode(_) => 15,
Self::BPTScheduledACCLResControlMode(_) => 16,
Self::DynamicACCLReqControlMode(_) => 30,
Self::DynamicACCLResControlMode(_) => 31,
Self::ScheduledACCLReqControlMode(_) => 126,
Self::ScheduledACCLResControlMode(_) => 127,
}
}
pub fn encode_fragment(&self, buf: &mut [u8]) -> ExiResult<usize> {
let mut e = Encoder::new(buf);
e.write_header(crate::exi::Header::ISO15118)?;
e.event(self.fragment_code(), FRAGMENT_WIDTH)?;
match self {
Self::ACCPDReqEnergyTransferMode(m) => m.encode_body(&mut e)?,
Self::ACCPDResEnergyTransferMode(m) => m.encode_body(&mut e)?,
Self::ACChargeLoopReq(m) => m.encode_body(&mut e)?,
Self::ACChargeLoopRes(m) => m.encode_body(&mut e)?,
Self::ACChargeParameterDiscoveryReq(m) => m.encode_body(&mut e)?,
Self::ACChargeParameterDiscoveryRes(m) => m.encode_body(&mut e)?,
Self::BPTACCPDReqEnergyTransferMode(m) => m.encode_body(&mut e)?,
Self::BPTACCPDResEnergyTransferMode(m) => m.encode_body(&mut e)?,
Self::BPTDynamicACCLReqControlMode(m) => m.encode_body(&mut e)?,
Self::BPTDynamicACCLResControlMode(m) => m.encode_body(&mut e)?,
Self::BPTScheduledACCLReqControlMode(m) => m.encode_body(&mut e)?,
Self::BPTScheduledACCLResControlMode(m) => m.encode_body(&mut e)?,
Self::DynamicACCLReqControlMode(m) => m.encode_body(&mut e)?,
Self::DynamicACCLResControlMode(m) => m.encode_body(&mut e)?,
Self::ScheduledACCLReqControlMode(m) => m.encode_body(&mut e)?,
Self::ScheduledACCLResControlMode(m) => m.encode_body(&mut e)?,
}
e.event(FRAGMENT_ED_CODE, FRAGMENT_WIDTH)?;
e.finish()
}
pub fn to_fragment(&self) -> ExiResult<Vec<u8>> {
crate::exi::encode_growing(|buf| self.encode_fragment(buf))
}
pub fn from_fragment(bytes: &[u8]) -> ExiResult<Self> {
let mut d = Decoder::new(bytes);
d.read_header()?;
let value = match d.event(FRAGMENT_WIDTH)? {
0 => Self::ACCPDReqEnergyTransferMode(ACCPDReqEnergyTransferMode::decode_body(&mut d)?),
1 => Self::ACCPDResEnergyTransferMode(ACCPDResEnergyTransferMode::decode_body(&mut d)?),
2 => Self::ACChargeLoopReq(ACChargeLoopReq::decode_body(&mut d)?),
3 => Self::ACChargeLoopRes(ACChargeLoopRes::decode_body(&mut d)?),
4 => Self::ACChargeParameterDiscoveryReq(ACChargeParameterDiscoveryReq::decode_body(
&mut d,
)?),
5 => Self::ACChargeParameterDiscoveryRes(ACChargeParameterDiscoveryRes::decode_body(
&mut d,
)?),
9 => Self::BPTACCPDReqEnergyTransferMode(BPTACCPDReqEnergyTransferMode::decode_body(
&mut d,
)?),
10 => Self::BPTACCPDResEnergyTransferMode(BPTACCPDResEnergyTransferMode::decode_body(
&mut d,
)?),
12 => Self::BPTDynamicACCLReqControlMode(BPTDynamicACCLReqControlMode::decode_body(
&mut d,
)?),
13 => Self::BPTDynamicACCLResControlMode(BPTDynamicACCLResControlMode::decode_body(
&mut d,
)?),
15 => Self::BPTScheduledACCLReqControlMode(
BPTScheduledACCLReqControlMode::decode_body(&mut d)?,
),
16 => Self::BPTScheduledACCLResControlMode(
BPTScheduledACCLResControlMode::decode_body(&mut d)?,
),
30 => Self::DynamicACCLReqControlMode(DynamicACCLReqControlMode::decode_body(&mut d)?),
31 => Self::DynamicACCLResControlMode(DynamicACCLResControlMode::decode_body(&mut d)?),
126 => {
Self::ScheduledACCLReqControlMode(ScheduledACCLReqControlMode::decode_body(&mut d)?)
}
127 => {
Self::ScheduledACCLResControlMode(ScheduledACCLResControlMode::decode_body(&mut d)?)
}
_ => return Err(ExiError::UnknownEventCode),
};
d.expect_event(FRAGMENT_ED_CODE, FRAGMENT_WIDTH)?;
d.finish()?;
Ok(value)
}
}
impl ACCPDReqEnergyTransferMode {
pub const FRAGMENT_CODE: u64 = 0;
pub fn encode_fragment(&self, buf: &mut [u8]) -> ExiResult<usize> {
let mut e = Encoder::new(buf);
e.write_header(crate::exi::Header::ISO15118)?;
e.event(Self::FRAGMENT_CODE, FRAGMENT_WIDTH)?;
self.encode_body(&mut e)?;
e.event(FRAGMENT_ED_CODE, FRAGMENT_WIDTH)?;
e.finish()
}
pub fn to_fragment(&self) -> ExiResult<Vec<u8>> {
crate::exi::encode_growing(|buf| self.encode_fragment(buf))
}
pub fn from_fragment(bytes: &[u8]) -> ExiResult<Self> {
let mut d = Decoder::new(bytes);
d.read_header()?;
d.expect_event(Self::FRAGMENT_CODE, FRAGMENT_WIDTH)?;
let value = Self::decode_body(&mut d)?;
d.expect_event(FRAGMENT_ED_CODE, FRAGMENT_WIDTH)?;
d.finish()?;
Ok(value)
}
}
impl ACCPDResEnergyTransferMode {
pub const FRAGMENT_CODE: u64 = 1;
pub fn encode_fragment(&self, buf: &mut [u8]) -> ExiResult<usize> {
let mut e = Encoder::new(buf);
e.write_header(crate::exi::Header::ISO15118)?;
e.event(Self::FRAGMENT_CODE, FRAGMENT_WIDTH)?;
self.encode_body(&mut e)?;
e.event(FRAGMENT_ED_CODE, FRAGMENT_WIDTH)?;
e.finish()
}
pub fn to_fragment(&self) -> ExiResult<Vec<u8>> {
crate::exi::encode_growing(|buf| self.encode_fragment(buf))
}
pub fn from_fragment(bytes: &[u8]) -> ExiResult<Self> {
let mut d = Decoder::new(bytes);
d.read_header()?;
d.expect_event(Self::FRAGMENT_CODE, FRAGMENT_WIDTH)?;
let value = Self::decode_body(&mut d)?;
d.expect_event(FRAGMENT_ED_CODE, FRAGMENT_WIDTH)?;
d.finish()?;
Ok(value)
}
}
impl ACChargeLoopReq {
pub const FRAGMENT_CODE: u64 = 2;
pub fn encode_fragment(&self, buf: &mut [u8]) -> ExiResult<usize> {
let mut e = Encoder::new(buf);
e.write_header(crate::exi::Header::ISO15118)?;
e.event(Self::FRAGMENT_CODE, FRAGMENT_WIDTH)?;
self.encode_body(&mut e)?;
e.event(FRAGMENT_ED_CODE, FRAGMENT_WIDTH)?;
e.finish()
}
pub fn to_fragment(&self) -> ExiResult<Vec<u8>> {
crate::exi::encode_growing(|buf| self.encode_fragment(buf))
}
pub fn from_fragment(bytes: &[u8]) -> ExiResult<Self> {
let mut d = Decoder::new(bytes);
d.read_header()?;
d.expect_event(Self::FRAGMENT_CODE, FRAGMENT_WIDTH)?;
let value = Self::decode_body(&mut d)?;
d.expect_event(FRAGMENT_ED_CODE, FRAGMENT_WIDTH)?;
d.finish()?;
Ok(value)
}
}
impl ACChargeLoopRes {
pub const FRAGMENT_CODE: u64 = 3;
pub fn encode_fragment(&self, buf: &mut [u8]) -> ExiResult<usize> {
let mut e = Encoder::new(buf);
e.write_header(crate::exi::Header::ISO15118)?;
e.event(Self::FRAGMENT_CODE, FRAGMENT_WIDTH)?;
self.encode_body(&mut e)?;
e.event(FRAGMENT_ED_CODE, FRAGMENT_WIDTH)?;
e.finish()
}
pub fn to_fragment(&self) -> ExiResult<Vec<u8>> {
crate::exi::encode_growing(|buf| self.encode_fragment(buf))
}
pub fn from_fragment(bytes: &[u8]) -> ExiResult<Self> {
let mut d = Decoder::new(bytes);
d.read_header()?;
d.expect_event(Self::FRAGMENT_CODE, FRAGMENT_WIDTH)?;
let value = Self::decode_body(&mut d)?;
d.expect_event(FRAGMENT_ED_CODE, FRAGMENT_WIDTH)?;
d.finish()?;
Ok(value)
}
}
impl ACChargeParameterDiscoveryReq {
pub const FRAGMENT_CODE: u64 = 4;
pub fn encode_fragment(&self, buf: &mut [u8]) -> ExiResult<usize> {
let mut e = Encoder::new(buf);
e.write_header(crate::exi::Header::ISO15118)?;
e.event(Self::FRAGMENT_CODE, FRAGMENT_WIDTH)?;
self.encode_body(&mut e)?;
e.event(FRAGMENT_ED_CODE, FRAGMENT_WIDTH)?;
e.finish()
}
pub fn to_fragment(&self) -> ExiResult<Vec<u8>> {
crate::exi::encode_growing(|buf| self.encode_fragment(buf))
}
pub fn from_fragment(bytes: &[u8]) -> ExiResult<Self> {
let mut d = Decoder::new(bytes);
d.read_header()?;
d.expect_event(Self::FRAGMENT_CODE, FRAGMENT_WIDTH)?;
let value = Self::decode_body(&mut d)?;
d.expect_event(FRAGMENT_ED_CODE, FRAGMENT_WIDTH)?;
d.finish()?;
Ok(value)
}
}
impl ACChargeParameterDiscoveryRes {
pub const FRAGMENT_CODE: u64 = 5;
pub fn encode_fragment(&self, buf: &mut [u8]) -> ExiResult<usize> {
let mut e = Encoder::new(buf);
e.write_header(crate::exi::Header::ISO15118)?;
e.event(Self::FRAGMENT_CODE, FRAGMENT_WIDTH)?;
self.encode_body(&mut e)?;
e.event(FRAGMENT_ED_CODE, FRAGMENT_WIDTH)?;
e.finish()
}
pub fn to_fragment(&self) -> ExiResult<Vec<u8>> {
crate::exi::encode_growing(|buf| self.encode_fragment(buf))
}
pub fn from_fragment(bytes: &[u8]) -> ExiResult<Self> {
let mut d = Decoder::new(bytes);
d.read_header()?;
d.expect_event(Self::FRAGMENT_CODE, FRAGMENT_WIDTH)?;
let value = Self::decode_body(&mut d)?;
d.expect_event(FRAGMENT_ED_CODE, FRAGMENT_WIDTH)?;
d.finish()?;
Ok(value)
}
}
impl BPTACCPDReqEnergyTransferMode {
pub const FRAGMENT_CODE: u64 = 9;
pub fn encode_fragment(&self, buf: &mut [u8]) -> ExiResult<usize> {
let mut e = Encoder::new(buf);
e.write_header(crate::exi::Header::ISO15118)?;
e.event(Self::FRAGMENT_CODE, FRAGMENT_WIDTH)?;
self.encode_body(&mut e)?;
e.event(FRAGMENT_ED_CODE, FRAGMENT_WIDTH)?;
e.finish()
}
pub fn to_fragment(&self) -> ExiResult<Vec<u8>> {
crate::exi::encode_growing(|buf| self.encode_fragment(buf))
}
pub fn from_fragment(bytes: &[u8]) -> ExiResult<Self> {
let mut d = Decoder::new(bytes);
d.read_header()?;
d.expect_event(Self::FRAGMENT_CODE, FRAGMENT_WIDTH)?;
let value = Self::decode_body(&mut d)?;
d.expect_event(FRAGMENT_ED_CODE, FRAGMENT_WIDTH)?;
d.finish()?;
Ok(value)
}
}
impl BPTACCPDResEnergyTransferMode {
pub const FRAGMENT_CODE: u64 = 10;
pub fn encode_fragment(&self, buf: &mut [u8]) -> ExiResult<usize> {
let mut e = Encoder::new(buf);
e.write_header(crate::exi::Header::ISO15118)?;
e.event(Self::FRAGMENT_CODE, FRAGMENT_WIDTH)?;
self.encode_body(&mut e)?;
e.event(FRAGMENT_ED_CODE, FRAGMENT_WIDTH)?;
e.finish()
}
pub fn to_fragment(&self) -> ExiResult<Vec<u8>> {
crate::exi::encode_growing(|buf| self.encode_fragment(buf))
}
pub fn from_fragment(bytes: &[u8]) -> ExiResult<Self> {
let mut d = Decoder::new(bytes);
d.read_header()?;
d.expect_event(Self::FRAGMENT_CODE, FRAGMENT_WIDTH)?;
let value = Self::decode_body(&mut d)?;
d.expect_event(FRAGMENT_ED_CODE, FRAGMENT_WIDTH)?;
d.finish()?;
Ok(value)
}
}
impl BPTDynamicACCLReqControlMode {
pub const FRAGMENT_CODE: u64 = 12;
pub fn encode_fragment(&self, buf: &mut [u8]) -> ExiResult<usize> {
let mut e = Encoder::new(buf);
e.write_header(crate::exi::Header::ISO15118)?;
e.event(Self::FRAGMENT_CODE, FRAGMENT_WIDTH)?;
self.encode_body(&mut e)?;
e.event(FRAGMENT_ED_CODE, FRAGMENT_WIDTH)?;
e.finish()
}
pub fn to_fragment(&self) -> ExiResult<Vec<u8>> {
crate::exi::encode_growing(|buf| self.encode_fragment(buf))
}
pub fn from_fragment(bytes: &[u8]) -> ExiResult<Self> {
let mut d = Decoder::new(bytes);
d.read_header()?;
d.expect_event(Self::FRAGMENT_CODE, FRAGMENT_WIDTH)?;
let value = Self::decode_body(&mut d)?;
d.expect_event(FRAGMENT_ED_CODE, FRAGMENT_WIDTH)?;
d.finish()?;
Ok(value)
}
}
impl BPTDynamicACCLResControlMode {
pub const FRAGMENT_CODE: u64 = 13;
pub fn encode_fragment(&self, buf: &mut [u8]) -> ExiResult<usize> {
let mut e = Encoder::new(buf);
e.write_header(crate::exi::Header::ISO15118)?;
e.event(Self::FRAGMENT_CODE, FRAGMENT_WIDTH)?;
self.encode_body(&mut e)?;
e.event(FRAGMENT_ED_CODE, FRAGMENT_WIDTH)?;
e.finish()
}
pub fn to_fragment(&self) -> ExiResult<Vec<u8>> {
crate::exi::encode_growing(|buf| self.encode_fragment(buf))
}
pub fn from_fragment(bytes: &[u8]) -> ExiResult<Self> {
let mut d = Decoder::new(bytes);
d.read_header()?;
d.expect_event(Self::FRAGMENT_CODE, FRAGMENT_WIDTH)?;
let value = Self::decode_body(&mut d)?;
d.expect_event(FRAGMENT_ED_CODE, FRAGMENT_WIDTH)?;
d.finish()?;
Ok(value)
}
}
impl BPTScheduledACCLReqControlMode {
pub const FRAGMENT_CODE: u64 = 15;
pub fn encode_fragment(&self, buf: &mut [u8]) -> ExiResult<usize> {
let mut e = Encoder::new(buf);
e.write_header(crate::exi::Header::ISO15118)?;
e.event(Self::FRAGMENT_CODE, FRAGMENT_WIDTH)?;
self.encode_body(&mut e)?;
e.event(FRAGMENT_ED_CODE, FRAGMENT_WIDTH)?;
e.finish()
}
pub fn to_fragment(&self) -> ExiResult<Vec<u8>> {
crate::exi::encode_growing(|buf| self.encode_fragment(buf))
}
pub fn from_fragment(bytes: &[u8]) -> ExiResult<Self> {
let mut d = Decoder::new(bytes);
d.read_header()?;
d.expect_event(Self::FRAGMENT_CODE, FRAGMENT_WIDTH)?;
let value = Self::decode_body(&mut d)?;
d.expect_event(FRAGMENT_ED_CODE, FRAGMENT_WIDTH)?;
d.finish()?;
Ok(value)
}
}
impl BPTScheduledACCLResControlMode {
pub const FRAGMENT_CODE: u64 = 16;
pub fn encode_fragment(&self, buf: &mut [u8]) -> ExiResult<usize> {
let mut e = Encoder::new(buf);
e.write_header(crate::exi::Header::ISO15118)?;
e.event(Self::FRAGMENT_CODE, FRAGMENT_WIDTH)?;
self.encode_body(&mut e)?;
e.event(FRAGMENT_ED_CODE, FRAGMENT_WIDTH)?;
e.finish()
}
pub fn to_fragment(&self) -> ExiResult<Vec<u8>> {
crate::exi::encode_growing(|buf| self.encode_fragment(buf))
}
pub fn from_fragment(bytes: &[u8]) -> ExiResult<Self> {
let mut d = Decoder::new(bytes);
d.read_header()?;
d.expect_event(Self::FRAGMENT_CODE, FRAGMENT_WIDTH)?;
let value = Self::decode_body(&mut d)?;
d.expect_event(FRAGMENT_ED_CODE, FRAGMENT_WIDTH)?;
d.finish()?;
Ok(value)
}
}
impl DynamicACCLReqControlMode {
pub const FRAGMENT_CODE: u64 = 30;
pub fn encode_fragment(&self, buf: &mut [u8]) -> ExiResult<usize> {
let mut e = Encoder::new(buf);
e.write_header(crate::exi::Header::ISO15118)?;
e.event(Self::FRAGMENT_CODE, FRAGMENT_WIDTH)?;
self.encode_body(&mut e)?;
e.event(FRAGMENT_ED_CODE, FRAGMENT_WIDTH)?;
e.finish()
}
pub fn to_fragment(&self) -> ExiResult<Vec<u8>> {
crate::exi::encode_growing(|buf| self.encode_fragment(buf))
}
pub fn from_fragment(bytes: &[u8]) -> ExiResult<Self> {
let mut d = Decoder::new(bytes);
d.read_header()?;
d.expect_event(Self::FRAGMENT_CODE, FRAGMENT_WIDTH)?;
let value = Self::decode_body(&mut d)?;
d.expect_event(FRAGMENT_ED_CODE, FRAGMENT_WIDTH)?;
d.finish()?;
Ok(value)
}
}
impl DynamicACCLResControlMode {
pub const FRAGMENT_CODE: u64 = 31;
pub fn encode_fragment(&self, buf: &mut [u8]) -> ExiResult<usize> {
let mut e = Encoder::new(buf);
e.write_header(crate::exi::Header::ISO15118)?;
e.event(Self::FRAGMENT_CODE, FRAGMENT_WIDTH)?;
self.encode_body(&mut e)?;
e.event(FRAGMENT_ED_CODE, FRAGMENT_WIDTH)?;
e.finish()
}
pub fn to_fragment(&self) -> ExiResult<Vec<u8>> {
crate::exi::encode_growing(|buf| self.encode_fragment(buf))
}
pub fn from_fragment(bytes: &[u8]) -> ExiResult<Self> {
let mut d = Decoder::new(bytes);
d.read_header()?;
d.expect_event(Self::FRAGMENT_CODE, FRAGMENT_WIDTH)?;
let value = Self::decode_body(&mut d)?;
d.expect_event(FRAGMENT_ED_CODE, FRAGMENT_WIDTH)?;
d.finish()?;
Ok(value)
}
}
impl ScheduledACCLReqControlMode {
pub const FRAGMENT_CODE: u64 = 126;
pub fn encode_fragment(&self, buf: &mut [u8]) -> ExiResult<usize> {
let mut e = Encoder::new(buf);
e.write_header(crate::exi::Header::ISO15118)?;
e.event(Self::FRAGMENT_CODE, FRAGMENT_WIDTH)?;
self.encode_body(&mut e)?;
e.event(FRAGMENT_ED_CODE, FRAGMENT_WIDTH)?;
e.finish()
}
pub fn to_fragment(&self) -> ExiResult<Vec<u8>> {
crate::exi::encode_growing(|buf| self.encode_fragment(buf))
}
pub fn from_fragment(bytes: &[u8]) -> ExiResult<Self> {
let mut d = Decoder::new(bytes);
d.read_header()?;
d.expect_event(Self::FRAGMENT_CODE, FRAGMENT_WIDTH)?;
let value = Self::decode_body(&mut d)?;
d.expect_event(FRAGMENT_ED_CODE, FRAGMENT_WIDTH)?;
d.finish()?;
Ok(value)
}
}
impl ScheduledACCLResControlMode {
pub const FRAGMENT_CODE: u64 = 127;
pub fn encode_fragment(&self, buf: &mut [u8]) -> ExiResult<usize> {
let mut e = Encoder::new(buf);
e.write_header(crate::exi::Header::ISO15118)?;
e.event(Self::FRAGMENT_CODE, FRAGMENT_WIDTH)?;
self.encode_body(&mut e)?;
e.event(FRAGMENT_ED_CODE, FRAGMENT_WIDTH)?;
e.finish()
}
pub fn to_fragment(&self) -> ExiResult<Vec<u8>> {
crate::exi::encode_growing(|buf| self.encode_fragment(buf))
}
pub fn from_fragment(bytes: &[u8]) -> ExiResult<Self> {
let mut d = Decoder::new(bytes);
d.read_header()?;
d.expect_event(Self::FRAGMENT_CODE, FRAGMENT_WIDTH)?;
let value = Self::decode_body(&mut d)?;
d.expect_event(FRAGMENT_ED_CODE, FRAGMENT_WIDTH)?;
d.finish()?;
Ok(value)
}
}