Click or drag to resize

DriverSession::ResetDefaults

Configures the initial settings for the driver and instrument based on the settings loaded from the IVI Configuration Store the driver session was initialized.

virtual ViStatus ResetDefaults();
Remarks

This function is used in the implementation of the IVI-defined ResetWithDefaults function. The ResetWithDefaults function performs the same operations as the reset function and then applies the settings to the driver that were initially in effect when the driver session was initialized.

The default implementation of ResetDefaults restores the six IVI-defined inherent initialization options to the original values they had when the driver session was initialized. These six IVI-defined inherent options are Cache, InterchangeCheck, QueryInstrStatus, RangeCheck, RecordCoercions, and Simulate.

Rather than customize the implementation of the ResetWithDefaults function directly, driver developers can override the ResetDefaults function in their DriverSession-derived class in the DriverSession.h file in order to apply additional initial settings. The example below demonstrates this.

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 ViStatus ResetDefaults()
    {
        // It's important to always call the base implementation, because the standard IVI inherent options, such as
        // state caching, range checking, simulation, etc, all need to be set to their original values.
        // 
        auto status = __super::ResetDefaults();
        ReturnOnError(status);

        // Read a driver-defined configurable initial setting and use it to perform some driver-specific re-initialization
        // 
        std::string strMySetting;
        auto bFound = GetConfigSettingInt32(Vi, "MySetting", strMySetting);
        assert(bFound);

        // ... Use the strMySetting to reset some piece of driver state

        return status;
    }
};

Download a complete CHM version of this documentation here.