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: StringCHARACTERISTIC name.
kind: CharKindVALUE/CURVE/MAP/VAL_BLK/ASCII.
address: u32ECU address of the deposit’s first byte.
deposit: StringRECORD_LAYOUT the values deposit through.
deposit_position: u8Byte offset of the value array inside the deposit record
(FNC_VALUES POSITION).
datatype: DataTypeElement datatype, from the deposit’s FNC_VALUES DATATYPE.
elements: usizeNumber 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: CompuMethodThe resolved conversion.
lower_limit: f64LOWER_LIMIT — physical.
upper_limit: f64UPPER_LIMIT — physical.
max_diff: f64MAX_DIFF — the largest step a single adjustment may take.
Implementations§
Source§impl Characteristic
impl Characteristic
Sourcepub fn element_bits(&self) -> u32
pub fn element_bits(&self) -> u32
Element width in bits.
Sourcepub const fn is_signed(&self) -> bool
pub const fn is_signed(&self) -> bool
true when the deposit datatype is two’s-complement signed.
Sourcepub fn element_mask(&self) -> u64
pub fn element_mask(&self) -> u64
Bit mask covering one element’s bits.
Sourcepub fn size_bytes(&self) -> usize
pub fn size_bytes(&self) -> usize
Total deposit size in bytes (all elements).
Sourcepub fn raw_value(&self, raw: u64) -> f64
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.
Sourcepub fn raw_bits(&self, value: f64) -> u64
pub fn raw_bits(&self, value: f64) -> u64
Encode a numeric raw value back into its memory bit pattern.
Sourcepub fn value_bounds(&self) -> (f64, f64)
pub fn value_bounds(&self) -> (f64, f64)
The raw-value bounds of the deposit, in numeric terms (negative for signed datatypes).
Sourcepub fn has_limits(&self) -> bool
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].
Sourcepub fn within_limits(&self, physical: f64) -> bool
pub fn within_limits(&self, physical: f64) -> bool
true when physical is inside the declared limits (or no limits
are declared).
Sourcepub fn with_elements(self, elements: usize) -> Self
pub fn with_elements(self, elements: usize) -> Self
Return a copy with the element count set (the builder form of
CalibrationProject::declare_elements).