Streaming API Reference

Streaming is used in the generation or acquisition of clocked data to allow asynchronous operation that does not block MATLAB®. Stream channels accommodate the flow of data separately from the session-dispatcher route. This also allows data sets that might exceed the size of the memory on the device.

The following functions are defined in the analog streaming source file daqstream_analog.cpp. Corresponding functions for digital I/O streaming are defined in daqstream_digital.cpp.

Initialization and Configuration

makeStream

Syntaxstatic DAQStream* makeStream(...)
PurposeFactory method to create channel group stream.
Inputs

Fixed signature

OutputPointer to DAQStream
Usage notesUse as shown in daqstream_analog.cpp.

initialize

Syntaxint64_T DAQStreamAnalog::initialize()
PurposeInitialize channel group after constructor.
InputsNone
OutputNone

terminate

Syntaxint64_T DAQStreamAnalog::terminate()
PurposeTerminate DAQ stream prior to its destruction.
InputsNone
OutputNone

configureStream

Syntaxint64_T DAQStreamAnalog::configureStream()
PurposeConfigure group of channels on the DAQ device driver for streaming operation.
InputsNone
OutputNone

unconfigureStream

Syntaxint64_T DAQStreamAnalog::unconfigureStream()
PurposeUnconfigure groups of channels when DAQStream channel is closed from MATLAB.
InputsNone
OutputNone

registerCallbacks

Syntaxint64_T DAQStreamAnalog::registerCallbacks()
PurposeRegister any callback handlers required by DAQ device driver following configureStream.
InputsNone
OutputNone

unregisterCallbacks

Syntaxint64_T DAQStreamAnalog::unregisterCallbacks()
PurposeUnregister immediately prior to unconfigureStream any callback handlers registered with DAQ device driver.
InputsNone
OutputNone

Start and Stop

prestart

Syntaxint64_T DAQStreamAnalog::prestart()
Purpose

Called on a per-run basis prior to the streaming operation start, typically to reset scan counters.

InputsNone
OutputNone

start

Syntaxint64_T DAQStreamAnalog::start()
PurposeStart the streaming operation for the given channelGroupHandle.
InputsNone
OutputNone

stop

Syntaxint64_T DAQStreamAnalog::stop()
PurposeStop the streaming operation for the given channelGroupHandle.
InputsNone
OutputNone

Data Availability

getNumInputScansAvailable

Syntaxint64_T DAQStreamAnalog::getNumInputScansAvailable(uint64_T& numScansAcquired)
PurposeQuery the number of input scans available to be read by a read or readWrite call.
InputsNone
OutputNumber of scans.

getNumScansOutputByHardware

Syntaxint64_T DAQStreamAnalog::getNumScansOutputByHardware(uint64_T& numScansGenerated)
PurposeQuery the number of scans output by the hardware by a write or readWrite call.
InputsNone
OutputNumber of scans.

getOutputBufferSize

Syntaxint64_T DAQStreamAnalog::getOutputBufferSize(uint64_T& outputBufferSize)
PurposeQuery the DAQ device output buffer size in number of scans.
InputsNone
OutputBuffer size in scans.

flushOutputBuffer

Syntaxint64_T DAQStreamAnalog::flushOutputBuffer()
PurposeEmpty the output buffer.
InputsNone
OutputNone

isDeviceDone

Syntaxint64_T DAQStreamAnalog::isDeviceDone(bool& isDone)
PurposePoll the vendor driver immediately following a call to stop.
InputsNone
OutputTrue if device is done streaming.

Transfer Data

read

Syntaxint64_T DAQStreamAnalog::read(float64 * const pReadBuffer, uint64_T numReadScans)
PurposeRead acquired data from the DAQ device into the read buffer.
Inputs

pReadBuffer: buffer used by stream to store input data acquired from the device.

numReadScans: number of scans to copy into the provided buffer.

OutputNone
NotesThe stream is responsible for the lifetime of the buffer.

write

Syntaxint64_T DAQStreamAnalog::write(float64 const * const pWriteBuffer, uint64_T numWriteScans)
PurposeWrite data from the buffer to the device for output generation.
Inputs

pWriteBuffer: buffer used by stream to store output data to be generated by the device.

numWriteScans: number of valid scans to copy from the provided buffer.

OutputNone
NotesThe stream is responsible for the lifetime of the buffer.

readWrite

Syntaxint64_T DAQStreamAnalog::readWrite(float64* const pReadBuffer, uint64_T numReadScans, float64 const * const pWriteBuffer, uint64_T numWriteScans)
PurposeSimultaneously read and write data between the buffers and a DAQ device duplex channel.
Inputs

pReadBuffer: buffer used by stream to store input data acquired from the device.

numReadScans: number of scans to copy into the provided buffer.

pWriteBuffer: buffer used by stream to store output data to be generated by the device.

numWriteScans: number of valid scans to copy from the provided buffer.

OutputNone
NotesThe stream is responsible for the lifetime of the buffer.

Related Examples

More About