Using The Option String |
Top Previous Next |
An IVI driver can operate without the presence of an actual instrument by using simulation mode. When simulation is turned on, the driver performs no instrument communication, but attempts to generate results which allow client applications to reasonably execute. You can turn on simulation using either of the following two techniques: •Passing the "simulate=VI_TRUE" option string parameter to the InitWithOptions function. •Setting the SIMULATE attribute to VI_TRUE. The IVI-C driver contains a SIMULATE attribute. Note that you can turn simulation on, if you initialize a driver with it off. However, if you initialize an IVI-C driver with simulation turned on, you will get an error if you attempt to later turn it off. This is because you cannot initiate a live I/O session with an instrument after you have called the InitWithOptions function. The fourth and last parameter to the InitWithOptions function is the option string. See the help on InitWithOptions for more details. To turn simulation on with the option string, include the following in the option string:
simulate=VI_TRUE For example, the InitWithOptions call might look like this: Btn55xxx_InitWithOptions("USB::0x1BFE::0x5500::8728::BTN", VI_TRUE, VI_TRUE, "Simulate=VI_TRUE", &session); When the simulate option is set VI_TRUE, the value of the resource descriptor parameter (the first parameter above) is ignored. This is because no I/O connection will be made with the instrument, as is required by IVI-3.1: Driver Architecture Specification. The Driver Session Simulate AttributeA DriverSession in the IVI Configuration Store contains properties for the same items which can be set with the option string parameter. The name of a DriverSession, or the name of a LogicalName which points to a DriverSession, can be used as the first parameter to InitWithOptions. If the SIMULATE attribute in the DriverSession is true, the driver is initialized in simulation mode. Changing the Instrument ModelMany drivers support more than one instrument model. Drivers will typically select one of these as the default model by creating a special type of entry in the IVI Configuration Store known as a Configurable Initial Settings. You can modify the Model value in the Configurable Initial Settings for the DriverSession of interest, or you can simply specify the model to simulate at runtime during the call to Initialize. To have the driver simulate a specific model of your choosing, simply add the desired model to the DriverSetup string using the following special syntax: Simulate=VI_TRUE, DriverSetup=Model=55006 The complete InitWithOptions call becomes: Btn55xxx_InitWithOptions("USB::0x1BFE::0x5500::8728::BTN", VI_TRUE, VI_TRUE, "Simulate=VI_TRUE, DriverSetup= Model=55006", &session); If you set the model to a value not supported by the driver, the driver reports an error. Limitations of SimulationSimulation is designed to allow the driver to be used without an instrument or any I/O software or hardware. However, simulation is not intended to fully emulate the instrument. There are some important differences you should be aware of: •Many instruments have status systems, and these are not live. For instance, you can set Enable and Transition registers but queries of Condition and Event registers will always return a fixed value, which is usually zero. •There often is no parameter range checking or coercion unless done in the driver. Most drivers depend on the instrument to perform range checking and coercion of parameter values. In simulation mode, this will not occur. For example setting a frequency parameter to 1E99 will be accepted without error in simulation where an instrument would return a "parameter out of range" error. •Btn55xxx_error_query typically returns no error. •Measurement data is not live. Most data queries will return a fixed value or a small array of values. |