pub struct EpidFastDeviceSupport { /* private fields */ }Expand description
Fast Epid device support using asyn driver for high-speed (1+ kHz) PID.
Ported from devEpidFast.c. The PID computation runs in a background
tokio task driven by asyn interrupt callbacks, not during record
processing. The record merely copies parameters to/from the fast
computation thread.
§Architecture
┌─────────────┐ interrupt ┌──────────────────┐
│ asyn driver │ ──────────────► │ PID callback task │
│ (input ADC) │ (new cval) │ (tokio::spawn) │
└─────────────┘ │ runs do_pid() │
│ writes output │
┌──────────────────────────┤ to output driver │
│ shared EpidFastPvt └──────────────────┘
│ (Arc<Mutex>) ▲
▼ │
┌─────────────┐ read() params │
│ EpidRecord │ ◄─────── copy ──────────┘
│ (process) │ ────────► copy ──────────►
└─────────────┘ resultsThe start_callback_loop() method spawns the background task.
Call it after connecting to the asyn input port.
Implementations§
Source§impl EpidFastDeviceSupport
impl EpidFastDeviceSupport
pub fn new() -> Self
Sourcepub fn pvt(&self) -> Arc<Mutex<EpidFastPvt>>
pub fn pvt(&self) -> Arc<Mutex<EpidFastPvt>>
Get a handle to the shared PID state for callback registration.
Sourcepub fn start_callback_loop(
&self,
input_rx: Receiver<f64>,
output_fn: Arc<Mutex<dyn FnMut(f64) + Send>>,
)
pub fn start_callback_loop( &self, input_rx: Receiver<f64>, output_fn: Arc<Mutex<dyn FnMut(f64) + Send>>, )
Start the interrupt-driven PID callback loop.
Spawns a tokio task that receives new readback values from input_rx
and runs do_pid() on each. This is the high-speed PID path that
runs at the interrupt rate (1kHz+), independent of record processing.
input_rx: receives new controlled-variable values from the input driver
output_fn: called with each new output value (writes to output driver)
Sourcepub fn start_from_asyn_interrupts(
&self,
interrupt_rx: Receiver<InterruptValue>,
input_reason: usize,
output_fn: Arc<Mutex<dyn FnMut(f64) + Send>>,
)
pub fn start_from_asyn_interrupts( &self, interrupt_rx: Receiver<InterruptValue>, input_reason: usize, output_fn: Arc<Mutex<dyn FnMut(f64) + Send>>, )
Start from an asyn interrupt subscription.
Subscribes to Float64 interrupts from the given broadcast sender and feeds them into the PID callback loop.
Trait Implementations§
Source§impl Default for EpidFastDeviceSupport
impl Default for EpidFastDeviceSupport
Source§impl DeviceSupport for EpidFastDeviceSupport
impl DeviceSupport for EpidFastDeviceSupport
fn dtyp(&self) -> &str
Source§fn read(&mut self, record: &mut dyn Record) -> CaResult<DeviceReadOutcome>
fn read(&mut self, record: &mut dyn Record) -> CaResult<DeviceReadOutcome>
fn write(&mut self, _record: &mut dyn Record) -> CaResult<()>
fn init(&mut self, _record: &mut (dyn Record + 'static)) -> Result<(), CaError>
Source§fn last_alarm(&self) -> Option<(u16, u16)>
fn last_alarm(&self) -> Option<(u16, u16)>
Source§fn last_timestamp(&self) -> Option<SystemTime>
fn last_timestamp(&self) -> Option<SystemTime>
Source§fn set_record_info(&mut self, _name: &str, _scan: ScanType)
fn set_record_info(&mut self, _name: &str, _scan: ScanType)
Source§fn io_intr_receiver(&mut self) -> Option<Receiver<()>>
fn io_intr_receiver(&mut self) -> Option<Receiver<()>>
Source§fn write_begin(
&mut self,
_record: &mut (dyn Record + 'static),
) -> Result<Option<Box<dyn WriteCompletion>>, CaError>
fn write_begin( &mut self, _record: &mut (dyn Record + 'static), ) -> Result<Option<Box<dyn WriteCompletion>>, CaError>
Some(handle) if the write was submitted to a worker queue —
the caller should wait on the handle outside any record lock.
Returns None to fall back to synchronous write().Source§fn handle_command(
&mut self,
_record: &mut (dyn Record + 'static),
_command: &str,
_args: &[EpicsValue],
) -> Result<(), CaError>
fn handle_command( &mut self, _record: &mut (dyn Record + 'static), _command: &str, _args: &[EpicsValue], ) -> Result<(), CaError>
ProcessAction::DeviceCommand. This allows records to request
driver operations (e.g., scaler reset/arm/write_preset) without
holding a direct driver reference. Read more