lasprs 0.14.3

Library for Acoustic Signal Processing (Rust edition, with optional Python bindings via pyo3)
Documentation
#![allow(non_snake_case)]

use std::fmt::Display;
use std::hash::Hash;

use super::DaqApiDescriptor;
use super::*;
use crate::config::*;

/// Device info structure. Gives all information regarding a device, i.e. the number of input and
/// output channels, its name and available sample rates and types.
#[derive(Clone, Debug, PartialEq)]
#[allow(dead_code)]
#[cfg_attr(
    feature = "python-bindings",
    gen_stub_pyclass,
    pyclass(get_all, from_py_object)
)]
pub struct DeviceInfo {
    /// The api in use for this device
    pub api: DaqApiDescriptor,

    /// Name for the device.
    pub device_name: String,

    /// Available data types for the sample
    // #[pyo3(get)]
    pub avDataTypes: Vec<DataType>,

    /// Preferred data type for device
    // #[pyo3(get)]
    pub prefDataType: DataType,

    /// Available frames per block
    pub avFramesPerBlock: Vec<usize>,

    /// Preferred frames per block for device
    pub prefFramesPerBlock: usize,

    /// Available sample rates
    pub avSampleRates: Vec<Flt>,

    /// Preferred sample rate for device
    pub prefSampleRate: Flt,

    /// Number of input channels available for this device
    pub iChannelCount: u8,

    /// Number of output channels available for this device
    pub oChannelCount: u8,

    /// Whether the device is capable to provide IEPE constant current power supply.
    pub hasInputIEPE: bool,

    /// Whether the device is capable of enabling a hardware AC-coupling
    pub hasInputACCouplingSwitch: bool,

    ///Whether the device is able to trigger on input
    pub hasInputTrigger: bool,

    /// Whether the device has an internal monitor of the output signal. If
    /// true, the device is able to monitor output signals internally and able to
    /// present output signals as virtual input signals. This only works together
    /// Daq's that are able to run in full duplex mode.
    pub hasInternalOutputMonitor: bool,

    /// Whether the device can run in duplex mode Y/N. Duplex mode means that a
    /// stream provides both input and output at the same time.
    pub hasDuplexMode: bool,

    /// This flag is used to be able to indicate that the device cannot run
    /// input and output streams independently, without opening the device in
    /// duplex mode. This is for example true for the UlDaq: only one handle to
    /// the device can be given at the same time.
    pub duplexModeForced: bool,

    /// The physical quantity of the input / output signal. For 'normal' audio
    /// devices, this is typically a 'number' between +/- full scale. For some
    /// devices however, the output quantity corresponds to a physical signal,
    /// such a Volts. Same holds for inputs.
    pub physicalIOQty: Qty,

    /// Data range for input signal (minimum, maximum)
    pub avInputRanges: Vec<(Flt, Flt)>,

    /// Data range for output signal (minimum, maximum)
    pub avOutputRanges: Vec<(Flt, Flt)>,
}
impl Display for DeviceInfo {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(&self.device_name)
    }
}
impl Eq for DeviceInfo {}
impl Hash for DeviceInfo {
    fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
        self.api.hash(state);
        self.device_name.hash(state);
        // self.avDataTypes.hash(state);
        // self.prefDataType.hash(state);
        // self.avFramesPerBlock.hash(state);
        // self.prefFramesPerBlock.hash(state);
        // self.avSampleRates.hash(state);
        // self.prefSampleRate.hash(state);
        self.iChannelCount.hash(state);
        self.oChannelCount.hash(state);
        self.hasInputIEPE.hash(state);
        self.hasInputACCouplingSwitch.hash(state);
        self.hasInputTrigger.hash(state);
        self.hasInternalOutputMonitor.hash(state);
        self.hasDuplexMode.hash(state);
        self.duplexModeForced.hash(state);
        // self.physicalIOQty.hash(state);
        // self.avInputRanges.hash(state);
        // self.avOutputRanges.hash(state);
    }
}

#[cfg_attr(feature = "python-bindings", pymethods)]
impl DeviceInfo {
    fn __repr__(&self) -> String {
        format!("{self:?}")
    }
}