Click or drag to resize

GetStringValueForSimulation Macro

Returns a model-based string value to return from a function or attribute value when simulating.

#define GetStringValueForSimulation(Vi, bufferSize, buffer, ...)
Parameters
Vi

[in] ViSession handle for the driver session.

bufferSize

[int] The number of characters allocated by the caller in the buffer parameter.

buffer

[out] Simulated value chosen based from those supplied in the model-specific list of values in the variable argument parameter.

... (variable arguments)

[in] A variable argument list of model-value pairs. The function returns in the buffer parameter a value from this list based on matching the connected instrument model with one of the entries in this list.

Example

The following example demonstrates use of the GetStringValueForSimulation function.

C++
ViStatus _VI_FUNC acme4321_get_USER_NAME(ViSession Vi, ViConstString RepCapIdentifier, ViInt32 AttributeValueBufferSize, ViChar AttributeValue[])
{
    // ...

    if (SimulationEnabled(Vi))
    {
        if (!cacheManager.GetCachedValue(AttributeValueBufferSize, 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 "Mark") will be chosen
            // if the model is something other than ModelA, ModelB, or ModelC.
            // 
            GetStringValueForSimulation(
                Vi, AttributeValueBufferSize, AttributeValue,
                { "Mark" },              
                { "ModelA", "Fred" },
                { "ModelB", "Tom" },
                { "ModelC", "Alice" },
            );
        }

        return VI_SUCCESS;
    }    

    // ...
}

Download a complete CHM version of this documentation here.