AcqConfig

Struct AcqConfig 

Source
pub struct AcqConfig { /* private fields */ }
Expand description

一次采集的完整配置。用链式方法构造,Device::configure 或 AcqConfig::apply 写入设备。

默认值:不抽取(r = 0),不改设备里已有的滤波核,4 个检测器全关,两组都没有来源和通道, 点数不限,8 KB 数据包(需要巨帧)。

Implementations§

Source§

impl AcqConfig

Source

pub fn new() -> AcqConfig

默认配置。

Source

pub fn decimation_log2(self, r: u8) -> AcqConfig

抽取指数 r(0..=4),重采样之前先做 R = 2^r 倍抽取。

Source

pub fn kernel(self, kernel: Kernel) -> AcqConfig

重采样滤波核。不设置时沿用设备里已装入的系数(上电后未装入过则为全 0,输出恒为 0)。

Source

pub fn bandwidth(self, bandwidth_hz: f64) -> Result<AcqConfig>

按信号带宽同时设置抽取指数和滤波核,见 Kernel::for_bandwidth。

Source

pub fn time_calibration(self, ticks: i16) -> AcqConfig

时间校准(单位 T/64,有符号):补偿 CONV 输入到 ADC 采样时刻的固定延迟,加到所有检测器的边沿时刻上。

Source

pub fn detector(self, d: usize, det: EdgeDetector) -> AcqConfig

设置边沿检测器 d(0..=3)。检测器还需要在某一组的来源里选中才起作用。

Source

pub fn detector_off(self, d: usize) -> AcqConfig

关闭边沿检测器 d(默认即关闭)。

Source

pub fn generator_period(self, samples: f64) -> AcqConfig

内部发生器的周期,单位为采样周期,可以是小数(分辨率 1/16384)。

整数周期时每个点落在同一个插值相位上;配合 Kernel::identity 和 r = 0 即“每 N 个采样取一个“。

Source

pub fn generator_rate(self, points_per_second: f64) -> AcqConfig

内部发生器的速率(点/秒),按标称采样率 100 MSPS 换算成周期。

Source

pub fn group(self, g: usize, f: impl FnOnce(Group) -> Group) -> AcqConfig

设置组 g(0 或 1)。闭包拿到该组当前的设置,返回修改后的设置。

Source

pub fn points(self, n: u32) -> AcqConfig

两组合计的点数,达到后自动停止;0 = 不限,直到 STOP。

Source

pub fn merge_delay(self, samples: u16) -> AcqConfig

合并延迟(采样周期数,≥ 16):多个来源的事件按时刻排序时等待的时间。 用作 CONV 的边沿很慢(从阈值走到迟滞电平超过这个时间)时需要加大。

Source

pub fn jumbo_packets(self) -> AcqConfig

使用 8 KB 数据包(默认)。主机网卡和交换机的 MTU 需 ≥ 8100。

Source

pub fn standard_mtu_packets(self) -> AcqConfig

使用标准 MTU(1500)能通过的数据包(1472 字节)。包数约为巨帧的 5.6 倍。

Source

pub fn packet_beats(self, beats: u16) -> AcqConfig

每个数据包的载荷拍数(8..=1020,每拍 8 字节,数据报 = 32 + 8 × 拍数 字节)。

Source

pub fn flush_timeout(self, t: Duration) -> AcqConfig

未装满的数据包最长等待多久就发出(默认 1 ms)。点速率很低时决定数据到达主机的延迟。

Source

pub fn total_points(&self) -> u32

配置的点数(0 = 不限)。

Source

pub fn decimation(&self) -> u8

配置的抽取指数 r。

Source

pub fn generator_period_samples(&self) -> Option<f64>

内部发生器的周期(采样周期数);未设置时为 None。

Source

pub fn groups(&self) -> &[Group; 2]

两组的设置。

Source

pub fn detectors(&self) -> &[Option<EdgeDetector>; 4]

4 个边沿检测器的设置(None = 关闭)。

Source

pub fn validate(&self) -> Result<()>

检查配置是否在设备允许的范围内。apply 会先调用它。

Source

pub fn apply<R: RegIo + ?Sized>(&self, io: &mut R) -> Result<()>

把配置写入设备(不启动)。io 可以是 Device,也可以是串口上的 AtClient(装入滤波核要写两千多个寄存器,串口上约需一分钟)。

设备正在采集时返回 Error::Busy,不写任何寄存器。

Trait Implementations§

Source§

impl Clone for AcqConfig

Source§

fn clone(&self) -> AcqConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AcqConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for AcqConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.