![]() | 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);
[in] ViSession handle for the driver session.
[in] Name of the DriverSetup option to return. This name is case insensitive.
[out] Value of the DriverSetup option corresponding to the strName parameter. If the named value is not found, this parameter value is undefined.
Returns true if the named value was passed as part of the DriverSetup string and false otherwise.
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.
The following code demonstrates how to use the GetDriverSetupOption function:
///////////////////////// // 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" // ... }