AP’s API Wrapper resolves .NET limitations in VEE and MATLAB, allowing them to access the complete APx API for automation and systems integration.
The APx API (Application Programming Interface) supports the .NET framework, allowing extensive automation and data exchange using any .NET compatible programming language. Two of the popular languages that work with APx are VEE from Agilent, and MATLAB from The Mathworks. VEE is a graphical language designed to utilize interconnected hardware for measurement and analysis. MATLAB is optimized for computationally intensive tasks and has advanced graphing capabilities.
The APx API makes extensive use of .NET interfaces. In programming terms, an interface contains no functional code, but serves as a bridge between a program and the outside world. Although VEE and MATLAB can see these interfaces, their .NET implementation only enumerates a small subset of the properties and methods that are contained in them, leaving the others inaccessible.
To overcome this problem, AP software engineers have created a class wrapper—a dynamic link library (DLL) that wraps the APx API interfaces in classes, so that all the API objects become visible from within VEE and MATLAB. The wrapper is available as a separate download for APx500 2.4, but starting with APx500 2.5, it is installed along with the APx application. We aren’t currently aware of any other programming languages that need the wrapper, but if any arise, the wrapper should accommodate them as well.
Using the wrapper imparts no performance penalty, and it is essentially transparent—all you have to do is reference it at the beginning of your code. In a default installation, you would reference the API wrapper at:
C:\Program Files\Audio Precision\APx500 x.x\Api\AudioPrecision.API2.dll
where x.x is the version of APx500 you are running.
To use the wrapper in a VEE program, proceed as follows:
1) Open VEE and add references to both the standard and wrapper APx API .dll files.
2) Create an instance of the "APx500_Application" object. This is the API object contained in the new DLL. To do so, select a Constructor for the APx500_Application object under AudioPrecision.API2 in the Function and Object Browser.
3) Once the instance of the APx500_Application object has been added, you can build your APx500 program by adding a series of .NET operation builders.
A simple sample program written in VEE is shown below. It does the following:
Note that if you open the *.vee file over a network, you may receive .NET security errors, because VEE creates a copy of the AudioPrecision.API2.dll in the folder where the *.vee program is located. You may be able to resolve this in your .NET configuration, or alternatively, just run the *.vee file from a local disc.
Our MATLAB code accomplishes the same tasks as the VEE example above. The first three lines reference the API wrapper.
The API wrapper now gives VEE and MATLAB complete access to the APx API. That, along with our existing .NET connectivity and the APx LabView driver, makes it possible to integrate APx into virtually any test and measurement environment.
This APx API wrapper dll enables you to access the entire APx API when using Agilent VEE and The Mathworks MATLAB. A discussion and instructions are in the kb article "Using APx with VEE." This download is only necessary for APx500 v2.4. APx500 v2.5 and later already include it.
An Agilent VEE example that opens APx500, makes settings, and runs an acquisition. For more details about controlling APx500 using VEE, read the associated kb article. After downloading, open in a text editor and modify the .NET references to refer to your current version of APx500.