User`s guide

5 Acquiring Image Data
5-10
Opening and Closing Connection with a Device
Adaptors typically open a connection with the device in their openDevice() function
and close the connection in their closeDevice() function. For most devices, opening
a connection to the device reserves it for exclusive use. Closing the device releases the
device.
Note The toolbox engine actually calls the IAdaptor class open() member function
to open a connection with a device and the close() function to close a connection with
a device. These function then call your adaptor's openDevice() and closeDevice()
functions. If your adaptor needs to open or close a device, use the open() and close()
functions, rather than calling openDevice() or closeDevice() directly.
Suggested Algorithm for openDevice()
The openDevice() function typically performs the following tasks.
1
Test whether the device is already open by calling the IAdaptor class isOpen()
function. If the device is already open, your openDevice() function should return
true. If the device is not already open, your openDevice() function should
establish a connection to the device using device SDK calls.
2
Start the acquisition thread. See “Starting an Acquisition Thread” on page 5-10
for more information.
Note Starting a separate thread is only required if your adaptor uses a thread-
based design. Adaptors can also use asynchronous interrupts (callbacks) to acquire
frames, if the device supports this. In this scenario, adaptors receive notification
asynchronously when data is available. For information about using this method,
refer to the documentation for your device's SDK.
Starting an Acquisition Thread
To start an acquisition thread, use the Windows CreateThread() function. The
CreateThread() function creates a thread that executes within the virtual address
space of the calling process.
The CreateThread() function accepts these parameters.