pub trait BaseExperiment {
Show 41 methods // Required methods fn devices(&self) -> &HashMap<String, Device, RandomState>; fn devices_(&mut self) -> &mut HashMap<String, Device, RandomState>; // Provided methods fn assert_has_device(&self, name: &str) { ... } fn assert_device_has_channel(&self, name: &str, chan_name: &str) { ... } fn add_device_base(&mut self, dev: Device) { ... } fn add_ao_device(&mut self, name: &str, samp_rate: f64) { ... } fn add_do_device(&mut self, name: &str, samp_rate: f64) { ... } fn edit_stop_time(&self) -> f64 { ... } fn compiled_stop_time(&self) -> f64 { ... } fn compile(&mut self) -> f64 { ... } fn compile_with_stoptime(&mut self, stop_time: f64) { ... } fn compiled_devices(&self) -> Vec<&Device, Global> { ... } fn is_edited(&self) -> bool { ... } fn is_compiled(&self) -> bool { ... } fn is_fresh_compiled(&self) -> bool { ... } fn clear_edit_cache(&mut self) { ... } fn clear_compile_cache(&mut self) { ... } fn typed_device_op<F, R>( &mut self, name: &str, task_type: TaskType, f: F ) -> R where F: FnMut(&mut Device) -> R { ... } fn device_op<F, R>(&mut self, name: &str, f: F) -> R where F: FnMut(&mut Device) -> R { ... } fn typed_channel_op<F, R>( &mut self, name: &str, chan_name: &str, task_type: TaskType, f: F ) -> R where F: FnMut(&mut Channel) -> R { ... } fn channel_op<F, R>(&mut self, name: &str, chan_name: &str, f: F) -> R where F: FnMut(&mut Channel) -> R { ... } fn add_ao_channel(&mut self, name: &str, channel_id: usize) { ... } fn add_do_channel(&mut self, name: &str, port_id: usize, line_id: usize) { ... } fn device_calc_signal_nsamps( &mut self, dev_name: &str, start_pos: usize, end_pos: usize, nsamps: usize, require_streamable: bool, require_editable: bool ) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>> { ... } fn device_cfg_samp_clk_src(&mut self, name: &str, src: &str) { ... } fn device_cfg_trig( &mut self, name: &str, trig_line: &str, export_trig: bool ) { ... } fn device_cfg_ref_clk( &mut self, name: &str, ref_clk_line: &str, ref_clk_rate: f64, export_ref_clk: bool ) { ... } fn device_edit_stop_time(&mut self, name: &str) -> f64 { ... } fn device_compiled_stop_time(&mut self, name: &str) -> f64 { ... } fn device_clear_compile_cache(&mut self, name: &str) { ... } fn device_clear_edit_cache(&mut self, name: &str) { ... } fn device_compiled_channel_names( &mut self, name: &str, require_streamable: bool, require_editable: bool ) -> Vec<String, Global> { ... } fn constant( &mut self, dev_name: &str, chan_name: &str, t: f64, duration: f64, value: f64, keep_val: bool ) { ... } fn sine( &mut self, dev_name: &str, chan_name: &str, t: f64, duration: f64, keep_val: bool, freq: f64, amplitude: Option<f64>, phase: Option<f64>, dc_offset: Option<f64> ) { ... } fn high(&mut self, dev_name: &str, chan_name: &str, t: f64, duration: f64) { ... } fn low(&mut self, dev_name: &str, chan_name: &str, t: f64, duration: f64) { ... } fn go_high(&mut self, dev_name: &str, chan_name: &str, t: f64) { ... } fn go_low(&mut self, dev_name: &str, chan_name: &str, t: f64) { ... } fn channel_clear_edit_cache(&mut self, dev_name: &str, chan_name: &str) { ... } fn channel_calc_signal_nsamps( &mut self, dev_name: &str, chan_name: &str, start_time: f64, end_time: f64, num_samps: usize ) -> Vec<f64, Global> { ... } fn channel_clear_compile_cache(&mut self, dev_name: &str, chan_name: &str) { ... }
}
Expand description

