Added daqconfig, datatype and qty

This commit is contained in:
Anne de Jong 2023-12-13 11:00:08 +01:00
parent c99faf7d0c
commit 92a66f4f20
3 changed files with 102 additions and 0 deletions

52
src/daq/daqconfig.rs Normal file
View File

@ -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<DaqChannel>,
pub outchannel_config: Vec<DaqChannel>,
pub dtype: DataType,
pub digitalHighPassCutOn: Flt,
sampleRateIndex: usize,
framesPerBlocIndex: usize,
monitorOutput: bool,
}

26
src/daq/datatype.rs Normal file
View File

@ -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,
}

24
src/daq/qty.rs Normal file
View File

@ -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,
}