pub struct CalibrationSpec {
pub id: Option<String>,
pub unit: Option<String>,
pub formula: CalibrationFormula,
}Expand description
Calibration definition for one channel.
Deserialized from the dashboard sensor settings by the archiver and from Parquet metadata by the exporter. The default is an unnamed identity calibration.
Fields§
§id: Option<String>Optional identifier, kept for older configs and files. The exporter writes
it in the calibration_id CSV column, or the formula’s type when it is
None (see Self::id_or_default).
unit: Option<String>Optional engineering unit of the calibrated value, such as kPa. Carried
into Parquet metadata; omitted from the JSON when None.
formula: CalibrationFormulaFormula; its type tag and fields sit at the top level of the JSON object
next to id (serde flatten).
Implementations§
Source§impl CalibrationSpec
impl CalibrationSpec
Sourcepub fn apply(&self, raw: f64) -> f64
pub fn apply(&self, raw: f64) -> f64
Applies the calibration formula to one raw sample value.
NaN and infinite inputs propagate through the arithmetic unchanged.
§Arguments
raw- Raw sample value as stored in the archive.
§Returns
The calibrated value.
§Examples
Linear { a: 2.0, b: -1.0 } applied to 3.0 == 5.0
Polynomial { coeffs: [1.0, 0.0, 2.0] } applied to 3.0 == 1 + 2 * 9 == 19.0Sourcepub fn id_or_default(&self) -> &str
pub fn id_or_default(&self) -> &str
Returns the configured calibration id, or the formula’s type when unnamed.
The fallback is the formula’s type tag (identity, linear or
polynomial), so an unnamed linear calibration is not labelled identity.
Trait Implementations§
Source§impl Clone for CalibrationSpec
impl Clone for CalibrationSpec
Source§fn clone(&self) -> CalibrationSpec
fn clone(&self) -> CalibrationSpec
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more