This trait defines the behavior of the Experiment struct through default trait implementations.

Trait methods are primary classified into the following categories:

  1. Experiment-targed methods which alter or query the behavior of the entire experiment:
  2. Device-targeted methods which alter or query the behavior of a specific device:
  3. Channel-targeted methods which alter or query the behavior of a particular channel
  4. Internal helper methods which are not exposed to python

Required Methods§

Provided Methods§

source

fn assert_has_device(&self, name: &str)

Asserts that the specified device exists in the experiment.

This function checks if the provided device name is present within the collection of devices in the current experiment. If the device is not found, it triggers an assertion failure with a descriptive error message indicating the missing device and a list of all registered devices.

Arguments
  • name: Name of the device to check.
Panics

Panics if the provided device name is not found in the experiment’s collection of devices.

Example
use nicompiler_backend::experiment::*;

let mut exp = Experiment::new();
exp.add_do_device("PXI1Slot6", 1e6,);
exp.assert_has_device("PXI1Slot6");

// This will panic
// exp.assert_has_device("PXI1Slot5");
source

fn assert_device_has_channel(&self, name: &str, chan_name: &str)

Asserts that the specified channel exists within the given device in the experiment.

This function first checks if the provided device name is present within the collection of devices in the current experiment using the assert_has_device function. If the device is found, it then checks if the specified channel name exists within the found device. If the channel is not found, it triggers an assertion failure with a descriptive error message indicating the missing channel and a list of all registered channels within the device.

Arguments
  • name: Name of the device to look into.
  • chan_name: Name of the channel to check within the specified device.
Panics

Panics if the provided channel name is not found in the specified device’s collection of channels.

Example
use nicompiler_backend::experiment::*;

let mut exp = Experiment::new();
exp.add_do_device("PXI1Slot6", 1e6,);
exp.add_do_channel("PXI1Slot6", 0, 0);
exp.assert_device_has_channel("PXI1Slot6", "port0/line0");

// This will panic
// exp.assert_device_has_channel("PXI1Slot6", "port0/line1");
source

fn add_device_base(&mut self, dev: Device)

Helper method to add a device to the experiment’s collection of devices.

This method registers a new device to the experiment, ensuring that there are no duplicates. Used by BaseExperiment::add_ao_device and BaseExperiment::add_do_device.

Arguments
  • dev: A Device instance to be added to the experiment.
Panics

This method will panic if a device with the same name as the provided dev is already registered in the experiment.

source

fn add_ao_device(&mut self, name: &str, samp_rate: f64)

Registers an Analog Output (AO) device to the experiment.

This method creates an AO device with the specified parameters and adds it to the experiment’s collection of devices using the BaseExperiment::add_device_base method.

Arguments
  • name: A string slice that holds the name of the AO device.
  • samp_rate: Sampling rate for the AO device.
Example
let mut exp = Experiment::new();
exp.add_ao_device("PXI1Slot6", 1e6);
// Adding the same device again, even with different parameters, will cause panic
// exp.add_ao_device("PXI1Slot6", 1e7);
source

fn add_do_device(&mut self, name: &str, samp_rate: f64)

Registers a Digital Output (DO) device to the experiment.

This method creates a DO device with the specified parameters and registers it to the experiment.

Arguments
  • name: A string slice that holds the name of the DO device.
  • samp_rate: Sampling rate for the DO device.
Example
let mut exp = Experiment::new();
exp.add_do_device("PXI1Slot7", 1e6);
// Adding the same device name will cause panic
exp.add_do_device("PXI1Slot7", 1e7);
source

fn edit_stop_time(&self) -> f64

Retrieves the latest edit_stop_time from all registered devices. See BaseDevice::edit_stop_time for more information.

