Click or drag to resize

Retrieving the Instrument Model

When a client application instantiates a driver, the standard Nimbus implementation of the constructor 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 Class Library to retrieve the identification information at any time during the driver session.

The InstrumentIsModel(String) is provided to allow driver code to compose conditional logical based upon the specific instrument model with which the driver is currently communicating. For instance, in the code example below, the InstrumentIsModel method is used to determine the exact SCPI command that should be sent to the instrument to program the voltage range.

Important note Important

Note the use of the Models class in the code below. This class is defined in the Models.cs file in the driver project and should always be used when referencing specific instrument models. Do not use the string literal for a particular model, else the Nimbus code roundtripping engine may not be able to roundtrip those model names if a model is added, deleted, or renamed. Using the Models class for all instrument model references also reduces the liklihood of errors in your driver implementation.

C#
void ConfigureRange(double range)
{
   // ....
     if (this.InstrumentIsModel(Models.ModelA))
   {
      this.IO.FormattedIO.PrintfAndFlush("SENS:FREQ:VOLT:RANGE %.15g", range);
     }
     else if (this.InstrumentIsModel(Models.ModelB))
     {
      this.IO.FormattedIO.PrintfAndFlush("FREQ:RANGE %.15g", range);
     }
     else if (this.InstrumentInFamily(Families.Family1)
     {
      this.IO.FormattedIO.PrintfAndFlush("FREQ:VOLT:RANGE %.15g", range);
     }
     else
     {
      this.IO.FormattedIO.PrintfAndFlush("FREQ:VOLT:RANGE %.15g", range);
     }
}

Note how the above example also makes use of InstrumentInFamily(String) method and the Families class (also defined in the Models.cs file) to incorporate logic that is common to muliple models within an instrument family. The definition of instrument models and families is managed from the Models Page of the Driver Settings Editor.

Important note Important

When using the InstrumentIsModel(String) method in conjunction with the InstrumentInFamily(String) method in an if-else construct such as the one in the above ConfigureRange example, it is important that the InstrumentIsModel checks be performed before the InstrumentInFamily checks.

Retrieving the Instrument Model in Simulation Mode

When a driver is initialized in simulation mode, the driver constructor obviously cannot use the InitializeIdentification method 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 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 InstrumentIsModel(String) method, InstrumentInFamily(String) method, and the InstrumentModel property can all 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 of the driver constructor.

  • By passing in a DriverSetup string to the driver constructor. 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
var driver = new Acme43XX("GPIB::14", false, false, "Simulate=true, DriverSetup=Model=4302");
See Also

Download a complete CHM version of this documentation here.