User`s guide

5 Acquiring Image Data
5-18
Implementing the Acquisition Thread Function
This section describes how to implement your adaptor's acquisition thread function. In a
threaded adaptor design, the acquisition thread function performs the actual acquisition
of frames from the device. When you create the thread (“Opening and Closing Connection
with a Device” on page 5-10), you specify the name of this acquisition thread function as
the starting address for the new thread.
User Scenario
The toolbox engine invokes the acquisition thread function indirectly when a user calls
the start, getsnapshot, or preview function. Once called, the acquisition thread
function acquires frames until the specified number of frames has been acquired or the
user calls the stop function.
Suggested Algorithm
Note The design of the acquisition thread function can vary significantly between various
adaptors, depending on the requirements of the device's SDK. This section does not
describe device-dependent implementation details but rather highlights required tasks
that are common to all implementations.
At its highest level, in a threaded design, an acquisition thread function typically
contains two loops:
“Thread Message Loop” on page 5-18
“Frame Acquisition Loop” on page 5-20
Thread Message Loop
The thread message loop is the main processing loop in the acquisition thread function.
You create the thread in the openDevice() function. The acquisition thread function
enters the thread message loop, waiting for the message to start acquiring frames.
Your adaptor's startCapture() function sends the message to the acquisition thread,
telling it to start acquiring frames. This example uses the WM_USER message to indicate
this state. See “Sending a Message to the Acquisition Thread” on page 5-15 for more
information.