The maximum edit_stop_time across all devices.

Example
let mut exp = Experiment::new();
exp.add_do_device("PXI1Slot6", 1e6);
exp.add_do_channel("PXI1Slot6", 0, 0);
exp.add_do_channel("PXI1Slot6", 0, 4);
exp.high("PXI1Slot6", "port0/line0", 1., 4.); // stop time at 5
assert_eq!(exp.edit_stop_time(), 5.);
exp.high("PXI1Slot6", "port0/line4", 0., 6.); // stop time at 6
assert_eq!(exp.edit_stop_time(), 6.);
source

fn compiled_stop_time(&self) -> f64

Retrieves the compiled_stop_time from all registered devices. See BaseDevice::compiled_stop_time for more information.

The maximum compiled_stop_time across all devices.

source

fn compile(&mut self) -> f64

Broadcasts the compile command to all devices, relying on the edit_stop_time as the compilation stop-target. See BaseDevice::compile and BaseExperiment::compiled_stop_time for more information.

Example
let mut exp = Experiment::new();
exp.add_do_device("PXI1Slot6", 1e6);
exp.add_do_channel("PXI1Slot6", 0, 0);
exp.high("PXI1Slot6", "port0/line0", 1., 4.);

exp.compile();
assert_eq!(exp.compiled_stop_time(), exp.edit_stop_time());
source

fn compile_with_stoptime(&mut self, stop_time: f64)

Compiles the experiment by broadcasting the compile command to all devices.

This method checks for a primary device before proceeding. An experiment must either have no primary devices or exactly one primary device to compile successfully.

Arguments
  • stop_time: The target time for the compilation.
Panics

Panics if there is no primary device in the experiment or if multiple primary devices are found.

Example
let mut exp = Experiment::new();
exp.add_ao_device("PXI1Slot6", 1e6);
exp.device_cfg_trig("PXI1Slot6", "PXI_Trig0", false);
// This will panic as there are no primary devices, but PXI1Slot6 is expecting a trigger source
exp.compile_with_stoptime(10.0);
let mut exp = Experiment::new();
exp.add_do_device("PXI1Slot6", 1e6);
exp.add_do_channel("PXI1Slot6", 0, 0);
exp.high("PXI1Slot6", "port0/line0", 1., 3.);

exp.compile();
assert_eq!(exp.compiled_stop_time(), 4.);
exp.compile_with_stoptime(5.); // Experiment signal will stop at t=5 now
assert_eq!(exp.compiled_stop_time(), 5.);
source

fn compiled_devices(&self) -> Vec<&Device, Global>

Retrieves a list of devices that have been successfully compiled.

Returns

A vector containing references to all compiled devices.

source

fn is_edited(&self) -> bool

Checks if any of the registered devices have been edited. Also see BaseDevice::is_edited.

Returns

true if at least one device has been edited, otherwise false.

source

fn is_compiled(&self) -> bool

Checks if any of the registered devices have been compiled. Also see BaseDevice::is_compiled.

Returns

true if at least one device has been compiled, otherwise false.

source

fn is_fresh_compiled(&self) -> bool

Checks if all registered devices are in a freshly compiled state. Also see BaseDevice::is_fresh_compiled.

Returns

true if all devices are freshly compiled, otherwise false.

source

fn clear_edit_cache(&mut self)

Clears the edit cache for all registered devices. Also see BaseDevice::clear_edit_cache.

This method is useful to reset or clear any temporary data or states stored during the editing phase for each device.

source

fn clear_compile_cache(&mut self)

Clears the compile cache for all registered devices. Also see BaseDevice::clear_compile_cache.

This method is useful to reset or clear any temporary data or states stored during the compilation phase for each device.

source

fn typed_device_op<F, R>(&mut self, name: &str, task_type: TaskType, f: F) -> Rwhere F: FnMut(&mut Device) -> R,

