1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
use anyhow::Result;
use autd3_driver::TxDatagram;
use super::Vector3;
pub trait DriveData<T> {
fn new() -> Self;
fn init(&mut self, size: usize);
fn set_drive(&mut self, tr: &T, phase: f64, amp: f64);
fn copy_from(&mut self, dev_id: usize, src: &Self);
}
pub trait Transducer: Sized {
type D: DriveData<Self>;
fn new(
id: usize,
pos: Vector3,
x_direction: Vector3,
y_direction: Vector3,
z_direction: Vector3,
) -> Self;
fn align_phase_at(&self, dist: f64, sound_speed: f64) -> f64;
fn position(&self) -> &Vector3;
fn id(&self) -> usize;
fn x_direction(&self) -> &Vector3;
fn y_direction(&self) -> &Vector3;
fn z_direction(&self) -> &Vector3;
fn cycle(&self) -> u16;
fn frequency(&self) -> f64;
fn wavelength(&self, sound_speed: f64) -> f64;
fn wavenumber(&self, sound_speed: f64) -> f64;
fn pack(
msg_id: u8,
phase_sent: &mut bool,
duty_sent: &mut bool,
drives: &Self::D,
tx: &mut TxDatagram,
) -> Result<()>;
}