Skip to main content

NDPluginFileBase

Struct NDPluginFileBase 

Source
pub struct NDPluginFileBase {
    pub file_path: String,
    pub file_name: String,
    pub file_number: i32,
    pub file_template: String,
    pub auto_increment: bool,
    pub temp_suffix: String,
    pub create_dir: i32,
    pub lazy_open: bool,
    pub delete_driver_file: bool,
    /* private fields */
}
Expand description

File path/name management and capture buffering for file plugins.

Fields§

§file_path: String§file_name: String§file_number: i32§file_template: String§auto_increment: bool§temp_suffix: String§create_dir: i32§lazy_open: bool§delete_driver_file: bool

Implementations§

Source§

impl NDPluginFileBase

Source

pub fn new() -> Self

Source

pub fn create_file_name(&self) -> String

Construct the full file path from template/path/name/number.

Mimics C epicsSnprintf(buf, ..., template, filePath, fileName, fileNumber). Template uses printf-style: first %s → filePath, second %s → fileName, %d (with optional width/precision like %3.3d) → fileNumber.

Source

pub fn temp_file_path(&self) -> Option<PathBuf>

Get the temp file path (if temp_suffix is set).

Source

pub fn last_written_name(&self) -> &str

Return the full file name that was last written.

Source

pub fn ensure_directory(&self) -> ADResult<()>

Create directory if needed. C ADCore behavior: createDir != 0 → create directories. Positive or negative values both trigger creation (negative = depth hint in C, but in practice create_dir_all handles any depth).

Source

pub fn process_array( &mut self, array: Arc<NDArray>, writer: &mut dyn NDFileWriter, ) -> ADResult<()>

Process an incoming array according to the current file mode.

Source

pub fn flush_capture(&mut self, writer: &mut dyn NDFileWriter) -> ADResult<()>

Flush capture buffer: open file, write all buffered arrays, close.

For writers that support multiple arrays (HDF5, NeXus), we open once, write all frames, and close once. For single-image writers (JPEG, TIFF), we open/write/close for each frame individually, auto-incrementing the filename between each.

capture_buffer means one thing throughout: the frames that have not reached disk. A frame leaves it only once its own file is complete, so a flush that fails part way keeps exactly the frames still owed and a second WriteFile resumes at the first of them instead of starting over on files that are already written under numbers file_number has moved past.

Source

pub fn open_stream( &mut self, writer: &mut dyn NDFileWriter, array: &NDArray, ) -> ADResult<()>

Open the Stream-mode file — the single owner of a stream open.

The eager open at capture start (C++ doCapture opens the file then so a bad path is reported at capture-start rather than on the first frame, NDPluginFile.cpp:478-479, B9) and the lazy open on the first frame both come through here, so Stream mode’s precondition is stated once: every frame the mode accepts is on disk when process_array returns, which is what lets the controller publish NDFileNumCaptured per frame. A writer that holds frames until close_file cannot keep that promise, and an unbounded stream (NumCapture=0) never reaches a close, so the open is refused here instead of growing in RAM behind a readback that reports those frames as captured.

array supplies the layout the writer needs at open time. A no-op when a file is already open.

Source

pub fn force_close(&mut self, writer: &mut dyn NDFileWriter) -> ADResult<()>

Force a file close (used by the FilePluginClose attribute, G9). Safe to call when no file is open.

Source

pub fn close_stream(&mut self, writer: &mut dyn NDFileWriter) -> ADResult<()>

Close stream mode.

This transition owns is_open: from the moment the close begins, the guard clears the marker on every exit path, so a failing close_file or temp rename ends the open state and reports the error instead of latching the plugin open against a file it can no longer write.

Source

pub fn is_open(&self) -> bool

Source

pub fn set_mode(&mut self, mode: NDFileMode)

Source

pub fn set_num_capture(&mut self, n: usize)

Source

pub fn num_captured(&self) -> usize

Source

pub fn mode(&self) -> NDFileMode

Source

pub fn num_capture_target(&self) -> usize

Source

pub fn capture_array(&mut self, array: Arc<NDArray>)

Source

pub fn clear_capture(&mut self)

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more