pub struct Channel { /* private fields */ }
Expand description

Represents a physical channel on an NI device.

Channel provides a concrete implementation of the BaseChannel trait, offering straightforward and direct methods to interact with the NI device channels. Each instance of Channel corresponds to a physical channel on an NI device, characterized by its name.

The Channel struct ensures that any interactions with the NI devices are consistent with the requirements and behaviors defined by the BaseChannel trait.

Fields

  • samp_rate: The sampling rate of the channel, determining how often the channel updates.
  • task_type: Specifies the type of task associated with this channel.
  • fresh_compiled: A boolean indicating whether the channel’s compiled results are up-to-date with the edit cache.
  • name: A string representation of the channel’s identifier as recognized by the NI driver.
  • instr_list: The edit-cache for the channel. Maintains a sorted list of instruction books.
  • instr_end: Stores the ending points of compiled instructions.
  • instr_val: Holds the values of the compiled instructions.

Implementations§

source§

impl Channel

source

pub fn new(task_type: TaskType, name: &str, samp_rate: f64) -> Self

Constructs a new Channel instance.

Creates a new channel with the specified task type, physical name, and sampling rate.

Arguments
  • task_type: Specifies the type of task associated with this channel. It can be either AO (analogue output) or DO (digital output).
  • name: The string representation of the channel’s identifier as recognized by the NI driver.
  • samp_rate: The sampling rate for the channel, determining how often the channel updates.
Returns

Returns a new instance of Channel initialized with the provided arguments.

Example
let do_channel = Channel::new(TaskType::DO, "port0/line0", 1e7);
let ao_channel = Channel::new(TaskType::AO, "ao0", 1e6);

Trait Implementations§

source§

impl BaseChannel for Channel

source§

fn samp_rate(&self) -> f64

source§

fn is_fresh_compiled(&self) -> bool

The fresh_compiled field is set to true by each BaseChannel::compile call and false by each BaseChannel::add_instr.
source§

fn name(&self) -> &str

source§

fn instr_list(&self) -> &BTreeSet<InstrBook>

Provies a reference to the edit cache of instrbook list.
source§

fn instr_end(&self) -> &Vec<usize>

Returns the ending points of compiled instructions.
source§

fn instr_val(&self) -> &Vec<Instruction>

Retrieves the values of compiled instructions.
source§

fn instr_list_(&mut self) -> &mut BTreeSet<InstrBook>

Mutable access to the instruction list.
source§

fn instr_end_(&mut self) -> &mut Vec<usize>

Mutable access to the ending points of compiled instructions.
source§

fn instr_val_(&mut self) -> &mut Vec<Instruction>

Mutable access to the values of compiled instructions.
source§

fn fresh_compiled_(&mut self) -> &mut bool

Mutable access to the fresh_compiled status.
source§

fn task_type(&self) -> TaskType

source§

fn is_compiled(&self) -> bool

Channel is marked as compiled if its compilation-data field instr_end is nonempty
source§

fn is_edited(&self) -> bool

Channel is marked as edited if its edit-cache field instr_list is nonempty
source§

fn editable(&self) -> bool

Channel is marked as editable if it is a AO channel or DO line channel (name contains “line”)
source§

fn streamable(&self) -> bool

Channel is marked as streamable if it is a AO channel or DO port channel (name does not contain “line”)
source§

fn compile(&mut self, stop_pos: usize)

Compiles the instructions in the channel up to the specified stop_pos. Read more
source§

fn binfind_first_intersect_instr(&self, start_pos: usize) -> usize

Utility function for signal sampling. Read more
source§

fn clear_edit_cache(&mut self)

Clears the instr_list field of the channel. Read more
source§

fn clear_compile_cache(&mut self)

Clears the compiled cache of the channel. Read more
source§

fn compiled_stop_time(&self) -> f64

Returns the stop time of the compiled instructions. Read more
source§

fn edit_stop_time(&self) -> f64

Returns the stop time of the edited instructions. Read more
source§

fn add_instr( &mut self, instr: Instruction, t: f64, duration: f64, keep_val: bool )

Adds an instruction to the channel. Read more
source§

fn constant(&mut self, value: f64, t: f64, duration: f64, keep_val: bool)

Utility function to add a constant instruction to the channel
source§

fn fill_signal_nsamps( &self, start_pos: usize, end_pos: usize, num_samps: usize, buffer: &mut ArrayViewMut1<'_, f64> )

Fills a buffer (1D view of array) with the signal samples derived from a channel’s instructions. Read more
source§

fn calc_signal_nsamps( &self, start_time: f64, end_time: f64, num_samps: usize ) -> Vec<f64>

Calls fill_signal_nsamps with the appropriate buffer and returns signal vector. The in-place version fill_signal_nsamps is preferred to this method for efficiency. This is mainly a wrapper to expose channel-signal sampling to Python

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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, U> Into<U> for Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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> Ungil for Twhere T: Send,