Click or drag to resize

DriverSession::GetDriverSetupOption

Retrieves the value of an option passed as part of the DriverSetup string during driver initialization.

virtual bool GetDriverSetupOption(const std::string& strName, std::string& strValue) const;

bool GetDriverSetupOption(ViSession Vi, const std::string& strName, std::string& strValue);
Parameters
Vi

[in] ViSession handle for the driver session.

strName

[in] Name of the DriverSetup option to return. This name is case insensitive.

strValue

[out] Value of the DriverSetup option corresponding to the strName parameter. If the named value is not found, this parameter value is undefined.

Return Value

Returns true if the named value was passed as part of the DriverSetup string and false otherwise.

Remarks

When the driver is initialized, Nimbus parses the DriverSetup string into name-value pairs and stores them with the session. Note that the DriverSetup string may be passed directly to the driver's InitWithOptions function or it may be read from the IVI Configuration Store. This function is used to retrieve the results of that DriverSetup string parsing. This provides a simple mechanism to define and process driver-specific initialization options.

Example

The following code demonstrates how to use the GetDriverSetupOption function:

C++
/////////////////////////
// Client.cpp
// 
// Client code initializes the driver.
// 
ViSession session;
ViStatus status = acme4321_InitWithOptions("GPIB0::13", VI_FALSE, VI_FALSE, "Cache=VI_TRUE, DriverSetup= Model=ModelA, MyOption=Foo, YourOption=Bar", &session);


/////////////////////////
// acme4321.cpp
// 
// Driver implementation access the parsed DriverSetup name-value pairs.
// 
ViStatus _VI_FUNC acme4321_ConfigureSweep(ViSession Vi, ViReal64 StartFrequency, ViReal64 StopFrequency)
{
    std::string strMyOption;
    auto bFound = GetDriverSetupOption(Vi, "MyOption", strMyOption);
    assert(bFound);

    printf(strMyOption.c_str());    // prints "Foo"

    std::string strYourOption;
    bFound = GetDriverSetupOption(Vi, "YourOption", strYourOption);
    assert(bFound);

    printf(strYourOption.c_str());  // prints "Bar"

    // ...
}

Download a complete CHM version of this documentation here.