Executes a specified operation (given by the closure f) on a targeted device of a specific TaskType.

This method is primarily a utility function to abstract away the common checks and operations performed on a device. It first ensures the device exists, then checks if the device’s task type matches the provided task_type, and finally, invokes the provided closure on the device.

Arguments
  • name: The name of the target device.
  • task_type: The expected TaskType of the device.
  • f: A closure that defines the operation to be performed on the device. It should accept a mutable reference to a Device and return a value of type R.
Panics
  1. If a device with the given name doesn’t exist.
  2. If the device’s task type doesn’t match the provided task_type.
Returns

The return value of the closure f.

Example
let mut exp = Experiment::new();
exp.add_ao_device("PXI1Slot6", 1e6);
exp.typed_device_op("PXI1Slot6", TaskType::AO, |dev| dev.clear_compile_cache());
// This will panic, since we're requiring that PXI1Slot6 be DO
// exp.typed_device_op("PXI1Slot6", TaskType::DO, |dev| dev.clear_compile_cache());
source

fn device_op<F, R>(&mut self, name: &str, f: F) -> Rwhere F: FnMut(&mut Device) -> R,

Executes a specified operation (given by the closure f) on a targeted device without considering its TaskType.

This method is a type-agnostic version of BaseExperiment::typed_device_op. It performs the same basic utility function but without asserting a specific TaskType for the device.

Arguments
  • name: The name of the target device.
  • f: A closure that defines the operation to be performed on the device. It should accept a mutable reference to a Device and return a value of type R.
Panics

If a device with the given name doesn’t exist.

Returns

The return value of the closure f.

source

fn typed_channel_op<F, R>( &mut self, name: &str, chan_name: &str, task_type: TaskType, f: F ) -> Rwhere F: FnMut(&mut Channel) -> R,

Executes a specified operation (given by the closure f) on a targeted channel of a specific device and TaskType.

This utility method abstracts the common checks and operations performed on a channel. It ensures the device and its channel both exist, then checks if the device’s task type matches the provided task_type, and finally, invokes the provided closure on the channel.

Arguments
  • name: The name of the parent device.
  • chan_name: The name of the target channel within the device.
  • task_type: The expected TaskType of the parent device.
  • f: A closure that defines the operation to be performed on the channel. It should accept a mutable reference to a Channel and return a value of type R.
Panics
  1. If a device with the given name doesn’t exist.
  2. If the channel with the given chan_name doesn’t exist within the device.
  3. If the device’s task type doesn’t match the provided task_type.
Returns

The return value of the closure f.

Example
let mut exp = Experiment::new();
exp.add_ao_device("PXI1Slot6", 1e6);
exp.add_ao_channel("PXI1Slot6", 0);
exp.typed_channel_op("PXI1Slot6", "ao0", TaskType::AO, |chan| {(*chan).constant(1., 0., 1., false)});
assert_eq!(exp.typed_channel_op("PXI1Slot6", "ao0", TaskType::AO,
            |chan| {(*chan).is_edited()}), true);
source

fn channel_op<F, R>(&mut self, name: &str, chan_name: &str, f: F) -> Rwhere F: FnMut(&mut Channel) -> R,

Executes a specified operation (given by the closure f) on a targeted channel of a device without considering its TaskType.

This method is a type-agnostic version of BaseExperiment::typed_channel_op. It abstracts away the common checks and operations performed on a channel without asserting a specific TaskType for the parent device.

Arguments
  • name: The name of the parent device.
  • chan_name: The name of the target channel within the device.
  • f: A closure that defines the operation to be performed on the channel. It should accept a mutable reference to a Channel and return a value of type R.
Panics
  1. If a device with the given name doesn’t exist.
  2. If the channel with the given chan_name doesn’t exist within the device.
Returns

The return value of the closure f.

source

fn add_ao_channel(&mut self, name: &str, channel_id: usize)

Adds an analogue output (AO) channel to the designated device.

