Click or drag to resize

Retrieving the Instrument Model

When a client application initializes a driver via the init or InitWithOptions function, the standard Nimbus implementation of those functions execute the GetIdentificationInfo function to query the instrument for identification information, such as the manufacturer, the firmware revision, and the specific instrument model. Nimbus caches the results of this process so that the driver developer (and the Nimbus-generated code) can use functions within the Nimbus Runtime Library to retrieve the identification information at any time during the driver session.

The InstrumentModel function is provided to allow driver code to retrieve the specific instrument model with which the driver is currently communicating. The driver developer can use the InstrumentModel function in a multi-model driver project to implement conditional logic. For instance, in the code example below, the InstrumentModel function is used to determine the exact SCPI command that should be sent to the instrument to program the voltage range.

C++
ViStatus _VI_FUNC acme4321_ConfigureRange(ViSession Vi, ViReal64 Range)
{
   // ...

   auto strModel = InstrumentModel(Vi);

   if (strModel == "4301")
   {
      status = viPrintf(GetVisaSession(Vi), "SENS:FREQ:VOLT:RANGE %.15g", Range);
   }
   else if (strModel == "4302")
   {
      status = viPrintf(GetVisaSession(Vi), "FREQ:RANGE %.15g", Range);
   }
   else 
   {
      status = viPrintf(GetVisaSession(Vi), "FREQ:VOLT:RANGE %.15g", Range);
   }

   // ...
}
Retrieving the Instrument Model in Simulation Mode

When a driver is initialized in simulation mode, the InitWithOptions function obviously cannot use the GetIdentificationInfo function to query the instrument for its identification information, such as the instrument model. Rather, the instrument model must be provided to the driver so that all of the model-based logic (both developer-written and Nimbus-generated) will operate properly. The model that is provided during simulation is referred to as the simulated model. When the driver is running in simulation mode, the InstrumentModel function can be used in exactly the same fashion as with a live session.

The simulated model can be specified in one of two ways:

  • By using the Models Page of the Driver Settings Editor to specify a default model. The default model is stored by the driver installer in the IVI Configuration Store and is automatically retrieved by the Nimbus implementation InitWithOptions.

  • By passing in a DriverSetup string to the InitWithOptions function. The client application includes in the DriverSetup string a name-value pair of the form "Model=<model>". A simulated model provided in this way overrides the default model specified by the driver developer in the Driver Settings Editor.

The code below demonsrates how a client application can specify a simulated model when calling the driver's InitWithOptions method.

C++
// Client.cpp
ViSession session;
ViStatus status = acme4321_InitWithOptions("GPIB::14", VI_FALSE, VI_FALSE, "Simulate=true, DriverSetup= Model=4302", &session);
See Also

Download a complete CHM version of this documentation here.