Enabling Instrument Simulation
You can simulate an instrument with IVI drivers. Using the simulation features, you can develop test code even when your instruments are not available. You can also use simulation to test for interchangeability. If you use IVI technology to build a test system, you can integrate the driver of the new instrument and run test programs against this driver in simulation mode. In effect, you can test a new instrument before you purchase it to make sure it can work in your system.
An IVI driver implements three different simulation capabilities: instrument driver calls; range checking and parameter coercion; and simulated output data.
Instrument Driver Calls
When you enable simulation, IVI instrument drivers do not attempt to communicate with the instrument. Therefore, you can make instrument driver function calls from your program and not receive I/O errors indicating that the instrument is not present.
You can use this simulation capability with IVI class drivers and specific drivers, simulating calls to a class driver and to instrument specific functions in the specific driver.
You can enable simulation through MAX. Alternatively, you can use the Initialize With Options function to enable simulation. The Initialize With Options function allows you to pass a string that presets a number of driver attributes. One of these attributes is the simulation attribute. When you use this function to preset the simulation attribute, you alert the driver that the instrument is not connected to the computer or that you wish to use simulation mode.
Range Checking and Parameter Coercion
You can range check and coerce all input parameters. Every time you try to send a value to an instrument to configure a setting, the driver ensures that the value is valid for the particular setting on that instrument. If necessary, the specific driver coerces the value to an acceptable one for the instrument. The range checking and coercion operations happen within the specific driver software. Even when you write test code without connecting the instrument, the specific driver ensures that each value you attempt to send to the instrument is valid.
Note The specific driver performs the range checking and coercion operations. Therefore, you can use this simulation capability with a class driver or a specific driver. |
Simulated Output Data
You can create simulated data for output parameters of functions. The IVI architecture uses one of the following methods to generate simulated data:
- Specific Driver Simulation—Each specific driver has basic built-in algorithms to simulate data generation. For example, when using a DMM-specific driver in simulation mode, the Read function may return a random number within the valid range of the DMM's current mode. When you use an oscilloscope specific driver in simulation mode, the Read Waveform function may return a simple sinewave array of data within valid ranges for the oscilloscope. This simple data generation process returns data values to the program variables so that subsequent function calls do not fail for lack of data. However, a simple or random data may not be meaningful.
- User-Defined Simulation—Because you have access to the specific driver source code, you can modify the driver, adding your own data generation algorithms to generate simulated data that more closely applies to the unit under test (UUT) or the application on which you are working. However, your code is only useful for that particular specific driver. If you change instruments in the future, you must re-implement this work for each new instrument you add. When you want customized simulation code that will work regardless of which specific driver is used, the IVI class drivers provide simulation tools.