pub type Model709 = DerTripLf;
struct Counts {
n_pt: u16,
n_crv_set: u16,
}
#[derive(Debug)]
#[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
pub struct DerTripLf {
pub ena: Ena,
pub adpt_crv_req: u16,
pub adpt_crv_rslt: AdptCrvRslt,
pub n_pt: u16,
pub n_crv_set: u16,
pub hz_sf: i16,
pub tms_sf: i16,
pub crv: Vec<Crv>,
}
#[allow(missing_docs)]
impl DerTripLf {
pub const ENA: crate::Point<Self, Ena> = crate::Point::new(0, 1, true);
pub const ADPT_CRV_REQ: crate::Point<Self, u16> = crate::Point::new(1, 1, true);
pub const ADPT_CRV_RSLT: crate::Point<Self, AdptCrvRslt> = crate::Point::new(2, 1, false);
pub const N_PT: crate::Point<Self, u16> = crate::Point::new(3, 1, false);
pub const N_CRV_SET: crate::Point<Self, u16> = crate::Point::new(4, 1, false);
pub const HZ_SF: crate::Point<Self, i16> = crate::Point::new(5, 1, false);
pub const TMS_SF: crate::Point<Self, i16> = crate::Point::new(6, 1, false);
}
impl crate::Group for DerTripLf {
const LEN: u16 = 7;
}
impl DerTripLf {
fn parse_group(data: &[u16]) -> Result<(&[u16], Self), crate::DecodeError> {
let nested_data = data
.get(usize::from(<Self as crate::Group>::LEN)..)
.unwrap_or(&[]);
let counts = Counts {
n_pt: Self::N_PT.from_data(data)?,
n_crv_set: Self::N_CRV_SET.from_data(data)?,
};
let (nested_data, crv) = Crv::parse_multiple(nested_data, &counts)?;
Ok((
nested_data,
Self {
ena: Self::ENA.from_data(data)?,
adpt_crv_req: Self::ADPT_CRV_REQ.from_data(data)?,
adpt_crv_rslt: Self::ADPT_CRV_RSLT.from_data(data)?,
n_pt: Self::N_PT.from_data(data)?,
n_crv_set: Self::N_CRV_SET.from_data(data)?,
hz_sf: Self::HZ_SF.from_data(data)?,
tms_sf: Self::TMS_SF.from_data(data)?,
crv,
},
))
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
pub enum Ena {
Disabled,
Enabled,
Invalid(u16),
}
impl crate::EnumValue for Ena {
type Repr = u16;
const INVALID: Self::Repr = 65535;
fn from_repr(value: Self::Repr) -> Self {
match value {
0 => Self::Disabled,
1 => Self::Enabled,
value => Self::Invalid(value),
}
}
fn to_repr(self) -> Self::Repr {
match self {
Self::Disabled => 0,
Self::Enabled => 1,
Self::Invalid(value) => value,
}
}
}
impl crate::FixedSize for Ena {
const SIZE: u16 = 1u16;
const INVALID: Self = Self::Invalid(65535);
fn is_invalid(&self) -> bool {
matches!(self, Self::Invalid(_))
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
pub enum AdptCrvRslt {
InProgress,
Completed,
Failed,
Invalid(u16),
}
impl crate::EnumValue for AdptCrvRslt {
type Repr = u16;
const INVALID: Self::Repr = 65535;
fn from_repr(value: Self::Repr) -> Self {
match value {
0 => Self::InProgress,
1 => Self::Completed,
2 => Self::Failed,
value => Self::Invalid(value),
}
}
fn to_repr(self) -> Self::Repr {
match self {
Self::InProgress => 0,
Self::Completed => 1,
Self::Failed => 2,
Self::Invalid(value) => value,
}
}
}
impl crate::FixedSize for AdptCrvRslt {
const SIZE: u16 = 1u16;
const INVALID: Self = Self::Invalid(65535);
fn is_invalid(&self) -> bool {
matches!(self, Self::Invalid(_))
}
}
#[derive(Debug)]
#[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
pub struct Crv {
pub read_only: CrvReadOnly,
pub must_trip: MustTrip,
pub may_trip: MayTrip,
pub mom_cess: MomCess,
}
#[allow(missing_docs)]
impl Crv {
pub const READ_ONLY: crate::Point<Self, CrvReadOnly> = crate::Point::new(0, 1, false);
}
impl crate::Group for Crv {
const LEN: u16 = 1;
}
impl Crv {
fn parse_group<'a>(
data: &'a [u16],
counts: &Counts,
) -> Result<(&'a [u16], Self), crate::DecodeError> {
let nested_data = data
.get(usize::from(<Self as crate::Group>::LEN)..)
.unwrap_or(&[]);
let (nested_data, must_trip) = MustTrip::parse_group(nested_data, counts)?;
let (nested_data, may_trip) = MayTrip::parse_group(nested_data, counts)?;
let (nested_data, mom_cess) = MomCess::parse_group(nested_data, counts)?;
Ok((
nested_data,
Self {
read_only: Self::READ_ONLY.from_data(data)?,
must_trip,
may_trip,
mom_cess,
},
))
}
fn parse_multiple<'a>(
data: &'a [u16],
counts: &Counts,
) -> Result<(&'a [u16], Vec<Self>), crate::DecodeError> {
let (data, groups) =
(0..counts.n_crv_set).try_fold((data, Vec::new()), |(data, mut groups), _| {
let (data, group) = Crv::parse_group(data, counts)?;
groups.push(group);
Ok::<_, crate::DecodeError>((data, groups))
})?;
Ok((data, groups))
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
pub enum CrvReadOnly {
Rw,
R,
Invalid(u16),
}
impl crate::EnumValue for CrvReadOnly {
type Repr = u16;
const INVALID: Self::Repr = 65535;
fn from_repr(value: Self::Repr) -> Self {
match value {
0 => Self::Rw,
1 => Self::R,
value => Self::Invalid(value),
}
}
fn to_repr(self) -> Self::Repr {
match self {
Self::Rw => 0,
Self::R => 1,
Self::Invalid(value) => value,
}
}
}
impl crate::FixedSize for CrvReadOnly {
const SIZE: u16 = 1u16;
const INVALID: Self = Self::Invalid(65535);
fn is_invalid(&self) -> bool {
matches!(self, Self::Invalid(_))
}
}
#[derive(Debug)]
#[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
pub struct MustTrip {
pub act_pt: Option<u16>,
pub pt: Vec<Pt>,
}
#[allow(missing_docs)]
impl MustTrip {
pub const ACT_PT: crate::Point<Self, Option<u16>> = crate::Point::new(0, 1, true);
}
impl crate::Group for MustTrip {
const LEN: u16 = 1;
}
impl MustTrip {
fn parse_group<'a>(
data: &'a [u16],
counts: &Counts,
) -> Result<(&'a [u16], Self), crate::DecodeError> {
let nested_data = data
.get(usize::from(<Self as crate::Group>::LEN)..)
.unwrap_or(&[]);
let (nested_data, pt) = Pt::parse_multiple(nested_data, counts)?;
Ok((
nested_data,
Self {
act_pt: Self::ACT_PT.from_data(data)?,
pt,
},
))
}
}
#[derive(Debug)]
#[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
pub struct Pt {
pub hz: Option<u32>,
pub tms: Option<u32>,
}
#[allow(missing_docs)]
impl Pt {
pub const HZ: crate::Point<Self, Option<u32>> = crate::Point::new(0, 2, true);
pub const TMS: crate::Point<Self, Option<u32>> = crate::Point::new(2, 2, true);
}
impl crate::Group for Pt {
const LEN: u16 = 4;
}
impl Pt {
fn parse_group(data: &[u16]) -> Result<(&[u16], Self), crate::DecodeError> {
let nested_data = data
.get(usize::from(<Self as crate::Group>::LEN)..)
.unwrap_or(&[]);
Ok((
nested_data,
Self {
hz: Self::HZ.from_data(data)?,
tms: Self::TMS.from_data(data)?,
},
))
}
fn parse_multiple<'a>(
data: &'a [u16],
counts: &Counts,
) -> Result<(&'a [u16], Vec<Self>), crate::DecodeError> {
let (data, groups) =
(0..counts.n_pt).try_fold((data, Vec::new()), |(data, mut groups), _| {
let (data, group) = Pt::parse_group(data)?;
groups.push(group);
Ok::<_, crate::DecodeError>((data, groups))
})?;
Ok((data, groups))
}
}
#[derive(Debug)]
#[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
pub struct MayTrip {
pub act_pt: Option<u16>,
pub pt: Vec<Pt>,
}
#[allow(missing_docs)]
impl MayTrip {
pub const ACT_PT: crate::Point<Self, Option<u16>> = crate::Point::new(0, 1, true);
}
impl crate::Group for MayTrip {
const LEN: u16 = 1;
}
impl MayTrip {
fn parse_group<'a>(
data: &'a [u16],
counts: &Counts,
) -> Result<(&'a [u16], Self), crate::DecodeError> {
let nested_data = data
.get(usize::from(<Self as crate::Group>::LEN)..)
.unwrap_or(&[]);
let (nested_data, pt) = Pt::parse_multiple(nested_data, counts)?;
Ok((
nested_data,
Self {
act_pt: Self::ACT_PT.from_data(data)?,
pt,
},
))
}
}
#[derive(Debug)]
#[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
pub struct MomCess {
pub act_pt: Option<u16>,
pub pt: Vec<Pt>,
}
#[allow(missing_docs)]
impl MomCess {
pub const ACT_PT: crate::Point<Self, Option<u16>> = crate::Point::new(0, 1, true);
}
impl crate::Group for MomCess {
const LEN: u16 = 1;
}
impl MomCess {
fn parse_group<'a>(
data: &'a [u16],
counts: &Counts,
) -> Result<(&'a [u16], Self), crate::DecodeError> {
let nested_data = data
.get(usize::from(<Self as crate::Group>::LEN)..)
.unwrap_or(&[]);
let (nested_data, pt) = Pt::parse_multiple(nested_data, counts)?;
Ok((
nested_data,
Self {
act_pt: Self::ACT_PT.from_data(data)?,
pt,
},
))
}
}
impl crate::Model for DerTripLf {
const ID: u16 = 709;
fn addr(models: &crate::Models) -> crate::ModelAddr<Self> {
models.m709
}
fn parse(data: &[u16]) -> Result<Self, crate::ParseError<Self>> {
let (_, model) = Self::parse_group(data)?;
Ok(model)
}
}