This method leverages the BaseExperiment::typed_device_op function to forward the channel addition request to the specified device. Adds a channel of name ao(channel_id) to the designated device.

Refer to the BaseDevice::add_channel method for detailed information on channel addition.

Arguments
  • name: The name of the target device.
  • channel_id: The identifier for the AO channel to be added.
Panics

This method will panic if the device with the provided name is not of TaskType::AO.

Example
let mut exp = Experiment::new();
exp.add_ao_device("PXI1Slot3", 1e6);
exp.add_ao_channel("PXI1Slot3", 0);
source

fn add_do_channel(&mut self, name: &str, port_id: usize, line_id: usize)

Adds a digital output (DO) channel to the designated device.

This method uses the BaseExperiment::typed_device_op function to forward the channel addition request to the specified device.

For further details on how channels are added, see the BaseDevice::add_channel method.

Arguments
  • name: The name of the target device.
  • port_id: The identifier for the digital port.
  • line_id: The identifier for the digital line within the port.
Panics

This method will panic if the device with the provided name is not of TaskType::DO.

Example
let mut exp = Experiment::new();
exp.add_do_device("PXI1Slot6", 1e7);
exp.add_do_channel("PXI1Slot6", 0, 0); // adds channel "port0/line0"
source

fn device_calc_signal_nsamps( &mut self, dev_name: &str, start_pos: usize, end_pos: usize, nsamps: usize, require_streamable: bool, require_editable: bool ) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>

Given interval and number of samples, calculates signal from specified device.

This method uses the BaseExperiment::device_op to forward the calculation request to the target device. The calculation is based on the BaseDevice::calc_signal_nsamps method.

Arguments
  • dev_name: The name of the target device.
  • start_pos: The start position for the calculation.
  • end_pos: The end position for the calculation.
  • nsamps: The number of samples for the calculation.
  • require_streamable: Flag to indicate if the signal should be streamable.
  • require_editable: Flag to indicate if the signal should be editable.
Returns

Returns an array of calculated signal samples for the specified device.

source

fn device_cfg_samp_clk_src(&mut self, name: &str, src: &str)

Configures the sample clock source of a device in the experiment.

This method retrieves the specified device and delegates the configuration of the sample clock source to its base method BaseDevice::cfg_samp_clk_src.

Arguments
  • name - The name of the device to configure.
  • src - The name of the sample clock source.

See also: BaseDevice::cfg_samp_clk_src

source

fn device_cfg_trig(&mut self, name: &str, trig_line: &str, export_trig: bool)

Configures the trigger settings of a device in the experiment while ensuring synchronization.

Before delegating the configuration to its base method BaseDevice::cfg_trig, this method performs a synchronization check to ensure:

If the current device is set to export a trigger (export_trig is true), then no other device in the experiment should already be exporting a trigger (export_trig should be None for all other devices).

The experiment can only have one device that exports triggers at any given time.

Arguments
  • name - The name of the device to configure.
  • trig_line - The trigger line identifier.
  • export_trig - A boolean that determines whether to export or import the trigger.
Panics

This method will panic if the synchronization condition related to a device exporting triggers is violated.

See also: BaseDevice::cfg_trig

source

fn device_cfg_ref_clk( &mut self, name: &str, ref_clk_line: &str, ref_clk_rate: f64, export_ref_clk: bool )

Configures the reference clock settings of a device in the experiment.

This method retrieves the specified device and delegates the configuration of the reference clock settings to its base method BaseDevice::cfg_ref_clk.

Arguments
  • name - The name of the device to configure.
  • ref_clk_line - The line or channel to import or export the device’s reference clock.
  • ref_clk_rate - The rate of the reference clock in Hz.
  • export_ref_clk - A boolean that determines whether to export (if true) or import (if false) the reference clock.

See also: BaseDevice::cfg_ref_clk

source

fn device_edit_stop_time(&mut self, name: &str) -> f64

