Click or drag to resize

DriverSession::InstrumentSupported

Indicates if the connected instrument (or model being simulated) is supported by the driver.

virtual bool InstrumentSupported() const;

bool InstrumentSupported(ViSession Vi);
Parameters
Vi

[in] ViSession handle for the driver session.

Return Value

Returns true if the connected instrument (or the model being simulated) is supported by the driver and false otherwise.

Remarks

The value for the instrument model tested here is set by the implementation of the GetIdentificationInfo function. By default, Nimbus implements the GetIdentificationInfo by sending a *IDN? query to the instrument and parsing an IEEE 488.2 response. The model parsed from this response is then compared to the list of models configured on the Models Property Page.

Driver developers can override this function in their DriverSession-derived class in the DriverSession.h file in order to provide different comparison logic for validating the connected instrument model. The example below demonstrates this.

When simulating, the model used is set by the Model value passed as part of the DriverSetup string. If no Model value was passed to the driver initialization function, then the default instrument model is returned when simulating.

Example

The following code demonstrates how to override the InstrumentSupported function to implement custom model validation logic:

C++
// DriverSession.h
class Acme4321DriverSession : public DriverSession
{
public:
    Acme4321DriverSession(ViSession handle)
        : DriverSession(handle, 2000, 2000, 2000, false, 1000)
    {
    }

    virtual bool InstrumentSupported() const
    {
        // Check the static list of models first
        // 
        auto bSupported = __super::InstrumentSupported();

        if (!bSupported)
        {
            // Doesn't match a pre-configured model, so try a regular expression
            // 
            static const std::regex rx("MODEL[a-eA-E]", std::regex_constants::icase);

            bSupported = std::regex_match(InstrumentModel(), rx);
        }

        return bSupported;
    }
};

Download a complete CHM version of this documentation here.