pub struct NSRT { /* private fields */ }Expand description
The main driver for the NSRT_mk4 device
Implementations§
Source§impl NSRT
impl NSRT
Sourcepub fn apply(self) -> Result<Self>
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?
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}Sourcepub fn open() -> Result<Self>
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?
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}Sourcepub fn read_level(&mut self) -> Result<f32>
pub fn read_level(&mut self) -> Result<f32>
Read the current sound level in dB
Examples found in repository?
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}Sourcepub fn read_leq(&mut self) -> Result<f32>
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?
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}Sourcepub fn read_temperature(&mut self) -> Result<f32>
pub fn read_temperature(&mut self) -> Result<f32>
Read the current temperature in degrees Celsius
Examples found in repository?
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}Sourcepub fn read_weighting(&mut self) -> Result<Weighting>
pub fn read_weighting(&mut self) -> Result<Weighting>
Read the current weighting curve
Sourcepub fn weighting(self, weighting: Weighting) -> Result<Self>
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?
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}Sourcepub fn read_sampling_frequency(&mut self) -> Result<SamplingFrequency>
pub fn read_sampling_frequency(&mut self) -> Result<SamplingFrequency>
Read the current sampling frequency
Sourcepub fn sampling_frequency(self, freq: SamplingFrequency) -> Result<Self>
pub fn sampling_frequency(self, freq: SamplingFrequency) -> Result<Self>
Set the sampling frequency using fluent API
Examples found in repository?
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}Sourcepub fn read_time_constant(&mut self) -> Result<f32>
pub fn read_time_constant(&mut self) -> Result<f32>
Read the current time constant in seconds
Sourcepub fn time_constant(self, tau: f32) -> Result<Self>
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?
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}Sourcepub fn read_model(&mut self) -> Result<String>
pub fn read_model(&mut self) -> Result<String>
Read the model name
Examples found in repository?
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}Sourcepub fn read_serial_number(&mut self) -> Result<String>
pub fn read_serial_number(&mut self) -> Result<String>
Read the serial number
Examples found in repository?
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}Sourcepub fn read_firmware_revision(&mut self) -> Result<String>
pub fn read_firmware_revision(&mut self) -> Result<String>
Read the firmware revision
Examples found in repository?
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}Sourcepub fn read_calibration_date(&mut self) -> Result<u64>
pub fn read_calibration_date(&mut self) -> Result<u64>
Read the date of last calibration
Sourcepub fn read_birth_date(&mut self) -> Result<u64>
pub fn read_birth_date(&mut self) -> Result<u64>
Read the date of birth (manufacturing date)
Sourcepub fn read_user_id(&mut self) -> Result<String>
pub fn read_user_id(&mut self) -> Result<String>
Read the user ID