Using Fetch Functions
- 更新时间2025-12-08
- 阅读时长2分钟
What Are Fetch Acquisition Functions?
Unlike Read functions, Fetch functions—such as niScope_Fetch and niScope_FetchMeasurement—acquire data asynchronously. That means these functions store data on your digitizer until you need it, which frees up your computer to perform other tasks and allows for better system performance. However, fetching requires additional functions that initiate waveform acquisitions and query your board to see if the acquisition is complete.
You use the same Fetch functions for both simple data acquisition and advanced data acquisition such as multiple-record fetching. Although the functions have only the numSamples parameter to determine how data is retrieved, NI-SCOPE offers several attributes that allow you to specify advanced fetching options. The NISCOPE_ATTR_FETCH_RELATIVE_TO and NISCOPE_ATTR_FETCH_OFFSET attributes allow you to explicitly choose the portion of a record to retrieve. The NISCOPE_ATTR_FETCH_RECORD_NUMBER and NISCOPE_ATTR_FETCH_NUM_RECORDS attributes allow specifying the records to retrieve during a multirecord acquisition.
Using Fetch Acquisition Functions
To fetch data, write a program that follows these general steps:
- Create a new instrument session using niScope_init.
- Configure your digitizer with NI-SCOPE Configuration functions.
- Call niScope_ActualRecordLength to find the actual number of points your digitizer acquires for each channel.
- Call niScope_InitiateAcquisition to initiate a waveform acquisition. Data will be acquired simultaneously on all enabled channels.
- Call niScope_AcquisitionStatus in a loop to check if the acquisition is complete or in progress. This step is useful if you want to perform other tasks during the acquisition. The Fetch functions can also accept a timeout to force NI-SCOPE to wait until the acquisition is complete.
- Call the Fetch function you need. You can call multiple fetches if you are acquiring data from more than one channel or measurement.
- Call niScope_close to close the current session.