Struct nicompiler_backend::channel::Channel
source · 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) -> Self
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 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 ArrayViewMut1<'_, f64>
)
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>
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 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