pub struct NDArray {
pub unique_id: i32,
pub timestamp: EpicsTimestamp,
pub time_stamp: f64,
pub dims: Vec<NDDimension>,
pub data: NDDataBuffer,
pub attributes: NDAttributeList,
pub codec: Option<Codec>,
pub pool_id: u64,
pub data_size: usize,
}Expand description
N-dimensional array with typed data buffer.
Fields§
§unique_id: i32§timestamp: EpicsTimestamp§time_stamp: f64Separate double-precision timestamp (C++ double timeStamp), independent of epicsTS.
dims: Vec<NDDimension>§data: NDDataBuffer§attributes: NDAttributeList§codec: Option<Codec>§pool_id: u64Identity of the pool that allocated this array (C++ pNDArrayPool).
0 means the array was not allocated through any pool. NDArrayPool::release
verifies this matches its own id before returning the buffer to the free list.
data_size: usizeRequested byte count at allocation time (C++ dataSize). This is the exact
num_elements * element_size requested, NOT the allocator-rounded Vec capacity.
Pool memory accounting adds/subtracts this exact value.
Implementations§
Source§impl NDArray
impl NDArray
Sourcepub fn new(dims: Vec<NDDimension>, data_type: NDDataType) -> Self
pub fn new(dims: Vec<NDDimension>, data_type: NDDataType) -> Self
Create a new NDArray with zeroed buffer matching dimensions.
Sourcepub fn with_data(dims: Vec<NDDimension>, data: NDDataBuffer) -> Self
pub fn with_data(dims: Vec<NDDimension>, data: NDDataBuffer) -> Self
Create an NDArray wrapping an already-built data buffer.
The array is not pool-allocated (pool_id == 0); data_size is taken
from the buffer’s element count. Use this when a producer fills its own
buffer instead of allocating through an crate::ndarray_pool::NDArrayPool.
Sourcepub fn update_time_stamps(&mut self, epics_ts: EpicsTimestamp)
pub fn update_time_stamps(&mut self, epics_ts: EpicsTimestamp)
Stamp both timestamps from one time source.
The single owner of the timestamp pair, mirroring C++
asynNDArrayDriver::updateTimeStamps (asynNDArrayDriver.cpp:832-836):
updateTimeStamp(&pArray->epicsTS);
pArray->timeStamp = pArray->epicsTS.secPastEpoch + pArray->epicsTS.nsec/1.e9;timeStamp is derived from epicsTS, so the two can never disagree.
Nothing else may write one without the other — NDArrayPool::alloc sets
neither, exactly as C does.
Sourcepub fn update_time_stamps_now(&mut self)
pub fn update_time_stamps_now(&mut self)
Stamp both timestamps from the current wall clock.
Convenience form of NDArray::update_time_stamps for drivers with no
custom time source (C++ updateTimeStamp falls back to
epicsTimeGetCurrent when no timestamp source is registered).
Sourcepub fn info(&self) -> NDArrayInfo
pub fn info(&self) -> NDArrayInfo
Compute layout info for this array (matching C++ NDArray::getInfo).
For 3D arrays, reads the ColorMode attribute to determine which
dimension is X, Y, and color (RGB1, RGB2, or RGB3 layout).