Skip to main content

NSRT

Struct NSRT 

Source
pub struct NSRT { /* private fields */ }
Expand description

The main driver for the NSRT_mk4 device

Implementations§

Source§

impl NSRT

Source

pub fn apply(self) -> Result<Self>

Apply stabilization wait after configuration

Call this after performing multiple chained configuration methods to apply a single stabilization wait.

Examples found in repository?
examples/simple_monitor.rs (line 12)
5fn main() -> Result<()> {
6    println!("Opening NSRT_mk4 device...");
7
8    let mut nsrt = NSRT::open()?
9        .weighting(Weighting::A)?
10        .time_constant(1.0)?
11        .sampling_frequency(SamplingFrequency::Freq48kHz)?
12        .apply()?;
13
14    let model = nsrt.read_model()?;
15    let serial = nsrt.read_serial_number()?;
16    let firmware = nsrt.read_firmware_revision()?;
17
18    println!("Connected to:");
19    println!("  Model: {}", model);
20    println!("  Serial: {}", serial);
21    println!("  Firmware: {}", firmware);
22
23    println!("Monitoring sound levels:");
24    println!("Level (dBA) | LEQ (dBA) | Temp (°C)");
25    println!("------------+-----------+----------");
26
27    loop {
28        let level = nsrt.read_level()?;
29        let leq = nsrt.read_leq()?;
30        let temp = nsrt.read_temperature()?;
31
32        println!("{:10.1} | {:9.1} | {:8.1}", level, leq, temp);
33
34        thread::sleep(Duration::from_secs(1));
35    }
36}
Source

pub fn open() -> Result<Self>

Open the NSRT_mk4 device

This method automatically finds and opens the first NSRT_mk4 device connected to the system using the Convergence Instruments VID/PID.

Examples found in repository?
examples/simple_monitor.rs (line 8)
5fn main() -> Result<()> {
6    println!("Opening NSRT_mk4 device...");
7
8    let mut nsrt = NSRT::open()?
9        .weighting(Weighting::A)?
10        .time_constant(1.0)?
11        .sampling_frequency(SamplingFrequency::Freq48kHz)?
12        .apply()?;
13
14    let model = nsrt.read_model()?;
15    let serial = nsrt.read_serial_number()?;
16    let firmware = nsrt.read_firmware_revision()?;
17
18    println!("Connected to:");
19    println!("  Model: {}", model);
20    println!("  Serial: {}", serial);
21    println!("  Firmware: {}", firmware);
22
23    println!("Monitoring sound levels:");
24    println!("Level (dBA) | LEQ (dBA) | Temp (°C)");
25    println!("------------+-----------+----------");
26
27    loop {
28        let level = nsrt.read_level()?;
29        let leq = nsrt.read_leq()?;
30        let temp = nsrt.read_temperature()?;
31
32        println!("{:10.1} | {:9.1} | {:8.1}", level, leq, temp);
33
34        thread::sleep(Duration::from_secs(1));
35    }
36}
Source

pub fn read_level(&mut self) -> Result<f32>

Read the current sound level in dB

Examples found in repository?
examples/simple_monitor.rs (line 28)
5fn main() -> Result<()> {
6    println!("Opening NSRT_mk4 device...");
7
8    let mut nsrt = NSRT::open()?
9        .weighting(Weighting::A)?
10        .time_constant(1.0)?
11        .sampling_frequency(SamplingFrequency::Freq48kHz)?
12        .apply()?;
13
14    let model = nsrt.read_model()?;
15    let serial = nsrt.read_serial_number()?;
16    let firmware = nsrt.read_firmware_revision()?;
17
18    println!("Connected to:");
19    println!("  Model: {}", model);
20    println!("  Serial: {}", serial);
21    println!("  Firmware: {}", firmware);
22
23    println!("Monitoring sound levels:");
24    println!("Level (dBA) | LEQ (dBA) | Temp (°C)");
25    println!("------------+-----------+----------");
26
27    loop {
28        let level = nsrt.read_level()?;
29        let leq = nsrt.read_leq()?;
30        let temp = nsrt.read_temperature()?;
31
32        println!("{:10.1} | {:9.1} | {:8.1}", level, leq, temp);
33
34        thread::sleep(Duration::from_secs(1));
35    }
36}
Source

