pub type Model125 = Pricing;
#[derive(Debug)]
#[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
pub struct Pricing {
pub mod_ena: ModEna,
pub sig_type: Option<SigType>,
pub sig: i16,
pub win_tms: Option<u16>,
pub rvt_tms: Option<u16>,
pub rmp_tms: Option<u16>,
pub sig_sf: i16,
}
#[allow(missing_docs)]
impl Pricing {
pub const MOD_ENA: crate::Point<Self, ModEna> = crate::Point::new(0, 1, true);
pub const SIG_TYPE: crate::Point<Self, Option<SigType>> = crate::Point::new(1, 1, true);
pub const SIG: crate::Point<Self, i16> = crate::Point::new(2, 1, true);
pub const WIN_TMS: crate::Point<Self, Option<u16>> = crate::Point::new(3, 1, true);
pub const RVT_TMS: crate::Point<Self, Option<u16>> = crate::Point::new(4, 1, true);
pub const RMP_TMS: crate::Point<Self, Option<u16>> = crate::Point::new(5, 1, true);
pub const SIG_SF: crate::Point<Self, i16> = crate::Point::new(6, 1, false);
}
impl crate::Group for Pricing {
const LEN: u16 = 8;
}
impl Pricing {
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 {
mod_ena: Self::MOD_ENA.from_data(data)?,
sig_type: Self::SIG_TYPE.from_data(data)?,
sig: Self::SIG.from_data(data)?,
win_tms: Self::WIN_TMS.from_data(data)?,
rvt_tms: Self::RVT_TMS.from_data(data)?,
rmp_tms: Self::RMP_TMS.from_data(data)?,
sig_sf: Self::SIG_SF.from_data(data)?,
},
))
}
}
bitflags::bitflags! {
#[doc = " ModEna"] #[doc = " "] #[doc =
" Is price-based charge/discharge mode active?"] #[derive(Copy, Clone, Debug, Eq,
PartialEq)] #[cfg_attr(feature = "serde", derive(::serde::Serialize,
::serde::Deserialize))] pub struct ModEna : u16 { #[allow(missing_docs)] const Enable
= 1; }
}
impl crate::Value for ModEna {
fn decode(data: &[u16]) -> Result<Self, crate::DecodeError> {
let value = u16::decode(data)?;
Ok(Self::from_bits_retain(value))
}
fn encode(self) -> Box<[u16]> {
self.bits().encode()
}
}
impl crate::FixedSize for ModEna {
const SIZE: u16 = 1u16;
const INVALID: Self = Self::from_bits_retain(65535u16);
fn is_invalid(&self) -> bool {
self.bits() == 65535u16
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
pub enum SigType {
#[allow(missing_docs)]
Unknown,
#[allow(missing_docs)]
Absolute,
#[allow(missing_docs)]
Relative,
#[allow(missing_docs)]
Multiplier,
#[allow(missing_docs)]
Level,
Invalid(u16),
}
impl crate::EnumValue for SigType {
type Repr = u16;
const INVALID: Self::Repr = 65535;
fn from_repr(value: Self::Repr) -> Self {
match value {
0 => Self::Unknown,
1 => Self::Absolute,
2 => Self::Relative,
3 => Self::Multiplier,
4 => Self::Level,
value => Self::Invalid(value),
}
}
fn to_repr(self) -> Self::Repr {
match self {
Self::Unknown => 0,
Self::Absolute => 1,
Self::Relative => 2,
Self::Multiplier => 3,
Self::Level => 4,
Self::Invalid(value) => value,
}
}
}
impl crate::FixedSize for SigType {
const SIZE: u16 = 1u16;
const INVALID: Self = Self::Invalid(65535);
fn is_invalid(&self) -> bool {
matches!(self, Self::Invalid(_))
}
}
impl crate::Model for Pricing {
const ID: u16 = 125;
fn addr(models: &crate::Models) -> crate::ModelAddr<Self> {
models.m125
}
fn parse(data: &[u16]) -> Result<Self, crate::ParseError<Self>> {
let (_, model) = Self::parse_group(data)?;
Ok(model)
}
}