use core::{f64::NAN, marker::PhantomData}; use uom::si::{ f64::{ ElectricCurrent, Power }, electric_current::microampere, }; use uom::{si::{ISQ, SI, Quantity}, typenum::*}; use miniconf::Miniconf; // Ampere / Watt pub type ResponsitivityUnit = Quantity, SI, f64>; #[derive(Clone, Debug, PartialEq, Miniconf)] pub struct Parameters { pub responsitivity: ResponsitivityUnit, pub i_dark: ElectricCurrent, } impl Parameters { pub fn get_ld_pwr_from_ld_i(&self, i: ElectricCurrent) -> Power { let ld_power = (i - self.i_dark) / self.responsitivity; ld_power } pub fn get_ld_i_from_ld_pwr(&self, pwr: Power) -> ElectricCurrent { let ld_i = pwr * self.responsitivity + self.i_dark; ld_i } } impl Default for Parameters { fn default() -> Self { Parameters { responsitivity: ResponsitivityUnit {dimension: PhantomData, units: PhantomData, value: NAN}, i_dark: ElectricCurrent::new::(0.0), } } }