Module nicompiler_backend::experiment
source · Expand description
The experiment module provides the highest level of abstraction for managing NI experiments, and the single place by which methods are exposed to python.
Overview
At the heart of this module lies the Experiment
struct, which consists of a collection of devices.
The behavior of the Experiment
struct is primarily defined
by the BaseExperiment
trait, which prescribes a collection of methods for experiment management and manipulation.
The module is organized into the following primary components:
- Experiment Struct: The main data structure representing the entire experimental setup. It houses devices and their associated channels.
- Traits: Including the pivotal
BaseExperiment
trait, which defines the expected behaviors and operations possible on anExperiment
. - Macro: The module features a macro,
impl_exp_boilerplate!
, designed to generate boilerplate code to assist in bridging Rust’s trait system and Python’s class system, as well as to make the python methods extensible.
Key Structures and Their Relationships
- Experiment: This is the main structure that users interact with. It represents a collection of devices and provides methods for their management.
- Device: Each device, represented by the
Device
struct, corresponds to a specific piece of NI hardware. Devices contain channels, and methods in theExperiment
struct often redirect to these devices. - Channel: Channels, denoted by the
Channel
struct, symbolize distinct physical channels on an NI device. They hold instructions and other functionalities specific to the channel. - Instruction: Instructions, housed within
InstrBook
, define specific tasks or commands for channels.
Navigating the Module
If you’re looking to:
- Understand core behaviors: Dive into the
BaseExperiment
trait. - Integrate with python: Refer to the [
impl_exp_boilerplate
] macro and its source. The macro provides python-exposed wrappers for methods implemented inBaseExperiment
trait.
Structs
- A concrete struct consisting of a collection of devices.
Traits
- This trait defines the behavior of the
Experiment
struct through default trait implementations.