Retrieves the edit_stop_time for a specific device.

This method employs the BaseExperiment::device_op function to request the edit_stop_time from the given device.

For details on how the stop time is determined, refer to the BaseDevice::edit_stop_time method.

Arguments
  • name: The name of the target device.
Returns

Returns the edit stop time for the specified device.

source

fn device_compiled_stop_time(&mut self, name: &str) -> f64

Retrieves the maximum compiled_stop_time from all registered devices.

This method determines the longest stop time across all devices that have been compiled, which may be useful for synchronization purposes.

Returns

The maximum compiled_stop_time across all devices.

See BaseDevice::compiled_stop_time for more details on individual device stop times.

source

fn device_clear_compile_cache(&mut self, name: &str)

Clears the compilation cache for a specific device.

Utilizing the BaseExperiment::device_op function, this method forwards the request to clear the compilation cache to the specified device. Also see BaseDevice::clear_compile_cache.

Arguments
  • name: The name of the target device.
Example
let mut exp = Experiment::new();
exp.add_do_device("PXI1Slot6", 1e7);
// ... other operations ...
exp.device_clear_compile_cache("PXI1Slot6");
source

fn device_clear_edit_cache(&mut self, name: &str)

Clears the edit cache for a specific device.

This method, using the BaseExperiment::device_op function, forwards the request to clear the edit cache to the designated device. Also see BaseDevice::clear_edit_cache.

The edit cache holds intermediate results during the editing phase. Clearing it can be beneficial when making significant changes to the device’s configuration or to free up memory.

Arguments
  • name: The name of the target device.
Example
let mut exp = Experiment::new();
exp.add_do_device("PXI1Slot6", 1e7);
// ... other operations ...
exp.device_clear_edit_cache("PXI1Slot6");
source

fn device_compiled_channel_names( &mut self, name: &str, require_streamable: bool, require_editable: bool ) -> Vec<String, Global>

Retrieves the names of compiled channels from the specified device based on the given requirements.

This method fetches the names of all channels from the designated device that have been compiled and meet the criteria specified by require_streamable and require_editable: see BaseDevice::compiled_channels. The order of the returned names will match that in BaseExperiment::device_calc_signal_nsamps. Set require_editable=true to see the signals as they are written into the experiment object. Set require_streamable=true to see signals from channels as they are written in to the NI-DAQmx driver. Also see the channel module on streamable and editable channel properties.

Arguments
  • name: The name of the target device.
  • require_streamable: If set to true, only channels that are streamable will be considered.
  • require_editable: If set to true, only channels that are editable will be considered.
Returns

A vector of strings, each representing the name of a channel that matches the given criteria.

Example
let mut exp = Experiment::new();
exp.add_do_device("PXI1Slot6", 1e6,);
exp.add_do_channel("PXI1Slot6", 0, 0);
exp.add_do_channel("PXI1Slot6", 2, 0);
exp.add_do_channel("PXI1Slot6", 2, 1);
exp.go_high("PXI1Slot6", "port0/line0", 0.);
exp.go_high("PXI1Slot6", "port2/line0", 1.);
exp.go_high("PXI1Slot6", "port2/line1", 2.);
exp.compile_with_stoptime(3.);
let compiled_streamable_channels = exp.device_compiled_channel_names("PXI1Slot6", true, false);
// 2 strealable channels: "port0" and "port2"
assert_eq!(compiled_streamable_channels.len(), 2);
// 3 editable channels: "port0/line0", "port2/line0", "port2/line1"
let compiled_editable_channels = exp.device_compiled_channel_names("PXI1Slot6", false, true);
assert_eq!(compiled_editable_channels.len(), 3);
source

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

Adds a constant value instruction to the specified analogue output (AO) channel.

This method leverages the BaseExperiment::typed_channel_op function to forward the constant value instruction request to the targeted AO channel using the BaseChannel::constant method.

