#![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_ACDP";
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ACDPConnectReq {
pub header: super::common::MessageHeader,
pub ev_electrical_charging_device_status: ElectricalChargingDeviceStatus,
}
impl ACDPConnectReq {
const SHAPE: Shape = Shape {
prod_before: &[0, 1, 2],
width: &[1, 1, 1],
repeat_width: &[0, 0],
min: &[1, 1],
max: &[1, 1],
};
}
impl ACDPConnectReq {
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.ev_electrical_charging_device_status;
w.start(e, 1, 0)?;
e.event(0, SIMPLE_WIDTH)?; e.nbit(item.as_index(), ElectricalChargingDeviceStatus::WIDTH)?;
e.event(0, SIMPLE_WIDTH)?; w.finish(1, 1);
}
w.end(e)?;
e.leave();
Ok(())
}
}
impl ACDPConnectReq {
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, .. } => {
d.expect_event(0, SIMPLE_WIDTH)?; let value = ElectricalChargingDeviceStatus::from_index(
d.nbit(ElectricalChargingDeviceStatus::WIDTH)?,
)?;
d.expect_event(0, SIMPLE_WIDTH)?; f_1 = Some(value);
}
Step::Item { .. } => return Err(ExiError::UnknownEventCode),
}
}
d.leave();
Ok(Self {
header: f_0.ok_or(ExiError::MissingElement)?,
ev_electrical_charging_device_status: f_1.ok_or(ExiError::MissingElement)?,
})
}
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ACDPConnectRes {
pub header: super::common::MessageHeader,
pub response_code: super::common::ResponseCode,
pub evse_processing: super::common::Processing,
pub evse_electrical_charging_device_status: ElectricalChargingDeviceStatus,
pub evse_mechanical_charging_device_status: MechanicalChargingDeviceStatus,
}
impl ACDPConnectRes {
const SHAPE: Shape = Shape {
prod_before: &[0, 1, 2, 3, 4, 5],
width: &[1, 1, 1, 1, 1, 1],
repeat_width: &[0, 0, 0, 0, 0],
min: &[1, 1, 1, 1, 1],
max: &[1, 1, 1, 1, 1],
};
}
impl ACDPConnectRes {
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.evse_processing;
w.start(e, 2, 0)?;
e.event(0, SIMPLE_WIDTH)?; e.nbit(item.as_index(), super::common::Processing::WIDTH)?;
e.event(0, SIMPLE_WIDTH)?; w.finish(2, 1);
}
{
let item = &self.evse_electrical_charging_device_status;
w.start(e, 3, 0)?;
e.event(0, SIMPLE_WIDTH)?; e.nbit(item.as_index(), ElectricalChargingDeviceStatus::WIDTH)?;
e.event(0, SIMPLE_WIDTH)?; w.finish(3, 1);
}
{
let item = &self.evse_mechanical_charging_device_status;
w.start(e, 4, 0)?;
e.event(0, SIMPLE_WIDTH)?; e.nbit(item.as_index(), MechanicalChargingDeviceStatus::WIDTH)?;
e.event(0, SIMPLE_WIDTH)?; w.finish(4, 1);
}
w.end(e)?;
e.leave();
Ok(())
}
}
impl ACDPConnectRes {
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;
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, .. } => {
d.expect_event(0, SIMPLE_WIDTH)?; let value = super::common::Processing::from_index(
d.nbit(super::common::Processing::WIDTH)?,
)?;
d.expect_event(0, SIMPLE_WIDTH)?; f_2 = Some(value);
}
Step::Item { index: 3, .. } => {
d.expect_event(0, SIMPLE_WIDTH)?; let value = ElectricalChargingDeviceStatus::from_index(
d.nbit(ElectricalChargingDeviceStatus::WIDTH)?,
)?;
d.expect_event(0, SIMPLE_WIDTH)?; f_3 = Some(value);
}
Step::Item { index: 4, .. } => {
d.expect_event(0, SIMPLE_WIDTH)?; let value = MechanicalChargingDeviceStatus::from_index(
d.nbit(MechanicalChargingDeviceStatus::WIDTH)?,
)?;
d.expect_event(0, SIMPLE_WIDTH)?; f_4 = 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_processing: f_2.ok_or(ExiError::MissingElement)?,
evse_electrical_charging_device_status: f_3.ok_or(ExiError::MissingElement)?,
evse_mechanical_charging_device_status: f_4.ok_or(ExiError::MissingElement)?,
})
}
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ACDPSystemStatusReq {
pub header: super::common::MessageHeader,
pub ev_technical_status: EVTechnicalStatus,
}
impl ACDPSystemStatusReq {
const SHAPE: Shape = Shape {
prod_before: &[0, 1, 2],
width: &[1, 1, 1],
repeat_width: &[0, 0],
min: &[1, 1],
max: &[1, 1],
};
}
impl ACDPSystemStatusReq {
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.ev_technical_status;
w.start(e, 1, 0)?;
item.encode_body(e)?;
w.finish(1, 1);
}
w.end(e)?;
e.leave();
Ok(())
}
}
impl ACDPSystemStatusReq {
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, .. } => {
let value = EVTechnicalStatus::decode_body(d)?;
f_1 = Some(value);
}
Step::Item { .. } => return Err(ExiError::UnknownEventCode),
}
}
d.leave();
Ok(Self {
header: f_0.ok_or(ExiError::MissingElement)?,
ev_technical_status: f_1.ok_or(ExiError::MissingElement)?,
})
}
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ACDPSystemStatusRes {
pub header: super::common::MessageHeader,
pub response_code: super::common::ResponseCode,
pub evse_mechanical_charging_device_status: MechanicalChargingDeviceStatus,
pub evse_ready_to_charge: bool,
pub evse_isolation_status: IsolationStatus,
pub evse_disabled: bool,
pub evse_utility_interrupt_event: bool,
pub evse_emergency_shutdown: bool,
pub evse_malfunction: bool,
pub ev_in_charge_position: bool,
pub ev_association_status: bool,
}
impl ACDPSystemStatusRes {
const SHAPE: Shape = Shape {
prod_before: &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
width: &[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
repeat_width: &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
min: &[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
max: &[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
};
}
impl ACDPSystemStatusRes {
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.evse_mechanical_charging_device_status;
w.start(e, 2, 0)?;
e.event(0, SIMPLE_WIDTH)?; e.nbit(item.as_index(), MechanicalChargingDeviceStatus::WIDTH)?;
e.event(0, SIMPLE_WIDTH)?; w.finish(2, 1);
}
{
let item = &self.evse_ready_to_charge;
w.start(e, 3, 0)?;
e.event(0, SIMPLE_WIDTH)?; e.boolean(*item)?;
e.event(0, SIMPLE_WIDTH)?; w.finish(3, 1);
}
{
let item = &self.evse_isolation_status;
w.start(e, 4, 0)?;
e.event(0, SIMPLE_WIDTH)?; e.nbit(item.as_index(), IsolationStatus::WIDTH)?;
e.event(0, SIMPLE_WIDTH)?; w.finish(4, 1);
}
{
let item = &self.evse_disabled;
w.start(e, 5, 0)?;
e.event(0, SIMPLE_WIDTH)?; e.boolean(*item)?;
e.event(0, SIMPLE_WIDTH)?; w.finish(5, 1);
}
{
let item = &self.evse_utility_interrupt_event;
w.start(e, 6, 0)?;
e.event(0, SIMPLE_WIDTH)?; e.boolean(*item)?;
e.event(0, SIMPLE_WIDTH)?; w.finish(6, 1);
}
{
let item = &self.evse_emergency_shutdown;
w.start(e, 7, 0)?;
e.event(0, SIMPLE_WIDTH)?; e.boolean(*item)?;
e.event(0, SIMPLE_WIDTH)?; w.finish(7, 1);
}
{
let item = &self.evse_malfunction;
w.start(e, 8, 0)?;
e.event(0, SIMPLE_WIDTH)?; e.boolean(*item)?;
e.event(0, SIMPLE_WIDTH)?; w.finish(8, 1);
}
{
let item = &self.ev_in_charge_position;
w.start(e, 9, 0)?;
e.event(0, SIMPLE_WIDTH)?; e.boolean(*item)?;
e.event(0, SIMPLE_WIDTH)?; w.finish(9, 1);
}
{
let item = &self.ev_association_status;
w.start(e, 10, 0)?;
e.event(0, SIMPLE_WIDTH)?; e.boolean(*item)?;
e.event(0, SIMPLE_WIDTH)?; w.finish(10, 1);
}
w.end(e)?;
e.leave();
Ok(())
}
}
impl ACDPSystemStatusRes {
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;
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, .. } => {
d.expect_event(0, SIMPLE_WIDTH)?; let value = MechanicalChargingDeviceStatus::from_index(
d.nbit(MechanicalChargingDeviceStatus::WIDTH)?,
)?;
d.expect_event(0, SIMPLE_WIDTH)?; f_2 = Some(value);
}
Step::Item { index: 3, .. } => {
d.expect_event(0, SIMPLE_WIDTH)?; let value = d.boolean()?;
d.expect_event(0, SIMPLE_WIDTH)?; f_3 = Some(value);
}
Step::Item { index: 4, .. } => {
d.expect_event(0, SIMPLE_WIDTH)?; let value = IsolationStatus::from_index(d.nbit(IsolationStatus::WIDTH)?)?;
d.expect_event(0, SIMPLE_WIDTH)?; f_4 = Some(value);
}
Step::Item { index: 5, .. } => {
d.expect_event(0, SIMPLE_WIDTH)?; let value = d.boolean()?;
d.expect_event(0, SIMPLE_WIDTH)?; f_5 = Some(value);
}
Step::Item { index: 6, .. } => {
d.expect_event(0, SIMPLE_WIDTH)?; let value = d.boolean()?;
d.expect_event(0, SIMPLE_WIDTH)?; f_6 = Some(value);
}
Step::Item { index: 7, .. } => {
d.expect_event(0, SIMPLE_WIDTH)?; let value = d.boolean()?;
d.expect_event(0, SIMPLE_WIDTH)?; f_7 = Some(value);
}
Step::Item { index: 8, .. } => {
d.expect_event(0, SIMPLE_WIDTH)?; let value = d.boolean()?;
d.expect_event(0, SIMPLE_WIDTH)?; f_8 = Some(value);
}
Step::Item { index: 9, .. } => {
d.expect_event(0, SIMPLE_WIDTH)?; let value = d.boolean()?;
d.expect_event(0, SIMPLE_WIDTH)?; f_9 = Some(value);
}
Step::Item { index: 10, .. } => {
d.expect_event(0, SIMPLE_WIDTH)?; let value = d.boolean()?;
d.expect_event(0, SIMPLE_WIDTH)?; f_10 = 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_mechanical_charging_device_status: f_2.ok_or(ExiError::MissingElement)?,
evse_ready_to_charge: f_3.ok_or(ExiError::MissingElement)?,
evse_isolation_status: f_4.ok_or(ExiError::MissingElement)?,
evse_disabled: f_5.ok_or(ExiError::MissingElement)?,
evse_utility_interrupt_event: f_6.ok_or(ExiError::MissingElement)?,
evse_emergency_shutdown: f_7.ok_or(ExiError::MissingElement)?,
evse_malfunction: f_8.ok_or(ExiError::MissingElement)?,
ev_in_charge_position: f_9.ok_or(ExiError::MissingElement)?,
ev_association_status: f_10.ok_or(ExiError::MissingElement)?,
})
}
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ACDPVehiclePositioningReq {
pub header: super::common::MessageHeader,
pub ev_mobility_status: bool,
pub ev_positioning_support: bool,
}
impl ACDPVehiclePositioningReq {
const SHAPE: Shape = Shape {
prod_before: &[0, 1, 2, 3],
width: &[1, 1, 1, 1],
repeat_width: &[0, 0, 0],
min: &[1, 1, 1],
max: &[1, 1, 1],
};
}
impl ACDPVehiclePositioningReq {
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.ev_mobility_status;
w.start(e, 1, 0)?;
e.event(0, SIMPLE_WIDTH)?; e.boolean(*item)?;
e.event(0, SIMPLE_WIDTH)?; w.finish(1, 1);
}
{
let item = &self.ev_positioning_support;
w.start(e, 2, 0)?;
e.event(0, SIMPLE_WIDTH)?; e.boolean(*item)?;
e.event(0, SIMPLE_WIDTH)?; w.finish(2, 1);
}
w.end(e)?;
e.leave();
Ok(())
}
}
impl ACDPVehiclePositioningReq {
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 = d.boolean()?;
d.expect_event(0, SIMPLE_WIDTH)?; 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 { .. } => return Err(ExiError::UnknownEventCode),
}
}
d.leave();
Ok(Self {
header: f_0.ok_or(ExiError::MissingElement)?,
ev_mobility_status: f_1.ok_or(ExiError::MissingElement)?,
ev_positioning_support: f_2.ok_or(ExiError::MissingElement)?,
})
}
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ACDPVehiclePositioningRes {
pub header: super::common::MessageHeader,
pub response_code: super::common::ResponseCode,
pub evse_processing: super::common::Processing,
pub evse_positioning_support: bool,
pub ev_relative_x_deviation: i16,
pub ev_relative_y_deviation: i16,
pub contact_window_xc: i16,
pub contact_window_yc: i16,
pub ev_in_charge_position: bool,
}
impl ACDPVehiclePositioningRes {
const SHAPE: Shape = Shape {
prod_before: &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
width: &[1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
repeat_width: &[0, 0, 0, 0, 0, 0, 0, 0, 0],
min: &[1, 1, 1, 1, 1, 1, 1, 1, 1],
max: &[1, 1, 1, 1, 1, 1, 1, 1, 1],
};
}
impl ACDPVehiclePositioningRes {
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.evse_processing;
w.start(e, 2, 0)?;
e.event(0, SIMPLE_WIDTH)?; e.nbit(item.as_index(), super::common::Processing::WIDTH)?;
e.event(0, SIMPLE_WIDTH)?; w.finish(2, 1);
}
{
let item = &self.evse_positioning_support;
w.start(e, 3, 0)?;
e.event(0, SIMPLE_WIDTH)?; e.boolean(*item)?;
e.event(0, SIMPLE_WIDTH)?; w.finish(3, 1);
}
{
let item = &self.ev_relative_x_deviation;
w.start(e, 4, 0)?;
e.event(0, SIMPLE_WIDTH)?; e.int(i64::from(*item))?;
e.event(0, SIMPLE_WIDTH)?; w.finish(4, 1);
}
{
let item = &self.ev_relative_y_deviation;
w.start(e, 5, 0)?;
e.event(0, SIMPLE_WIDTH)?; e.int(i64::from(*item))?;
e.event(0, SIMPLE_WIDTH)?; w.finish(5, 1);
}
{
let item = &self.contact_window_xc;
w.start(e, 6, 0)?;
e.event(0, SIMPLE_WIDTH)?; e.int(i64::from(*item))?;
e.event(0, SIMPLE_WIDTH)?; w.finish(6, 1);
}
{
let item = &self.contact_window_yc;
w.start(e, 7, 0)?;
e.event(0, SIMPLE_WIDTH)?; e.int(i64::from(*item))?;
e.event(0, SIMPLE_WIDTH)?; w.finish(7, 1);
}
{
let item = &self.ev_in_charge_position;
w.start(e, 8, 0)?;
e.event(0, SIMPLE_WIDTH)?; e.boolean(*item)?;
e.event(0, SIMPLE_WIDTH)?; w.finish(8, 1);
}
w.end(e)?;
e.leave();
Ok(())
}
}
impl ACDPVehiclePositioningRes {
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::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, .. } => {
d.expect_event(0, SIMPLE_WIDTH)?; let value = super::common::Processing::from_index(
d.nbit(super::common::Processing::WIDTH)?,
)?;
d.expect_event(0, SIMPLE_WIDTH)?; f_2 = Some(value);
}
Step::Item { index: 3, .. } => {
d.expect_event(0, SIMPLE_WIDTH)?; let value = d.boolean()?;
d.expect_event(0, SIMPLE_WIDTH)?; f_3 = Some(value);
}
Step::Item { index: 4, .. } => {
d.expect_event(0, SIMPLE_WIDTH)?; let value = i16::try_from(d.int()?).map_err(|_| ExiError::IntegerOverflow)?;
d.expect_event(0, SIMPLE_WIDTH)?; f_4 = Some(value);
}
Step::Item { index: 5, .. } => {
d.expect_event(0, SIMPLE_WIDTH)?; let value = i16::try_from(d.int()?).map_err(|_| ExiError::IntegerOverflow)?;
d.expect_event(0, SIMPLE_WIDTH)?; f_5 = Some(value);
}
Step::Item { index: 6, .. } => {
d.expect_event(0, SIMPLE_WIDTH)?; let value = i16::try_from(d.int()?).map_err(|_| ExiError::IntegerOverflow)?;
d.expect_event(0, SIMPLE_WIDTH)?; f_6 = Some(value);
}
Step::Item { index: 7, .. } => {
d.expect_event(0, SIMPLE_WIDTH)?; let value = i16::try_from(d.int()?).map_err(|_| ExiError::IntegerOverflow)?;
d.expect_event(0, SIMPLE_WIDTH)?; f_7 = Some(value);
}
Step::Item { index: 8, .. } => {
d.expect_event(0, SIMPLE_WIDTH)?; let value = d.boolean()?;
d.expect_event(0, SIMPLE_WIDTH)?; f_8 = 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_processing: f_2.ok_or(ExiError::MissingElement)?,
evse_positioning_support: f_3.ok_or(ExiError::MissingElement)?,
ev_relative_x_deviation: f_4.ok_or(ExiError::MissingElement)?,
ev_relative_y_deviation: f_5.ok_or(ExiError::MissingElement)?,
contact_window_xc: f_6.ok_or(ExiError::MissingElement)?,
contact_window_yc: f_7.ok_or(ExiError::MissingElement)?,
ev_in_charge_position: f_8.ok_or(ExiError::MissingElement)?,
})
}
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct EVTechnicalStatus {
pub ev_ready_to_charge: bool,
pub ev_immobilization_request: bool,
pub ev_immobilized: Option<bool>,
pub ev_wlan_strength: Option<super::common::RationalNumber>,
pub ev_cp_status: Option<CpStatus>,
pub ev_soc: Option<u8>,
pub ev_error_code: Option<ErrorCode>,
pub ev_timeout: Option<bool>,
}
impl EVTechnicalStatus {
const SHAPE: Shape = Shape {
prod_before: &[0, 1, 2, 3, 4, 5, 6, 7, 8],
width: &[1, 1, 3, 3, 3, 3, 2, 2, 1],
repeat_width: &[0, 0, 0, 0, 0, 0, 0, 0],
min: &[1, 1, 0, 0, 0, 0, 0, 0],
max: &[1, 1, 1, 1, 1, 1, 1, 1],
};
}
impl EVTechnicalStatus {
pub fn encode_body(&self, e: &mut Encoder<'_>) -> ExiResult<()> {
e.enter()?;
let mut w = SeqWriter::new(Self::SHAPE);
{
let item = &self.ev_ready_to_charge;
w.start(e, 0, 0)?;
e.event(0, SIMPLE_WIDTH)?; e.boolean(*item)?;
e.event(0, SIMPLE_WIDTH)?; w.finish(0, 1);
}
{
let item = &self.ev_immobilization_request;
w.start(e, 1, 0)?;
e.event(0, SIMPLE_WIDTH)?; e.boolean(*item)?;
e.event(0, SIMPLE_WIDTH)?; w.finish(1, 1);
}
if let Some(item) = &self.ev_immobilized {
w.start(e, 2, 0)?;
e.event(0, SIMPLE_WIDTH)?; e.boolean(*item)?;
e.event(0, SIMPLE_WIDTH)?; w.finish(2, 1);
}
if let Some(item) = &self.ev_wlan_strength {
w.start(e, 3, 0)?;
item.encode_body(e)?;
w.finish(3, 1);
}
if let Some(item) = &self.ev_cp_status {
w.start(e, 4, 0)?;
e.event(0, SIMPLE_WIDTH)?; e.nbit(item.as_index(), CpStatus::WIDTH)?;
e.event(0, SIMPLE_WIDTH)?; w.finish(4, 1);
}
if let Some(item) = &self.ev_soc {
w.start(e, 5, 0)?;
e.event(0, SIMPLE_WIDTH)?; e.restricted(i64::from(*item), 0, 100)?;
e.event(0, SIMPLE_WIDTH)?; w.finish(5, 1);
}
if let Some(item) = &self.ev_error_code {
w.start(e, 6, 0)?;
e.event(0, SIMPLE_WIDTH)?; e.nbit(item.as_index(), ErrorCode::WIDTH)?;
e.event(0, SIMPLE_WIDTH)?; w.finish(6, 1);
}
if let Some(item) = &self.ev_timeout {
w.start(e, 7, 0)?;
e.event(0, SIMPLE_WIDTH)?; e.boolean(*item)?;
e.event(0, SIMPLE_WIDTH)?; w.finish(7, 1);
}
w.end(e)?;
e.leave();
Ok(())
}
}
impl EVTechnicalStatus {
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;
loop {
match r.next(d)? {
Step::End => break,
Step::Item { index: 0, .. } => {
d.expect_event(0, SIMPLE_WIDTH)?; let value = d.boolean()?;
d.expect_event(0, SIMPLE_WIDTH)?; f_0 = Some(value);
}
Step::Item { index: 1, .. } => {
d.expect_event(0, SIMPLE_WIDTH)?; let value = d.boolean()?;
d.expect_event(0, SIMPLE_WIDTH)?; 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, .. } => {
let value = super::common::RationalNumber::decode_body(d)?;
f_3 = Some(value);
}
Step::Item { index: 4, .. } => {
d.expect_event(0, SIMPLE_WIDTH)?; let value = CpStatus::from_index(d.nbit(CpStatus::WIDTH)?)?;
d.expect_event(0, SIMPLE_WIDTH)?; f_4 = Some(value);
}
Step::Item { index: 5, .. } => {
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_5 = Some(value);
}
Step::Item { index: 6, .. } => {
d.expect_event(0, SIMPLE_WIDTH)?; let value = ErrorCode::from_index(d.nbit(ErrorCode::WIDTH)?)?;
d.expect_event(0, SIMPLE_WIDTH)?; f_6 = Some(value);
}
Step::Item { index: 7, .. } => {
d.expect_event(0, SIMPLE_WIDTH)?; let value = d.boolean()?;
d.expect_event(0, SIMPLE_WIDTH)?; f_7 = Some(value);
}
Step::Item { .. } => return Err(ExiError::UnknownEventCode),
}
}
d.leave();
Ok(Self {
ev_ready_to_charge: f_0.ok_or(ExiError::MissingElement)?,
ev_immobilization_request: f_1.ok_or(ExiError::MissingElement)?,
ev_immobilized: f_2,
ev_wlan_strength: f_3,
ev_cp_status: f_4,
ev_soc: f_5,
ev_error_code: f_6,
ev_timeout: f_7,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[repr(u16)]
pub enum CpStatus {
StateA = 0,
StateB = 1,
StateC = 2,
StateD = 3,
StateE = 4,
}
impl CpStatus {
pub const WIDTH: u32 = 3;
pub const ALL: [Self; 5] =
[Self::StateA, Self::StateB, Self::StateC, Self::StateD, Self::StateE];
#[must_use]
pub const fn as_index(self) -> u64 {
self as u64
}
pub const fn from_index(index: u64) -> ExiResult<Self> {
Ok(match index {
0 => Self::StateA,
1 => Self::StateB,
2 => Self::StateC,
3 => Self::StateD,
4 => Self::StateE,
_ => return Err(ExiError::UnknownEnumValue),
})
}
#[must_use]
pub const fn as_str(self) -> &'static str {
match self {
Self::StateA => "StateA",
Self::StateB => "StateB",
Self::StateC => "StateC",
Self::StateD => "StateD",
Self::StateE => "StateE",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[repr(u16)]
pub enum ElectricalChargingDeviceStatus {
StateA = 0,
StateB = 1,
StateC = 2,
StateD = 3,
}
impl ElectricalChargingDeviceStatus {
pub const WIDTH: u32 = 2;
pub const ALL: [Self; 4] = [Self::StateA, Self::StateB, Self::StateC, Self::StateD];
#[must_use]
pub const fn as_index(self) -> u64 {
self as u64
}
pub const fn from_index(index: u64) -> ExiResult<Self> {
Ok(match index {
0 => Self::StateA,
1 => Self::StateB,
2 => Self::StateC,
3 => Self::StateD,
_ => return Err(ExiError::UnknownEnumValue),
})
}
#[must_use]
pub const fn as_str(self) -> &'static str {
match self {
Self::StateA => "State_A",
Self::StateB => "State_B",
Self::StateC => "State_C",
Self::StateD => "State_D",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[repr(u16)]
pub enum ErrorCode {
OKNoEVError = 0,
FAILED = 1,
FAILEDEmergencyEvent = 2,
FAILEDBreaker = 3,
FAILEDRESSTemperatureInhibit = 4,
FAILEDRESS = 5,
FAILEDChargingCurrentDifferential = 6,
FAILEDChargingVoltageOutOfRange = 7,
FAILEDReserved1 = 8,
FAILEDReserved2 = 9,
}
impl ErrorCode {
pub const WIDTH: u32 = 4;
pub const ALL: [Self; 10] = [
Self::OKNoEVError,
Self::FAILED,
Self::FAILEDEmergencyEvent,
Self::FAILEDBreaker,
Self::FAILEDRESSTemperatureInhibit,
Self::FAILEDRESS,
Self::FAILEDChargingCurrentDifferential,
Self::FAILEDChargingVoltageOutOfRange,
Self::FAILEDReserved1,
Self::FAILEDReserved2,
];
#[must_use]
pub const fn as_index(self) -> u64 {
self as u64
}
pub const fn from_index(index: u64) -> ExiResult<Self> {
Ok(match index {
0 => Self::OKNoEVError,
1 => Self::FAILED,
2 => Self::FAILEDEmergencyEvent,
3 => Self::FAILEDBreaker,
4 => Self::FAILEDRESSTemperatureInhibit,
5 => Self::FAILEDRESS,
6 => Self::FAILEDChargingCurrentDifferential,
7 => Self::FAILEDChargingVoltageOutOfRange,
8 => Self::FAILEDReserved1,
9 => Self::FAILEDReserved2,
_ => return Err(ExiError::UnknownEnumValue),
})
}
#[must_use]
pub const fn as_str(self) -> &'static str {
match self {
Self::OKNoEVError => "OK_NoEVError",
Self::FAILED => "FAILED",
Self::FAILEDEmergencyEvent => "FAILED_EmergencyEvent",
Self::FAILEDBreaker => "FAILED_Breaker",
Self::FAILEDRESSTemperatureInhibit => "FAILED_RESSTemperatureInhibit",
Self::FAILEDRESS => "FAILED_RESS",
Self::FAILEDChargingCurrentDifferential => "FAILED_ChargingCurrentDifferential",
Self::FAILEDChargingVoltageOutOfRange => "FAILED_ChargingVoltageOutOfRange",
Self::FAILEDReserved1 => "FAILED_Reserved1",
Self::FAILEDReserved2 => "FAILED_Reserved2",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[repr(u16)]
pub enum IsolationStatus {
Invalid = 0,
Safe = 1,
Warning = 2,
Fault = 3,
}
impl IsolationStatus {
pub const WIDTH: u32 = 2;
pub const ALL: [Self; 4] = [Self::Invalid, Self::Safe, Self::Warning, Self::Fault];
#[must_use]
pub const fn as_index(self) -> u64 {
self as u64
}
pub const fn from_index(index: u64) -> ExiResult<Self> {
Ok(match index {
0 => Self::Invalid,
1 => Self::Safe,
2 => Self::Warning,
3 => Self::Fault,
_ => return Err(ExiError::UnknownEnumValue),
})
}
#[must_use]
pub const fn as_str(self) -> &'static str {
match self {
Self::Invalid => "Invalid",
Self::Safe => "Safe",
Self::Warning => "Warning",
Self::Fault => "Fault",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[repr(u16)]
pub enum MechanicalChargingDeviceStatus {
Home = 0,
Moving = 1,
EndPosition = 2,
}
impl MechanicalChargingDeviceStatus {
pub const WIDTH: u32 = 2;
pub const ALL: [Self; 3] = [Self::Home, Self::Moving, Self::EndPosition];
#[must_use]
pub const fn as_index(self) -> u64 {
self as u64
}
pub const fn from_index(index: u64) -> ExiResult<Self> {
Ok(match index {
0 => Self::Home,
1 => Self::Moving,
2 => Self::EndPosition,
_ => return Err(ExiError::UnknownEnumValue),
})
}
#[must_use]
pub const fn as_str(self) -> &'static str {
match self {
Self::Home => "Home",
Self::Moving => "Moving",
Self::EndPosition => "EndPosition",
}
}
}
pub const DOCUMENT_WIDTH: u32 = 6;
pub const FRAGMENT_WIDTH: u32 = 8;
pub const FRAGMENT_ED_CODE: u64 = 130;
pub const XMLDSIG_FRAGMENT_WIDTH: u32 = 6;
pub const XMLDSIG_FRAGMENT_ED_CODE: u64 = 46;
impl ACDPSystemStatusReq {
pub const DOCUMENT_CODE: u64 = 4;
}
impl crate::exi::ExiDocument for ACDPSystemStatusReq {
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 ACDPSystemStatusRes {
pub const DOCUMENT_CODE: u64 = 5;
}
impl crate::exi::ExiDocument for ACDPSystemStatusRes {
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 ACDPVehiclePositioningReq {
pub const DOCUMENT_CODE: u64 = 6;
}
impl crate::exi::ExiDocument for ACDPVehiclePositioningReq {
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 ACDPVehiclePositioningRes {
pub const DOCUMENT_CODE: u64 = 7;
}
impl crate::exi::ExiDocument for ACDPVehiclePositioningRes {
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 {
ACDPConnectReq(ACDPConnectReq),
ACDPConnectRes(ACDPConnectRes),
ACDPDisconnectReq(ACDPConnectReq),
ACDPDisconnectRes(ACDPConnectRes),
ACDPSystemStatusReq(ACDPSystemStatusReq),
ACDPSystemStatusRes(ACDPSystemStatusRes),
ACDPVehiclePositioningReq(ACDPVehiclePositioningReq),
ACDPVehiclePositioningRes(ACDPVehiclePositioningRes),
}
impl Document {
#[must_use]
pub const fn name(&self) -> &'static str {
match self {
Self::ACDPConnectReq(_) => "ACDP_ConnectReq",
Self::ACDPConnectRes(_) => "ACDP_ConnectRes",
Self::ACDPDisconnectReq(_) => "ACDP_DisconnectReq",
Self::ACDPDisconnectRes(_) => "ACDP_DisconnectRes",
Self::ACDPSystemStatusReq(_) => "ACDP_SystemStatusReq",
Self::ACDPSystemStatusRes(_) => "ACDP_SystemStatusRes",
Self::ACDPVehiclePositioningReq(_) => "ACDP_VehiclePositioningReq",
Self::ACDPVehiclePositioningRes(_) => "ACDP_VehiclePositioningRes",
}
}
#[must_use]
pub const fn code(&self) -> u64 {
match self {
Self::ACDPConnectReq(_) => 0,
Self::ACDPConnectRes(_) => 1,
Self::ACDPDisconnectReq(_) => 2,
Self::ACDPDisconnectRes(_) => 3,
Self::ACDPSystemStatusReq(_) => 4,
Self::ACDPSystemStatusRes(_) => 5,
Self::ACDPVehiclePositioningReq(_) => 6,
Self::ACDPVehiclePositioningRes(_) => 7,
}
}
}
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::ACDPConnectReq(m) => m.encode_body(&mut e)?,
Self::ACDPConnectRes(m) => m.encode_body(&mut e)?,
Self::ACDPDisconnectReq(m) => m.encode_body(&mut e)?,
Self::ACDPDisconnectRes(m) => m.encode_body(&mut e)?,
Self::ACDPSystemStatusReq(m) => m.encode_body(&mut e)?,
Self::ACDPSystemStatusRes(m) => m.encode_body(&mut e)?,
Self::ACDPVehiclePositioningReq(m) => m.encode_body(&mut e)?,
Self::ACDPVehiclePositioningRes(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::ACDPConnectReq(ACDPConnectReq::decode_body(&mut d)?),
1 => Self::ACDPConnectRes(ACDPConnectRes::decode_body(&mut d)?),
2 => Self::ACDPDisconnectReq(ACDPConnectReq::decode_body(&mut d)?),
3 => Self::ACDPDisconnectRes(ACDPConnectRes::decode_body(&mut d)?),
4 => Self::ACDPSystemStatusReq(ACDPSystemStatusReq::decode_body(&mut d)?),
5 => Self::ACDPSystemStatusRes(ACDPSystemStatusRes::decode_body(&mut d)?),
6 => Self::ACDPVehiclePositioningReq(ACDPVehiclePositioningReq::decode_body(&mut d)?),
7 => Self::ACDPVehiclePositioningRes(ACDPVehiclePositioningRes::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::ACDPConnectReq(m) => Some(&m.header),
Self::ACDPConnectRes(m) => Some(&m.header),
Self::ACDPDisconnectReq(m) => Some(&m.header),
Self::ACDPDisconnectRes(m) => Some(&m.header),
Self::ACDPSystemStatusReq(m) => Some(&m.header),
Self::ACDPSystemStatusRes(m) => Some(&m.header),
Self::ACDPVehiclePositioningReq(m) => Some(&m.header),
Self::ACDPVehiclePositioningRes(m) => Some(&m.header),
}
}
pub const fn header_mut(&mut self) -> Option<&mut super::common::MessageHeader> {
match self {
Self::ACDPConnectReq(m) => Some(&mut m.header),
Self::ACDPConnectRes(m) => Some(&mut m.header),
Self::ACDPDisconnectReq(m) => Some(&mut m.header),
Self::ACDPDisconnectRes(m) => Some(&mut m.header),
Self::ACDPSystemStatusReq(m) => Some(&mut m.header),
Self::ACDPSystemStatusRes(m) => Some(&mut m.header),
Self::ACDPVehiclePositioningReq(m) => Some(&mut m.header),
Self::ACDPVehiclePositioningRes(m) => Some(&mut m.header),
}
}
}
impl Document {
#[must_use]
pub const fn response_code(&self) -> Option<super::common::ResponseCode> {
match self {
Self::ACDPConnectRes(m) => Some(m.response_code),
Self::ACDPDisconnectRes(m) => Some(m.response_code),
Self::ACDPSystemStatusRes(m) => Some(m.response_code),
Self::ACDPVehiclePositioningRes(m) => Some(m.response_code),
_ => None,
}
}
}
impl Document {
#[must_use]
pub const fn fragment_code(&self) -> u64 {
match self {
Self::ACDPConnectReq(_) => 0,
Self::ACDPConnectRes(_) => 1,
Self::ACDPDisconnectReq(_) => 2,
Self::ACDPDisconnectRes(_) => 3,
Self::ACDPSystemStatusReq(_) => 4,
Self::ACDPSystemStatusRes(_) => 5,
Self::ACDPVehiclePositioningReq(_) => 6,
Self::ACDPVehiclePositioningRes(_) => 7,
}
}
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::ACDPConnectReq(m) => m.encode_body(&mut e)?,
Self::ACDPConnectRes(m) => m.encode_body(&mut e)?,
Self::ACDPDisconnectReq(m) => m.encode_body(&mut e)?,
Self::ACDPDisconnectRes(m) => m.encode_body(&mut e)?,
Self::ACDPSystemStatusReq(m) => m.encode_body(&mut e)?,
Self::ACDPSystemStatusRes(m) => m.encode_body(&mut e)?,
Self::ACDPVehiclePositioningReq(m) => m.encode_body(&mut e)?,
Self::ACDPVehiclePositioningRes(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::ACDPConnectReq(ACDPConnectReq::decode_body(&mut d)?),
1 => Self::ACDPConnectRes(ACDPConnectRes::decode_body(&mut d)?),
2 => Self::ACDPDisconnectReq(ACDPConnectReq::decode_body(&mut d)?),
3 => Self::ACDPDisconnectRes(ACDPConnectRes::decode_body(&mut d)?),
4 => Self::ACDPSystemStatusReq(ACDPSystemStatusReq::decode_body(&mut d)?),
5 => Self::ACDPSystemStatusRes(ACDPSystemStatusRes::decode_body(&mut d)?),
6 => Self::ACDPVehiclePositioningReq(ACDPVehiclePositioningReq::decode_body(&mut d)?),
7 => Self::ACDPVehiclePositioningRes(ACDPVehiclePositioningRes::decode_body(&mut d)?),
_ => return Err(ExiError::UnknownEventCode),
};
d.expect_event(FRAGMENT_ED_CODE, FRAGMENT_WIDTH)?;
d.finish()?;
Ok(value)
}
}
impl ACDPSystemStatusReq {
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 ACDPSystemStatusRes {
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 ACDPVehiclePositioningReq {
pub const FRAGMENT_CODE: u64 = 6;
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 ACDPVehiclePositioningRes {
pub const FRAGMENT_CODE: u64 = 7;
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 EVTechnicalStatus {
pub const FRAGMENT_CODE: u64 = 56;
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)
}
}