pub type Model705 = DerVoltVar;
struct Counts {
n_pt: u16,
n_crv: u16,
}
#[derive(Debug)]
#[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
pub struct DerVoltVar {
pub ena: Ena,
pub adpt_crv_req: u16,
pub adpt_crv_rslt: AdptCrvRslt,
pub n_pt: u16,
pub n_crv: u16,
pub rvrt_tms: Option<u32>,
pub rvrt_rem: Option<u32>,
pub rvrt_crv: Option<u16>,
pub v_sf: i16,
pub dept_ref_sf: i16,
pub rsp_tms_sf: i16,
pub crv: Vec<Crv>,
}
#[allow(missing_docs)]
impl DerVoltVar {
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: crate::Point<Self, u16> = crate::Point::new(4, 1, false);
pub const RVRT_TMS: crate::Point<Self, Option<u32>> = crate::Point::new(5, 2, true);
pub const RVRT_REM: crate::Point<Self, Option<u32>> = crate::Point::new(7, 2, false);
pub const RVRT_CRV: crate::Point<Self, Option<u16>> = crate::Point::new(9, 1, true);
pub const V_SF: crate::Point<Self, i16> = crate::Point::new(10, 1, false);
pub const DEPT_REF_SF: crate::Point<Self, i16> = crate::Point::new(11, 1, false);
pub const RSP_TMS_SF: crate::Point<Self, i16> = crate::Point::new(12, 1, false);
}
impl crate::Group for DerVoltVar {
const LEN: u16 = 13;
}
impl DerVoltVar {
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: Self::N_CRV.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: Self::N_CRV.from_data(data)?,
rvrt_tms: Self::RVRT_TMS.from_data(data)?,
rvrt_rem: Self::RVRT_REM.from_data(data)?,
rvrt_crv: Self::RVRT_CRV.from_data(data)?,
v_sf: Self::V_SF.from_data(data)?,
dept_ref_sf: Self::DEPT_REF_SF.from_data(data)?,
rsp_tms_sf: Self::RSP_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 act_pt: u16,
pub dept_ref: CrvDeptRef,
pub pri: Option<CrvPri>,
pub v_ref: Option<u16>,
pub v_ref_auto: Option<u16>,
pub v_ref_auto_ena: Option<CrvVRefAutoEna>,
pub v_ref_auto_tms: Option<u16>,
pub rsp_tms: Option<u32>,
pub read_only: CrvReadOnly,
pub pt: Vec<Pt>,
}
#[allow(missing_docs)]
impl Crv {
pub const ACT_PT: crate::Point<Self, u16> = crate::Point::new(0, 1, true);
pub const DEPT_REF: crate::Point<Self, CrvDeptRef> = crate::Point::new(1, 1, true);
pub const PRI: crate::Point<Self, Option<CrvPri>> = crate::Point::new(2, 1, true);
pub const V_REF: crate::Point<Self, Option<u16>> = crate::Point::new(3, 1, true);
pub const V_REF_AUTO: crate::Point<Self, Option<u16>> = crate::Point::new(4, 1, false);
pub const V_REF_AUTO_ENA: crate::Point<Self, Option<CrvVRefAutoEna>> =
crate::Point::new(5, 1, true);
pub const V_REF_AUTO_TMS: crate::Point<Self, Option<u16>> = crate::Point::new(6, 1, true);
pub const RSP_TMS: crate::Point<Self, Option<u32>> = crate::Point::new(7, 2, true);
pub const READ_ONLY: crate::Point<Self, CrvReadOnly> = crate::Point::new(9, 1, false);
}
impl crate::Group for Crv {
const LEN: u16 = 10;
}
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, pt) = Pt::parse_multiple(nested_data, counts)?;
Ok((
nested_data,
Self {
act_pt: Self::ACT_PT.from_data(data)?,
dept_ref: Self::DEPT_REF.from_data(data)?,
pri: Self::PRI.from_data(data)?,
v_ref: Self::V_REF.from_data(data)?,
v_ref_auto: Self::V_REF_AUTO.from_data(data)?,
v_ref_auto_ena: Self::V_REF_AUTO_ENA.from_data(data)?,
v_ref_auto_tms: Self::V_REF_AUTO_TMS.from_data(data)?,
rsp_tms: Self::RSP_TMS.from_data(data)?,
read_only: Self::READ_ONLY.from_data(data)?,
pt,
},
))
}
fn parse_multiple<'a>(
data: &'a [u16],
counts: &Counts,
) -> Result<(&'a [u16], Vec<Self>), crate::DecodeError> {
let (data, groups) =
(0..counts.n_crv).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 CrvDeptRef {
WMaxPct,
VarMaxPct,
VarAvalPct,
VaMaxPct,
Invalid(u16),
}
impl crate::EnumValue for CrvDeptRef {
type Repr = u16;
const INVALID: Self::Repr = 65535;
fn from_repr(value: Self::Repr) -> Self {
match value {
0 => Self::WMaxPct,
1 => Self::VarMaxPct,
2 => Self::VarAvalPct,
3 => Self::VaMaxPct,
value => Self::Invalid(value),
}
}
fn to_repr(self) -> Self::Repr {
match self {
Self::WMaxPct => 0,
Self::VarMaxPct => 1,
Self::VarAvalPct => 2,
Self::VaMaxPct => 3,
Self::Invalid(value) => value,
}
}
}
impl crate::FixedSize for CrvDeptRef {
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 CrvPri {
Active,
Reactive,
Vendor,
Invalid(u16),
}
impl crate::EnumValue for CrvPri {
type Repr = u16;
const INVALID: Self::Repr = 65535;
fn from_repr(value: Self::Repr) -> Self {
match value {
0 => Self::Active,
1 => Self::Reactive,
2 => Self::Vendor,
value => Self::Invalid(value),
}
}
fn to_repr(self) -> Self::Repr {
match self {
Self::Active => 0,
Self::Reactive => 1,
Self::Vendor => 2,
Self::Invalid(value) => value,
}
}
}
impl crate::FixedSize for CrvPri {
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 CrvVRefAutoEna {
Disabled,
Enabled,
Invalid(u16),
}
impl crate::EnumValue for CrvVRefAutoEna {
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 CrvVRefAutoEna {
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 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 Pt {
pub v: Option<u16>,
pub var: Option<i16>,
}
#[allow(missing_docs)]
impl Pt {
pub const V: crate::Point<Self, Option<u16>> = crate::Point::new(0, 1, true);
pub const VAR: crate::Point<Self, Option<i16>> = crate::Point::new(1, 1, true);
}
impl crate::Group for Pt {
const LEN: u16 = 2;
}
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 {
v: Self::V.from_data(data)?,
var: Self::VAR.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))
}
}
impl crate::Model for DerVoltVar {
const ID: u16 = 705;
fn addr(models: &crate::Models) -> crate::ModelAddr<Self> {
models.m705
}
fn parse(data: &[u16]) -> Result<Self, crate::ParseError<Self>> {
let (_, model) = Self::parse_group(data)?;
Ok(model)
}
}