use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum SensorType {
NvDiamond,
Opm,
Eeg,
SquidMeg,
AtomInterferometer,
}
impl SensorType {
pub fn typical_sensitivity_ft_sqrt_hz(&self) -> f64 {
match self {
SensorType::NvDiamond => 10.0,
SensorType::Opm => 7.0,
SensorType::Eeg => 1000.0,
SensorType::SquidMeg => 3.0,
SensorType::AtomInterferometer => 1.0,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SensorChannel {
pub id: usize,
pub sensor_type: SensorType,
pub position: [f64; 3],
pub orientation: [f64; 3],
pub sensitivity_ft_sqrt_hz: f64,
pub sample_rate_hz: f64,
pub label: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SensorArray {
pub channels: Vec<SensorChannel>,
pub sensor_type: SensorType,
pub name: String,
}
impl SensorArray {
pub fn num_channels(&self) -> usize {
self.channels.len()
}
pub fn is_empty(&self) -> bool {
self.channels.is_empty()
}
pub fn get_channel(&self, index: usize) -> Option<&SensorChannel> {
self.channels.get(index)
}
pub fn bounding_box(&self) -> Option<([f64; 3], [f64; 3])> {
if self.channels.is_empty() {
return None;
}
let mut min = [f64::INFINITY; 3];
let mut max = [f64::NEG_INFINITY; 3];
for ch in &self.channels {
for i in 0..3 {
if ch.position[i] < min[i] {
min[i] = ch.position[i];
}
if ch.position[i] > max[i] {
max[i] = ch.position[i];
}
}
}
Some((min, max))
}
}