EasyManua.ls Logo

VTI Instruments EX1000A - Page 118

VTI Instruments EX1000A
320 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
VTI Instruments Corp.
118 EX10xxA Programming
`
Host PC
time time
Receive streaming data
Receive streaming data
Receive streaming data
Receive streaming data
Receive
:
vtex
10
xxa
_
trig
_
init
()
response
Send
:
vtex
10
xxa
_
enable
_
streaming
_
data
()
request
Receive
:
vtex
10
xxa
_
enable
_
streaming
_
data
()
response
Send
:
vtex
10
xxa
_
trig
_
init
()
request
EX1016A
FIGURE 6-3: STREAMING DATA NETWORK EXAMPLE
Basic Streaming Data Usage
When using the streaming data interface, via the vtex10xxA_enable_streaming_data function, the
user application provides a callback function. Internally, the instrument driver creates a thread and
then opens a socket for streaming data between the host PC and the instrument. The newly
constructed thread does a “blocking” read on the socket, which causes it to “sleep” (become idle)
until data arrives. When acquisition data arrives, the thread begins executing, receives the
acquisition data from the instrument, executes the user-provided callback function, passing in the
newly arrived data, and then returns to the “sleep” state. The callback function can do whatever is
necessary for the application: write the acquisition values to a file on disk, perform limit checking
on the acquisition values, update an application-specific data structure (e.g., FIFO) post the
acquisition data to a database or spreadsheet, etc. This behavior is illustrated in Figure 6-4, with the
reception of streaming data causing the user-provided callback function to be executed.
NOTE Since the callback function executes asynchronously in the same process as the main application
thread, it is important that any data or data structures used by both threads are suitably protected to
guarantee consistency. As with any multi-thread application, care must be taken when using inter-
thread communication primitives (e.g., mutexes) to prevent deadlocks and livelocks. Similarly,
performing GUI operations (e.g., updating an on-screen graph) within the callback function needs
to be implemented carefully.

Table of Contents

Related product manuals