pub fn read_leq(&mut self) -> Result<f32>

Read the current LEQ (Equivalent Continuous Sound Level) in dB and restart integration for the next LEQ measurement

Examples found in repository?
examples/simple_monitor.rs (line 29)
5fn main() -> Result<()> {
6    println!("Opening NSRT_mk4 device...");
7
8    let mut nsrt = NSRT::open()?
9        .weighting(Weighting::A)?
10        .time_constant(1.0)?
11        .sampling_frequency(SamplingFrequency::Freq48kHz)?
12        .apply()?;
13
14    let model = nsrt.read_model()?;
15    let serial = nsrt.read_serial_number()?;
16    let firmware = nsrt.read_firmware_revision()?;
17
18    println!("Connected to:");
19    println!("  Model: {}", model);
20    println!("  Serial: {}", serial);
21    println!("  Firmware: {}", firmware);
22
23    println!("Monitoring sound levels:");
24    println!("Level (dBA) | LEQ (dBA) | Temp (°C)");
25    println!("------------+-----------+----------");
26
27    loop {
28        let level = nsrt.read_level()?;
29        let leq = nsrt.read_leq()?;
30        let temp = nsrt.read_temperature()?;
31
32        println!("{:10.1} | {:9.1} | {:8.1}", level, leq, temp);
33
34        thread::sleep(Duration::from_secs(1));
35    }
36}
Source

pub fn read_temperature(&mut self) -> Result<f32>

Read the current temperature in degrees Celsius

Examples found in repository?
examples/simple_monitor.rs (line 30)
5fn main() -> Result<()> {
6    println!("Opening NSRT_mk4 device...");
7
8    let mut nsrt = NSRT::open()?
9        .weighting(Weighting::A)?
10        .time_constant(1.0)?
11        .sampling_frequency(SamplingFrequency::Freq48kHz)?
12        .apply()?;
13
14    let model = nsrt.read_model()?;
15    let serial = nsrt.read_serial_number()?;
16    let firmware = nsrt.read_firmware_revision()?;
17
18    println!("Connected to:");
19    println!("  Model: {}", model);
20    println!("  Serial: {}", serial);
21    println!("  Firmware: {}", firmware);
22
23    println!("Monitoring sound levels:");
24    println!("Level (dBA) | LEQ (dBA) | Temp (°C)");
25    println!("------------+-----------+----------");
26
27    loop {
28        let level = nsrt.read_level()?;
29        let leq = nsrt.read_leq()?;
30        let temp = nsrt.read_temperature()?;
31
32        println!("{:10.1} | {:9.1} | {:8.1}", level, leq, temp);
33
34        thread::sleep(Duration::from_secs(1));
35    }
36}
Source

pub fn read_weighting(&mut self) -> Result<Weighting>

Read the current weighting curve

Source

pub fn weighting(self, weighting: Weighting) -> Result<Self>

Set the weighting curve using fluent API

This method can be chained with other setters during initialization.

Examples found in repository?
examples/simple_monitor.rs (line 9)
5fn main() -> Result<()> {
6    println!("Opening NSRT_mk4 device...");
7
8    let mut nsrt = NSRT::open()?
9        .weighting(Weighting::A)?
10        .time_constant(1.0)?
11        .sampling_frequency(SamplingFrequency::Freq48kHz)?
12        .apply()?;
13
14    let model = nsrt.read_model()?;
15    let serial = nsrt.read_serial_number()?;
16    let firmware = nsrt.read_firmware_revision()?;
17
18    println!("Connected to:");
19    println!("  Model: {}", model);
20    println!("  Serial: {}", serial);
21    println!("  Firmware: {}", firmware);
22
23    println!("Monitoring sound levels:");
24    println!("Level (dBA) | LEQ (dBA) | Temp (°C)");
25    println!("------------+-----------+----------");
26
27    loop {
28        let level = nsrt.read_level()?;
29        let leq = nsrt.read_leq()?;
30        let temp = nsrt.read_temperature()?;
31
32        println!("{:10.1} | {:9.1} | {:8.1}", level, leq, temp);
33
34        thread::sleep(Duration::from_secs(1));
35    }
36}
Source