Arguments
  • dev_name: The name of the target device.
  • chan_name: The name of the target AO channel within the device.
  • t: The start time of the constant instruction.
  • duration: Duration for which the constant value is applied.
  • value: The constant value to apply.
  • keep_val: Flag indicating whether to maintain the value beyond the specified duration.
Panics

This method will panic if the provided channel is not of type AO.

Example
let mut exp = Experiment::new();
exp.add_do_device("PXI1Slot6", 1e6,);
exp.add_do_channel("PXI1Slot6", 0, 0);
exp.add_do_channel("PXI1Slot6", 2, 0);
exp.add_do_channel("PXI1Slot6", 2, 1);
exp.go_high("PXI1Slot6", "port0/line0", 0.);
exp.go_high("PXI1Slot6", "port2/line0", 1.);
exp.go_high("PXI1Slot6", "port2/line1", 2.);
exp.compile_with_stoptime(3.);
let compiled_streamable_channels = exp.device_compiled_channel_names("PXI1Slot6", true, false);
// 2 strealable channels: "port0" and "port2"
assert_eq!(compiled_streamable_channels.len(), 2);
// 3 editable channels: "port0/line0", "port2/line0", "port2/line1"
let compiled_editable_channels = exp.device_compiled_channel_names("PXI1Slot6", false, true);
assert_eq!(compiled_editable_channels.len(), 3);
source

fn sine( &mut self, dev_name: &str, chan_name: &str, t: f64, duration: f64, keep_val: bool, freq: f64, amplitude: Option<f64>, phase: Option<f64>, dc_offset: Option<f64> )

Adds a sine waveform instruction to the specified analogue output (AO) channel.

This method uses the BaseExperiment::typed_channel_op function to relay the sine instruction request to the appropriate AO channel via the BaseChannel::add_instr method. See Instruction::new_sine for more detailed explanation of the sine arguments.

Arguments
  • dev_name: The name of the target device.
  • chan_name: The name of the target AO channel within the device.
  • t: The start time of the sine instruction.
  • duration: Duration of the sine waveform.
  • keep_val: Flag indicating whether to maintain the waveform’s value beyond the specified duration.
  • freq: Frequency of the sine waveform.
  • amplitude: Optional amplitude of the sine waveform.
  • phase: Optional phase shift for the sine waveform.
  • dc_offset: Optional DC offset for the sine waveform.
Panics

This method will panic if the designated channel is not of type AO.

Example
let mut exp = Experiment::new();
exp.add_ao_device("PXI1Slot3", 1e6,);
exp.add_ao_channel("PXI1Slot3", 0);
// t=0, duration=1, keep_val=false, freq=10Hz, amplitude=10, phase=0(default), dc_offset=0(default)
exp.sine("PXI1Slot3", "ao0", 0., 1., false, 10., Some(10.), None, None);
source

fn high(&mut self, dev_name: &str, chan_name: &str, t: f64, duration: f64)

Sets the specified digital output (DO) channel to a high state for the given duration.

Arguments
  • dev_name: The name of the target device.
  • chan_name: The name of the target DO channel within the device.
  • t: The start time for the high state.
  • duration: Duration for which the channel remains high.
Panics

This method will panic if the channel is not of type DO.

source

fn low(&mut self, dev_name: &str, chan_name: &str, t: f64, duration: f64)

Sets the specified digital output (DO) channel to a low state for the given duration.

Arguments
  • dev_name: The name of the target device.
  • chan_name: The name of the target DO channel within the device.
  • t: The start time for the low state.
  • duration: Duration for which the channel remains low.
Panics

This method will panic if the channel is not of type DO.

source

fn go_high(&mut self, dev_name: &str, chan_name: &str, t: f64)

Sets the specified digital output (DO) channel to a high state, until the next instruction.

The duration is determined as the inverse of the channel’s sampling rate. A go_high instruction is a one-tick low pulse which keeps its value.

