AFData Class
- Last UpdatedNov 18, 2025
- 9 minute read
- PI System
- AF SDK 2024 R2
- Developer
The AFData object is associated with a single AFAttribute
and is used to retrieve and set extended historical data.
It is accessed through the Data property of an AFAttribute.

Inheritance Hierarchy
SystemObject
OSIsoft.AF.DataAFData
OSIsoft.AF.DataAFData
Namespace: OSIsoft.AF.Data
Assembly: OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.1.1.1182
Syntax
public class AFData
Public Class AFData Dim instance As AFData
public ref class AFData
type AFData = class end
The AFData type exposes the following members.
Properties
| Name | Description | |
|---|---|---|
| Attribute |
The AFAttribute associated with this object.
| |
| BufferOption |
Indicates the AFBufferOption to use when updating values.
| |
| CacheEnabled |
Whether AFDataCache is enabled for this AFData instance.
| |
| CacheStartTime |
The earliest event time stamp in the AFDataCache for this AFData instance.
| |
| EventsCached |
The number of events cached for this AFData instance.
|
Methods
| Name | Description | |
|---|---|---|
| CreateWithInputDataProvider |
Creates a new AFData instance that will evaluate this attribute with input data obtained by the specified input data provider.
| |
| EndOfStream |
Returns the end-of-stream AFValue.
| |
| EndOfStreamAsync |
Get the value with the largest timestamp for a data stream.
| |
| Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
| FilteredSummaries |
This method, when supplied a filter expression that evaluates to true or false,
evaluates it over the passed time range. For the time ranges where the expression evaluates to true, the method calculates
the requested summaries on the source attribute.
| |
| FilteredSummariesAsync |
This method, when supplied a filter expression that evaluates to true or false,
evaluates it over the passed time range. For the time ranges where the expression evaluates to true, the method calculates
the requested summaries on the source attribute.
| |
| GetAllCachedValues |
Get all the events in the AFDataCache for this AFData instance.
| |
| GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
| GetType | Gets the Type of the current instance. (Inherited from Object.) | |
| InterpolatedValue |
Returns a single AFValue whose value is
interpolated at the passed time.
| |
| InterpolatedValueAsync |
Returns a single AFValue whose value is interpolated at the passed time.
| |
| InterpolatedValues |
Retrieves interpolated values over the specified time range at the specified sampling interval.
| |
| InterpolatedValuesAsync |
Retrieves interpolated values over the specified time range at the specified sampling interval.
| |
| InterpolatedValuesAtTimes |
Retrieves interpolated values at the specified times.
| |
| InterpolatedValuesAtTimesAsync |
Retrieves interpolated values at the specified times.
| |
| PlotValues |
Retrieves values over the specified time range suitable for plotting over the number of intervals (typically represents pixels).
| |
| PlotValuesAsync |
Retrieves values over the specified time range suitable for plotting over the number of intervals (typically represents pixels).
| |
| RecordedValue |
Returns a single recorded AFValue based on the
passed time and mode.
| |
| RecordedValueAsync |
Returns a single recorded AFValue based on the passed time and mode.
| |
| RecordedValues |
Returns a list of compressed values for the requested time range
from the source provider.
| |
| RecordedValuesAsync |
Returns a list of values for the requested time range
from the source provider.
| |
| RecordedValuesAtTimes |
Retrieves recorded values at the specified times.
| |
| RecordedValuesAtTimesAsync |
Retrieves recorded values at the specified times.
| |
| RecordedValuesByCount |
This method returns a specified number of compressed values beginning at the requested start time in the direction specified.
| |
| RecordedValuesByCountAsync |
This method returns a specified number of compressed values beginning at the requested start time in the direction specified.
| |
| ReplaceValues(AFTimeRange, AFValues) |
This method removes existing data within the specified AFTimeRange and
inserts the specified values on the target system using the configured data reference.
| |
| ReplaceValues(AFTimeRange, AFValues, AFBufferOption) |
This method removes existing data within the specified AFTimeRange and
inserts the specified values on the target system using the configured data reference.
| |
| ReplaceValuesAsync(AFTimeRange, AFValues, CancellationToken) |
This method removes existing data within the specified AFTimeRange and
inserts the specified values on the target system using the configured data reference.
| |
| ReplaceValuesAsync(AFTimeRange, AFValues, AFBufferOption, CancellationToken) |
This method removes existing data within the specified AFTimeRange and
inserts the specified values on the target system using the configured data reference.
| |
| Summaries |
Returns several summaries for a single attribute over a time range for each interval within the range.
| |
| SummariesAsync |
Returns several summaries for a single attribute over a time range for each interval within the range.
| |
| Summary |
Returns several summaries for a single attribute over a single time range.
| |
| SummaryAsync |
Returns several summaries for a single attribute over a single time range.
| |
| ToString | Returns a string that represents the current object. (Inherited from Object.) | |
| UpdateValue(AFValue, AFUpdateOption) |
This method writes, replaces, or removes a value on the target system using the configured data reference.
| |
| UpdateValue(AFValue, AFUpdateOption, AFBufferOption) |
This method writes, replaces, or removes a value on the target system using the configured data reference.
| |
| UpdateValues(AFValues, AFUpdateOption) |
This method writes or replaces one or more values on the target system using the configured data reference.
| |
| UpdateValues(AFValues, AFUpdateOption, AFBufferOption) |
This method writes or replaces one or more values on the target system using the configured data reference.
| |
| UpdateValuesAsync(AFValues, AFUpdateOption, CancellationToken) |
This method writes or replaces one or more values on the target system using the configured data reference.
| |
| UpdateValuesAsync(AFValues, AFUpdateOption, AFBufferOption, CancellationToken) |
This method writes or replaces one or more values on the target system using the configured data reference.
|
Remarks
The AFData object is created on demand when accessed via the Data property of the AFAttribute. If the attribute will be repeatedly queried, this object should be cached. If retrieving data for multiple attributes, use the AFListData class retrieved from the Data.
The AFAttribute.SupportedDataMethods and AFDataReference.SupportedDataMethods properties can be checked to see if a data method is supported.
| This method, property, or class is not available in the legacy .NET 3.5 version of the SDK. |
Examples
// This example demonstrates how to create an attribute for an // element and retrieve values using the 'Data' object. // Get the Database PISystems myPISystems = new PISystems(); PISystem myPISystem = myPISystems.DefaultPISystem; AFDatabase myDB = myPISystem.Databases.DefaultDatabase; // Create an Element AFElement myElement = myDB.Elements.Add("MyElement"); // Create an Attribute AFAttribute myAttribute = myElement.Attributes.Add("MyAttribute"); myAttribute.DefaultUOM = myPISystem.UOMDatabase.UOMs["kelvin"]; myAttribute.DataReferencePlugIn = AFDataReference.GetPIPointDataReference(myPISystem); myAttribute.ConfigString = @"\\%Server%\sinusoid"; // Get the Recorded Value for the Attribute AFTime myTime = DateTime.Now.AddDays(-1); AFValue value = myAttribute.Data.RecordedValue(myTime, AFRetrievalMode.AtOrBefore, myAttribute.DefaultUOM); Console.WriteLine("Value = '{0}' at '{1}'", value, myTime);
' This example demonstrates how to create an attribute for an ' element and retrieve values using the 'Data' object. ' Get the Database Dim myPISystems As New PISystems Dim myPISystem As PISystem = myPISystems.DefaultPISystem Dim myDB As AFDatabase = myPISystem.Databases.DefaultDatabase ' Create An Element Dim myElement As AFElement = myDB.Elements.Add("MyElement*") ' Create an Attribute Dim myAttribute As AFAttribute = myElement.Attributes.Add("MyAttribute") myAttribute.DefaultUOM = myPISystem.UOMDatabase.UOMs("Kelvin") myAttribute.DataReferencePlugIn = AFDataReference.GetPIPointDataReference(myPISystem) myAttribute.ConfigString = "\\%Server%\sinusoid" ' Get the Recorded Value for the Attribute Dim myTime As AFTime = DateTime.Now.AddDays(-1) Dim value As AFValue = myAttribute.Data.RecordedValue(myTime, AFRetrievalMode.AtOrBefore, myAttribute.DefaultUOM) Console.WriteLine("Value = '{0}' at '{1}'", value, myTime)
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.