diff --git a/src/daq/daqconfig.rs b/src/daq/daqconfig.rs new file mode 100644 index 0000000..3f4e948 --- /dev/null +++ b/src/daq/daqconfig.rs @@ -0,0 +1,52 @@ +use super::api::StreamApiDescr; +use super::datatype::DataType; +use super::qty::Qty; +use crate::config::*; +use serde::{Deserialize, Serialize}; + +/// DAQ Configuration for a single channel +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] +pub struct DaqChannel { + /// Whether the channel is enabled + pub enabled: bool, + /// Readable name for channel + pub name: String, + /// To convert to physical units. Divide values by this to obtain it. + pub sensitivity: Flt, + /// Enabled constant current power supply for sensor (if device supports it) + pub IEPEEnabled: bool, + /// Enabled hardware AC coupling (if) + pub ACCouplingMode: bool, + /// If supporting multiple input ranges: select the right index + pub rangeIndex: usize, + /// Physical quantity + pub qty: Qty, +} +impl Default for DaqChannel { + fn default() -> Self { + DaqChannel { + enabled: false, + name: "".into(), + sensitivity: -1.0, + IEPEEnabled: false, + ACCouplingMode: false, + rangeIndex: 0, + qty: Qty::Number, + } + } +} + +/// Configuration of a device. +#[derive(PartialEq, Clone, Debug, Serialize, Deserialize)] +pub struct DaqConfig { + pub api: StreamApiDescr, + pub device_name: String, + + pub inchannel_config: Vec, + pub outchannel_config: Vec, + pub dtype: DataType, + pub digitalHighPassCutOn: Flt, + sampleRateIndex: usize, + framesPerBlocIndex: usize, + monitorOutput: bool, +} diff --git a/src/daq/datatype.rs b/src/daq/datatype.rs new file mode 100644 index 0000000..bd8fe7a --- /dev/null +++ b/src/daq/datatype.rs @@ -0,0 +1,26 @@ +//! Data types (sample formats) that can come from a DAQ device, or have to be sent as output to a +//! DAQ device. +use strum::EnumMessage; +use strum_macros; +use serde::{Serialize, Deserialize}; + +/// Data type description for samples coming from a stream +#[derive(strum_macros::EnumMessage, PartialEq, Copy, Debug, Clone, Serialize, Deserialize)] +#[allow(dead_code)] +pub enum DataType { + /// 32-bit floats + #[strum(message = "F32", detailed_message = "32-bits floating points")] + F32 = 0, + /// 64-bit floats + #[strum(message = "F64", detailed_message = "64-bits floating points")] + F64 = 1, + /// 8-bit integers + #[strum(message = "F8", detailed_message = "8-bits integers")] + I8 = 2, + /// 16-bit integers + #[strum(message = "F16", detailed_message = "16-bits integers")] + I16 = 3, + /// 32-bit integers + #[strum(message = "F32", detailed_message = "32-bits integers")] + I32 = 4, +} diff --git a/src/daq/qty.rs b/src/daq/qty.rs new file mode 100644 index 0000000..3e5d7ff --- /dev/null +++ b/src/daq/qty.rs @@ -0,0 +1,24 @@ +//! Physical quantities that are input / output of a daq device. Provides an enumeration for these. +//! + +use strum::EnumMessage; +use strum_macros; +use serde::{Serialize, Deserialize}; + +/// Physical quantities that are I/O of a Daq device. +#[derive(PartialEq, Serialize, Deserialize, strum_macros::EnumMessage, Debug, Clone, Copy)] +#[allow(dead_code)] +pub enum Qty { + /// Number + #[strum(message = "number", detailed_message = "Unitless number")] + Number = 0, + /// Acoustic pressure + #[strum(message = "acousticpressure", detailed_message = "Acoustic Pressure [Pa]")] + AcousticPressure = 1, + /// Voltage + #[strum(message = "voltage", detailed_message = "Voltage [V]")] + Voltage = 2, + #[strum(message = "userdefined", detailed_message = "User defined [#]")] + /// User defined + UserDefined = 3, +}