pub fn read_sampling_frequency(&mut self) -> Result<SamplingFrequency>

Read the current sampling frequency

Source

pub fn sampling_frequency(self, freq: SamplingFrequency) -> Result<Self>

Set the sampling frequency using fluent API

Examples found in repository?
examples/simple_monitor.rs (line 11)
5fn main() -> Result<()> {
6    println!("Opening NSRT_mk4 device...");
7
8    let mut nsrt = NSRT::open()?
9        .weighting(Weighting::A)?
10        .time_constant(1.0)?
11        .sampling_frequency(SamplingFrequency::Freq48kHz)?
12        .apply()?;
13
14    let model = nsrt.read_model()?;
15    let serial = nsrt.read_serial_number()?;
16    let firmware = nsrt.read_firmware_revision()?;
17
18    println!("Connected to:");
19    println!("  Model: {}", model);
20    println!("  Serial: {}", serial);
21    println!("  Firmware: {}", firmware);
22
23    println!("Monitoring sound levels:");
24    println!("Level (dBA) | LEQ (dBA) | Temp (°C)");
25    println!("------------+-----------+----------");
26
27    loop {
28        let level = nsrt.read_level()?;
29        let leq = nsrt.read_leq()?;
30        let temp = nsrt.read_temperature()?;
31
32        println!("{:10.1} | {:9.1} | {:8.1}", level, leq, temp);
33
34        thread::sleep(Duration::from_secs(1));
35    }
36}
Source

pub fn read_time_constant(&mut self) -> Result<f32>

Read the current time constant in seconds

Source

pub fn time_constant(self, tau: f32) -> Result<Self>

Set the time constant using fluent API

This method can be chained with other setters during initialization.

Examples found in repository?
examples/simple_monitor.rs (line 10)
5fn main() -> Result<()> {
6    println!("Opening NSRT_mk4 device...");
7
8    let mut nsrt = NSRT::open()?
9        .weighting(Weighting::A)?
10        .time_constant(1.0)?
11        .sampling_frequency(SamplingFrequency::Freq48kHz)?
12        .apply()?;
13
14    let model = nsrt.read_model()?;
15    let serial = nsrt.read_serial_number()?;
16    let firmware = nsrt.read_firmware_revision()?;
17
18    println!("Connected to:");
19    println!("  Model: {}", model);
20    println!("  Serial: {}", serial);
21    println!("  Firmware: {}", firmware);
22
23    println!("Monitoring sound levels:");
24    println!("Level (dBA) | LEQ (dBA) | Temp (°C)");
25    println!("------------+-----------+----------");
26
27    loop {
28        let level = nsrt.read_level()?;
29        let leq = nsrt.read_leq()?;
30        let temp = nsrt.read_temperature()?;
31
32        println!("{:10.1} | {:9.1} | {:8.1}", level, leq, temp);
33
34        thread::sleep(Duration::from_secs(1));
35    }
36}
Source

pub fn read_model(&mut self) -> Result<String>

Read the model name

