GetValueForSimulation Macro |
Returns a model-based value to return from a function or attribute value when simulating.
#define GetValueForSimulation(Vi, pValueOut, ...)
[in] ViSession handle for the driver session.
[out] Simulated value chosen based from those supplied in the model-specific list of values in the variable argument parameter.
[in] A variable argument list of model-value pairs. The function returns in the pValueOut parameter a value from this list based on matching the connected instrument model with one of the entries in this list.
The following example demonstrates use of the GetValueForSimulation function.
ViStatus _VI_FUNC acme4321_get_BANDWIDTH(ViSession Vi, ViConstString RepCapIdentifier, ViReal64* AttributeValue)
{
// ...
if (SimulationEnabled(Vi))
{
if (!cacheManager.GetCachedValue(AttributeValue))
{
// The entries below indicate which values should be returned based upon the instrument model
// being simulated. The entry with no model specified (the one with value 1.0E9) will be chosen
// if the model is something other than ModelA, ModelB, or ModelC.
//
GetValueForSimulation(
Vi, AttributeValue,
{ 1.0E9 },
{ "ModelA", 2.0E9 },
{ "ModelB", 5.0E9 },
{ "ModelC", 7.0E9 },
);
}
return VI_SUCCESS;
}
// ...
}