Main Content

Creating an Adaptor

To create an adaptor, you must implement the C++ routines and the classes required by the adaptor framework. The following outlines one way to develop an adaptor that divides the task into several smaller tasks, called stages. This staged development model has been shown to be an effective way to create an adaptor.

Staged Development Model

Stage 1: Familiarize Yourself with the Adaptor Kit and Device SDK

Before you start developing an adaptor, you must gather information about the device (or devices) to help you make design decisions.

  • Familiarize yourself with adaptors and adaptor development by looking at the demo adaptor which is included with the adaptor kit — see Looking at the Demo Adaptor

  • Familiarize yourself with your device's SDK. Devices provide the tools you need to access and control them programmatically. You must learn your device's requirements for initialization, startup, and acquiring data, and the SDK functions used to perform these tasks.

  • Determine what device or devices you want to support with your adaptor. You can create an adaptor to support one particular device, a group of devices offered by a particular vendor, or a group of devices that all support a common interface. You must also determine the formats supported by the device and the properties of the device that you want to make available to users of your adaptor.

Stage 2: Set Up Your Build Environment

You must set up the required adaptor build environment, which includes specifying the names and locations of required header files and libraries. Setting Up a Build Environment on Windows Systems provides this information.

Stage 3: Provide Hardware Information

In this stage, you start development by creating a stub implementation of your adaptor. Every adaptor must provide the toolbox with information about the device (or devices) it makes available to users. As a first step, you define the labels you want to use to identify the devices available through your adaptor and the formats they support, and you implement the adaptor functions that return this information to users. The toolbox displays these labels to users who must specify the device and format they want to use for an acquisition.

After building this stub implementation of your adaptor DLL and registering it with the toolbox, you can use the imaqhwinfo function and verify that the toolbox can find your adaptor and load it. For more information about this stage, see Using Adaptor Exported Functions.

Stage 4: Define Your Adaptor Class

In this stage, you define your adaptor class and add a stub implementation of this class to your adaptor project. Every adaptor must define an adaptor class that is a subclass of the adaptor kit IAdaptor class.

After building your adaptor DLL, a call to the videoinput function instantiates a video input object with your adaptor. For more information, see Defining Your Adaptor Class.

Stage 5: Implement Virtual Functions in Adaptor Class

In this stage, you flesh out the stub implementations of the virtual functions in your adaptor class. After completing this stage, you will be able to acquire data from your device and bring it into the MATLAB® workspace.

In addition, in this step you can also implement support for defining a region-of-interest (ROI) and for using hardware triggering, if your device supports this capability. For more information, see Acquiring Image Data.

Stage 6: Choose Which Device Properties to Expose

In this stage, you decide which properties of the device you want to expose to toolbox users. You make this determination by reading the device's SDK documentation, determining its capabilities, and deciding which capabilities toolbox users will expect to configure. Once you decide to expose a property, you must decide on a name for the property, determine its data type, and, optionally, the range of valid values. As an alternative, you can define device-specific properties in an image device definition file (IMDF). For more information, see Defining Device-Specific Properties.