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 is provided to allow driver code to compose conditional logic 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.
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 method and the Families class (also defined in the Models.cs file) to incorporate logic that is common to multiple models within an instrument family. The definition of instrument models and families is managed from the Models Page of the Driver Settings Editor.
Retrieving the Instrument Model in Simulation Mode
Section titled “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 method, InstrumentInFamily 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
DriverSetupstring to the driver constructor. The client application includes in theDriverSetupstring 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 demonstrates how a client application can specify a simulated model when calling the driver’s Initialize method.
var driver = new Acme43XX("GPIB::14", false, false, "Simulate=true, DriverSetup=Model=4302");See also
Section titled “See also”- Adding Support for Multiple Instrument Models
InstrumentModelInstrumentIsModelInstrumentInFamily