Click or drag to resize

Retrieving the Intrument Model

When a client application initializes a driver via the IIviDriver::Initialize method, the standard Nimbus implementation of that method executes the InitializeIdentification 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 Template Library to retrieve the identification information at any time during the driver session.

The GetModel 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 GetModel function in a multi-model driver project to implement conditional logic. For instance, in the code example below, the GetModel function is used to determine the exact SCPI command that should be sent to the instrument to program the voltage range.

C++
HRESULT Acme43XX::IAcme43XXFrequency_put_Range(double Range)
{
   HRESULT hr = S_OK;

   CString strModel = GetModel();

   if (strModel == _T("4301"))
   {
      hr = InstrPrintf(_T("SENS:FREQ:VOLT:RANGE %.15g"), Range);
   }
   else if (strModel == _T("4302"))
   {
      hr = InstrPrintf(_T("FREQ:RANGE %.15g"), Range);
   }
   else if (strModel == _T("4303"))
   {
      hr = InstrPrintf(_T("FREQ:VOLT:RANGE %.15g"), Range);
   }
   else
   {
      hr = err.ModelNotSupported();
   }

   return hr;
}
Retrieving the Instrument Model in Simulation Mode

When a driver is initialized in simulation mode, the IIviDriver::Initialize method obviously cannot use the InitializeIdentification 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 GetModel 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 IIviDriver::Initialize.

  • By passing in a DriverSetup string to the IIviDriver::Initialize method. 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 Initialize method.

C#
// Client.cs
IIviDriver driver = new Acme43XX();

driver.Initialize("GPIB::14", false, false, "Simulate=true, DriverSetup=Model=4302");
See Also

Download a complete CHM version of this documentation here.