CacheEntry::SetValue |
Updates the value for the cache entry. Note that SetValid must be called to set the entry's valid state to true.
void SetValue(const T& value);
[in] The value to test for equality against the cached value, if present. The data type T is that of the CacheEntry template instance.
The following example demonstrates use of the SetValue function.
ViStatus _VI_FUNC acme4321_set_BANDWIDTH(ViSession Vi, ViConstString RepCapIdentifier, ViReal64 AttributeValue)
{
auto status = VI_SUCCESS;
// Retrieve the cache entry for the Bandwidth attribute
//
auto& entry = GetCacheEntry<ViReal64>(Vi, ACME4321_ATTR_BANDWIDTH);
// If the value is in the cache AND is valid, simply return since we don't need to send the instrument command
//
if (entry.HasValue(AttributeValue))
{
return status;
}
// If we get this far, then the new value is not in the cache, so we must communicate with the instrument to set the value
//
status = viPrintf(GetVisaSession(Vi), "SENS:BAND %0.15g\n", AttributeValue);
ReturnOnError(status);
// The new value was successfully sent to the instrument, so update the cache
//
entry.SetValue(AttributeValue);
entry.SetValid();
return status;
}