Click or drag to resize

Using the I/O Object

All of the built-in instrument communication features of Nimbus are built on top of an I/O object. The I/O object supplies a wide variety of functions for reading and writing data to and from an instrument. The I/O object is an instance of a special class known as an I/O provider. Nimbus ships with two pre-built I/O providers -- the VISA-COM I/O provider and the VISA-C I/O provider.

For detailed information on the functions available on the I/O object, see the Nimbus Template Library topics on the I/O object.

Accessing the I/O Object

When the driver's Initialize function is called, Nimbus automatically creates the I/O object and associates it with the instrument session. The type of I/O object created depends upon the selection made in the I/O Page of the Driver Settings Editor. Often, the I/O object created will be an instance of CVisaComSession (the VISA-COM I/O provider) or an instance of CVisaCSession (the VISA-C I/O provider). In either case, the I/O object functions are accessed within a driver function by simply using the io property, as shown below.

// CoAcme4321.cpp
STDMETHODIMP Acme4321::IAcme4321_Configure()
    HRESULT hr = S_OK;

    hr = io.Printf(_T("SENS:OUTP:ENAB ON"));

    return hr;

When the user types "io" and then a ".", IntelliSense presents a list of all of the functions available for the type of I/O provider in use. The functions available for the VISA-COM and VISA-C I/O providers will be very similar, while those available for a custom I/O provider would include any specialized functions specific to that provider.

Best Practices for Using the I/O Object

One of the key advantages of using the I/O object is that the driver implementation code can be largely independent of the underyling I/O library in use -- be it VISA-COM, VISA-C, or a custom I/O library. The Nimbus Template Library provides a uniform set of functions for instrument I/O that can operate on top of any arbitrary I/O library. By using these common I/O functions instead of provider-specific functions or direct calls into a custom library, the driver code can remain unchanged when a new I/O library is introduced or other I/O requirements change.

The Nimbus Template Library documentation for the I/O object is divided into sections that are general to all I/O providers and those that are specific to the VISA-COM or VISA-C I/O providers. All of the functions in the Nimbus Template Library topic I/O Object and its subtopics, can be used with any I/O provider, with the exception of those in the topic VISA-Specific Functions.

See Also

Other Resources

Download a complete CHM version of this documentation here.