![]() | GetStringValueForSimulation Macro |
Returns a model-based string value to return from a function or attribute value when simulating.
#define GetStringValueForSimulation(Vi, bufferSize, buffer, ...)
[in] ViSession handle for the driver session.
[int] The number of characters allocated by the caller in the buffer parameter.
[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 buffer 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 GetStringValueForSimulation function.
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; } // ... }