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
impl Channel
Sourcepub fn new(task_type: TaskType, name: &str, samp_rate: f64) -> Channel
pub fn new(task_type: TaskType, name: &str, samp_rate: f64) -> Channel
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 eitherAO
(analogue output) orDO
(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
impl BaseChannel for Channel
fn samp_rate(&self) -> f64
Source§fn is_fresh_compiled(&self) -> bool
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
.fn name(&self) -> &str
Source§fn instr_list(&self) -> &BTreeSet<InstrBook>
fn instr_list(&self) -> &BTreeSet<InstrBook>
Provies a reference to the edit cache of instrbook list.
Source§fn instr_val(&self) -> &Vec<Instruction>
fn instr_val(&self) -> &Vec<Instruction>
Retrieves the values of compiled instructions.
Source§fn instr_list_(&mut self) -> &mut BTreeSet<InstrBook>
fn instr_list_(&mut self) -> &mut BTreeSet<InstrBook>
Mutable access to the instruction list.
Source§fn instr_end_(&mut self) -> &mut Vec<usize>
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>
fn instr_val_(&mut self) -> &mut Vec<Instruction>
Mutable access to the values of compiled instructions.
Source§fn fresh_compiled_(&mut self) -> &mut bool
fn fresh_compiled_(&mut self) -> &mut bool
Mutable access to the
fresh_compiled
status.fn task_type(&self) -> TaskType
Source§fn is_compiled(&self) -> bool
fn is_compiled(&self) -> bool
Channel is marked as compiled if its compilation-data field
instr_end
is nonemptySource§fn is_edited(&self) -> bool
fn is_edited(&self) -> bool
Channel is marked as edited if its edit-cache field
instr_list
is nonemptySource§fn editable(&self) -> bool
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
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)
fn compile(&mut self, stop_pos: usize)
Compiles the instructions in the channel up to the specified
stop_pos
. Read moreSource§fn binfind_first_intersect_instr(&self, start_pos: usize) -> usize
fn binfind_first_intersect_instr(&self, start_pos: usize) -> usize
Utility function for signal sampling. Read more
Source§fn clear_edit_cache(&mut self)
fn clear_edit_cache(&mut self)
Clears the
instr_list
field of the channel. Read moreSource§fn clear_compile_cache(&mut self)
fn clear_compile_cache(&mut self)
Clears the compiled cache of the channel. Read more
Source§fn compiled_stop_time(&self) -> f64
fn compiled_stop_time(&self) -> f64
Returns the stop time of the compiled instructions. Read more
Source§fn edit_stop_time(&self) -> f64
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,
)
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)
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 ArrayBase<ViewRepr<&mut f64>, Dim<[usize; 1]>>,
)
fn fill_signal_nsamps( &self, start_pos: usize, end_pos: usize, num_samps: usize, buffer: &mut ArrayBase<ViewRepr<&mut f64>, Dim<[usize; 1]>>, )
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>
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 PythonAuto Trait Implementations§
impl Freeze for Channel
impl RefUnwindSafe for Channel
impl Send for Channel
impl Sync for Channel
impl Unpin for Channel
impl UnwindSafe for Channel
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more