Examples found in repository?
examples/simple_monitor.rs (line 14)
5fn main() -> Result<()> {
6    println!("Opening NSRT_mk4 device...");
7
8    let mut nsrt = NSRT::open()?
9        .weighting(Weighting::A)?
10        .time_constant(1.0)?
11        .sampling_frequency(SamplingFrequency::Freq48kHz)?
12        .apply()?;
13
14    let model = nsrt.read_model()?;
15    let serial = nsrt.read_serial_number()?;
16    let firmware = nsrt.read_firmware_revision()?;
17
18    println!("Connected to:");
19    println!("  Model: {}", model);
20    println!("  Serial: {}", serial);
21    println!("  Firmware: {}", firmware);
22
23    println!("Monitoring sound levels:");
24    println!("Level (dBA) | LEQ (dBA) | Temp (°C)");
25    println!("------------+-----------+----------");
26
27    loop {
28        let level = nsrt.read_level()?;
29        let leq = nsrt.read_leq()?;
30        let temp = nsrt.read_temperature()?;
31
32        println!("{:10.1} | {:9.1} | {:8.1}", level, leq, temp);
33
34        thread::sleep(Duration::from_secs(1));
35    }
36}
Source

pub fn read_serial_number(&mut self) -> Result<String>

Read the serial number

Examples found in repository?
examples/simple_monitor.rs (line 15)
5fn main() -> Result<()> {
6    println!("Opening NSRT_mk4 device...");
7
8    let mut nsrt = NSRT::open()?
9        .weighting(Weighting::A)?
10        .time_constant(1.0)?
11        .sampling_frequency(SamplingFrequency::Freq48kHz)?
12        .apply()?;
13
14    let model = nsrt.read_model()?;
15    let serial = nsrt.read_serial_number()?;
16    let firmware = nsrt.read_firmware_revision()?;
17
18    println!("Connected to:");
19    println!("  Model: {}", model);
20    println!("  Serial: {}", serial);
21    println!("  Firmware: {}", firmware);
22
23    println!("Monitoring sound levels:");
24    println!("Level (dBA) | LEQ (dBA) | Temp (°C)");
25    println!("------------+-----------+----------");
26
27    loop {
28        let level = nsrt.read_level()?;
29        let leq = nsrt.read_leq()?;
30        let temp = nsrt.read_temperature()?;
31
32        println!("{:10.1} | {:9.1} | {:8.1}", level, leq, temp);
33
34        thread::sleep(Duration::from_secs(1));
35    }
36}
Source

pub fn read_firmware_revision(&mut self) -> Result<String>

Read the firmware revision

Examples found in repository?
examples/simple_monitor.rs (line 16)
5fn main() -> Result<()> {
6    println!("Opening NSRT_mk4 device...");
7
8    let mut nsrt = NSRT::open()?
9        .weighting(Weighting::A)?
10        .time_constant(1.0)?
11        .sampling_frequency(SamplingFrequency::Freq48kHz)?
12        .apply()?;
13
14    let model = nsrt.read_model()?;
15    let serial = nsrt.read_serial_number()?;
16    let firmware = nsrt.read_firmware_revision()?;
17
18    println!("Connected to:");
19    println!("  Model: {}", model);
20    println!("  Serial: {}", serial);
21    println!("  Firmware: {}", firmware);
22
23    println!("Monitoring sound levels:");
24    println!("Level (dBA) | LEQ (dBA) | Temp (°C)");
25    println!("------------+-----------+----------");
26
27    loop {
28        let level = nsrt.read_level()?;
29        let leq = nsrt.read_leq()?;
30        let temp = nsrt.read_temperature()?;
31
32        println!("{:10.1} | {:9.1} | {:8.1}", level, leq, temp);
33
34        thread::sleep(Duration::from_secs(1));
35    }
36}
Source

pub fn read_calibration_date(&mut self) -> Result<u64>

Read the date of last calibration

Source

pub fn read_birth_date(&mut self) -> Result<u64>

Read the date of birth (manufacturing date)

Source

pub fn read_user_id(&mut self) -> Result<String>

Read the user ID

Auto Trait Implementations§

§

impl Freeze for NSRT

§

impl !RefUnwindSafe for NSRT

§

impl Send for NSRT

§

impl !Sync for NSRT

§

impl Unpin for NSRT

§

impl UnsafeUnpin for NSRT

§

impl !UnwindSafe for NSRT

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.