Arguments
  • dev_name: The name of the target device.
  • chan_name: The name of the target DO channel within the device.
  • t: The start time for the high pulse.
Panics

This method will panic if the channel is not of type DO.

source

fn go_low(&mut self, dev_name: &str, chan_name: &str, t: f64)

Sets the specified digital output (DO) channel to a low state for a short duration.

The duration is determined as the inverse of the channel’s sampling rate. A go_low instruction translates to a one-tick low pulse which keeps its value

Arguments
  • dev_name: The name of the target device.
  • chan_name: The name of the target DO channel within the device.
  • t: The start time for the low pulse.
Panics

This method will panic if the channel is not of type DO.

source

fn channel_clear_edit_cache(&mut self, dev_name: &str, chan_name: &str)

Clears the edit cache of the specified channel.

This method resets the channel to its pre-edit state. Clearing the edit cache can be helpful when a sequence of edits needs to be discarded without affecting the compiled state of the channel. Also see BaseExperiment::channel_op and BaseChannel::clear_edit_cache.

Arguments
  • dev_name: The name of the target device.
  • chan_name: The name of the target channel within the device.
Example
let mut exp = Experiment::new();
exp.add_do_device("PXI1Slot7", 1e6);
exp.add_do_channel("PXI1Slot7", 0, 7);
exp.go_high("PXI1Slot7", "port0/line7", 0.);
assert_eq!(exp.is_fresh_compiled(), false);
exp.channel_clear_edit_cache("PXI1Slot7", "port0/line7");
assert_eq!(exp.is_fresh_compiled(), true);
source

fn channel_calc_signal_nsamps( &mut self, dev_name: &str, chan_name: &str, start_time: f64, end_time: f64, num_samps: usize ) -> Vec<f64, Global>

Calculates the sampled signal for a given channel over a specified time interval.

The function computes the signal values based on the given start and end times, along with the number of samples desired.

Arguments
  • dev_name: The name of the device associated with the channel.
  • chan_name: The name of the channel for which the signal is calculated.
  • start_time: The starting time of the sampling interval (in seconds).
  • end_time: The ending time of the sampling interval (in seconds).
  • num_samps: The number of samples to be computed over the specified interval.
Returns

Returns a vector of f64 containing the signal values sampled over the interval.

Example
let mut exp = Experiment::new();
exp.add_do_device("PXI1Slot7", 1e6);
exp.add_do_channel("PXI1Slot7", 0, 7);
exp.go_high("PXI1Slot7", "port0/line7", 0.5);
exp.compile_with_stoptime(1.);
let sig = exp.channel_calc_signal_nsamps("PXI1Slot7", "port0/line7", 0., 1., 10);
assert_eq!(sig[0], 0.);
assert_eq!(sig[sig.len() - 1], 1.);
source

fn channel_clear_compile_cache(&mut self, dev_name: &str, chan_name: &str)

Clears the compile cache of the specified channel.

By invoking this method, any compiled data related to the channel will be removed. This is useful when the compiled state of a channel needs to be invalidated, such as after a series of edits or changes. Also see BaseExperiment::channel_op and BaseChannel::clear_compile_cache.

Arguments
  • dev_name: The name of the target device.
  • chan_name: The name of the target channel within the device.
Example
let mut exp = Experiment::new();
exp.add_do_device("PXI1Slot7", 1e6);
exp.add_do_channel("PXI1Slot7", 0, 7);
exp.go_high("PXI1Slot7", "port0/line7", 0.);
exp.compile();
assert_eq!(exp.is_compiled(), true);
exp.channel_clear_compile_cache("PXI1Slot7", "port0/line7");
assert_eq!(exp.is_compiled(), false);

Implementors§

source§

impl BaseExperiment for niexpctrl_backend::experiment::Experiment

source§

impl BaseExperiment for nicompiler_backend::experiment::Experiment