Crate nlabapi

Source
Expand description

This crate provides an interface to the nLab

§Usage

This crate is on crates.io and can be used by adding nlab to the dependencies in your project’s Cargo.toml.

§Example

extern crate nlabapi;
use nlabapi::LabBench;

fn main() {
    // Create a LabBench
    let bench = LabBench::new().expect("Cannot create LabBench");

    // Print the bench to show a list of detected nLabs
    println!("{:?}", bench);

    // Open an nLab
    let nlab = bench.open_first_available(true).expect("Cannot open nLab");

    // Turn on analog output channel A1
    nlab.a1.turn_on();

    // Trigger an auto-triggered sweep of 20 samples at 4.0 Hz sample rate
    let sweep_handle = nlab.request(4.0, 20, None);

    // Loop through the received data, blocking on each sample until it arrives
    for sample in sweep_handle.receiver {
        // Print the sample data
        println!("{:?}", sample.data);
    }

    // Turn off the analog output channel A1
    nlab.a1.turn_off();

}

Structs§

AnalogInput
Interface to a single scope channel
AnalogOutput
Interface to an analog output channel
LabBench
A representation of all the nLabs plugged into a computer
Nlab
Primary interface to the nLab, used to set outputs, trigger sweeps of input data on scope channels, and monitor power state
NlabLink
A detected link between the computer and an nLab, used to open and retrieve an nLab
PowerStatus
Information about the power supply status of nLab
PulseOutput
Interface to a pulse output channel
Sample
Voltage information from all open channels at a given time
SweepHandle
Handle to an ongoing data sweep, holds received data from nLab
Trigger
A representation of a trigger used to start a data sweep

Enums§

AnalogSignalPolarity
Possible analog output polarities
AnalogWaveType
Possible analog output signal types
PowerState
Possible states of the nLab power supply
TriggerType
Different trigger types used to start a data sweep

Functions§

version
Returns the current version of the nLab API