NotifyWhenDataAvailableExceeds
Control firing of DataAvailable
event
Description
The DataAvailable
event is triggered when the number of scans available to the
session object exceeds the quantity specified in the
NotifyWhenDataAvailableExceeds
property.
You cannot set the NotifyWhenDataAvailableExceeds
property when the
session is in the prepared state, which can happen after running
startForeground
. In this case, call release
on the session before setting this property value.
Values
By default the DataAvailable
event triggers when 1/10 second
worth of data is available for analysis. To specify a different threshold, change the value
of NotifyWhenDataAvailableExceeds
.
Examples
Control Firing of Data Available Event
Add an event listener to display the total number of scans acquired and fire the event when the data available exceeds specified amount.
Create the session and add an analog input voltage channel.
s = daq.createSession('ni'); addAnalogInputChannel(s,'Dev4',1,'Voltage'); lh = addlistener(s,'DataAvailable', ... @(src, event) disp(s.ScansAcquired));
The default the Rate
is 1000 scans per second. The session is
automatically configured to fire the DataAvailable
notification 10
times per second.
Increase the Rate
to 800,000 scans per second, while the
DataAvailable
notification automatically fires 10 times per
second.
s.Rate = 800000; s.NotifyWhenDataAvailableExceeds
ans = 80000
Running the acquisition causes the number of scans acquired to be displayed by the callback 10 times.
data = startForeground(s);
80000 160000 240000 320000 400000 480000 560000 640000 720000 800000
Increase NotifyWhenDataAvailableExceeds
to
160,000
. NotifyWhenDataAvailableExceeds
is
no longer configured automatically when the Rate
changes.
s.NotifyWhenDataAvailableExceeds = 160000; s.IsNotifyWhenDataAvailableExceedsAuto
ans = 0
Start the acquisition. The DataAvailable
event
is fired only five times per second.
data = startForeground(s);
160000 320000 480000 640000 800000
Set IsNotifyWhenDataAvailableExceedsAuto
back
to true
.
s.IsNotifyWhenDataAvailableExceedsAuto = true; s.NotifyWhenDataAvailableExceeds
ans = 80000
This causes NotifyWhenDataAvailableExceeds
to
set automatically when Rate
changes.
s.Rate = 50000; s.NotifyWhenDataAvailableExceeds
ans = 5000