Skip to main content

Characteristic

Struct Characteristic 

Source
pub struct Characteristic {
    pub name: String,
    pub kind: CharKind,
    pub address: u32,
    pub deposit: String,
    pub deposit_position: u8,
    pub datatype: DataType,
    pub elements: usize,
    pub conversion: CompuMethod,
    pub lower_limit: f64,
    pub upper_limit: f64,
    pub max_diff: f64,
}
Expand description

A CHARACTERISTIC: one calibration parameter, resolved and ready to read, write, and validate.

Fields§

§name: String

CHARACTERISTIC name.

§kind: CharKind

VALUE/CURVE/MAP/VAL_BLK/ASCII.

§address: u32

ECU address of the deposit’s first byte.

§deposit: String

RECORD_LAYOUT the values deposit through.

§deposit_position: u8

Byte offset of the value array inside the deposit record (FNC_VALUES POSITION).

§datatype: DataType

Element datatype, from the deposit’s FNC_VALUES DATATYPE.

§elements: usize

Number of elements in the deposit. a2l_parse does not retain the ASAP2 NUMBER keyword, so this is 1 until declared with CalibrationProject::declare_elements — see that method’s documentation for why it is an explicit declaration rather than a guess.

§conversion: CompuMethod

The resolved conversion.

§lower_limit: f64

LOWER_LIMIT — physical.

§upper_limit: f64

UPPER_LIMIT — physical.

§max_diff: f64

MAX_DIFF — the largest step a single adjustment may take.

Implementations§

Source§

impl Characteristic

Source

pub fn element_bits(&self) -> u32

Element width in bits.

Source

pub const fn is_signed(&self) -> bool

true when the deposit datatype is two’s-complement signed.

Source

pub fn element_mask(&self) -> u64

Bit mask covering one element’s bits.

Source

pub fn size_bytes(&self) -> usize

Total deposit size in bytes (all elements).

Source

pub fn raw_value(&self, raw: u64) -> f64

Interpret a raw bit pattern as the numeric value the conversion sees: signed datatypes are sign-extended, unsigned ones masked.

Source

pub fn raw_bits(&self, value: f64) -> u64

Encode a numeric raw value back into its memory bit pattern.

Source

pub fn value_bounds(&self) -> (f64, f64)

The raw-value bounds of the deposit, in numeric terms (negative for signed datatypes).

Source

pub fn has_limits(&self) -> bool

true when the A2L declaration constrains the physical value at all. A degenerate range (lower >= upper, as generators emit for ASCII identifiers) imposes no constraint — the same convention dbc-parse applies to an empty [min|max].

Source

pub fn within_limits(&self, physical: f64) -> bool

true when physical is inside the declared limits (or no limits are declared).

Source

pub fn with_elements(self, elements: usize) -> Self

Return a copy with the element count set (the builder form of CalibrationProject::declare_elements).

Trait Implementations§

Source§

impl Clone for Characteristic

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Characteristic

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Characteristic

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Characteristic

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.