Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AF SDK Reference

AFData Class

  • Last UpdatedNov 18, 2025
  • 9 minute read
AFData Class
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

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

  NameDescription
Public property
Attribute
The AFAttribute associated with this object.
Public propertyStatic member
BufferOption
Indicates the AFBufferOption to use when updating values.
Public property
CacheEnabled
Whether AFDataCache is enabled for this AFData instance.
Public property
CacheStartTime
The earliest event time stamp in the AFDataCache for this AFData instance.
Public property
EventsCached
The number of events cached for this AFData instance.

Methods

  NameDescription
Public method
CreateWithInputDataProvider
Creates a new AFData instance that will evaluate this attribute with input data obtained by the specified input data provider.
Public method
EndOfStream
Returns the end-of-stream AFValue.
Public method
EndOfStreamAsync
Get the value with the largest timestamp for a data stream.
Public method
Equals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public method
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.
Public method
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.
Public method
GetAllCachedValues
Get all the events in the AFDataCache for this AFData instance.
Public method
GetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public method
GetType
Gets the Type of the current instance.
(Inherited from Object.)
Public method
InterpolatedValue
Returns a single AFValue whose value is interpolated at the passed time.
Public method
InterpolatedValueAsync
Returns a single AFValue whose value is interpolated at the passed time.
Public method
InterpolatedValues
Retrieves interpolated values over the specified time range at the specified sampling interval.
Public method
InterpolatedValuesAsync
Retrieves interpolated values over the specified time range at the specified sampling interval.
Public method
InterpolatedValuesAtTimes
Retrieves interpolated values at the specified times.
Public method
InterpolatedValuesAtTimesAsync
Retrieves interpolated values at the specified times.
Public method
PlotValues
Retrieves values over the specified time range suitable for plotting over the number of intervals (typically represents pixels).
Public method
PlotValuesAsync
Retrieves values over the specified time range suitable for plotting over the number of intervals (typically represents pixels).
Public method
RecordedValue
Returns a single recorded AFValue based on the passed time and mode.
Public method
RecordedValueAsync
Returns a single recorded AFValue based on the passed time and mode.
Public method
RecordedValues
Returns a list of compressed values for the requested time range from the source provider.
Public method
RecordedValuesAsync
Returns a list of values for the requested time range from the source provider.
Public method
RecordedValuesAtTimes
Retrieves recorded values at the specified times.
Public method
RecordedValuesAtTimesAsync
Retrieves recorded values at the specified times.
Public method
RecordedValuesByCount
This method returns a specified number of compressed values beginning at the requested start time in the direction specified.
Public method
RecordedValuesByCountAsync
This method returns a specified number of compressed values beginning at the requested start time in the direction specified.
Public method
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.
Public method
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.
Public method
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.
Public method
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.
Public method
Summaries
Returns several summaries for a single attribute over a time range for each interval within the range.
Public method
SummariesAsync
Returns several summaries for a single attribute over a time range for each interval within the range.
Public method
Summary
Returns several summaries for a single attribute over a single time range.
Public method
SummaryAsync
Returns several summaries for a single attribute over a single time range.
Public method
ToString
Returns a string that represents the current object.
(Inherited from Object.)
Public method
UpdateValue(AFValue, AFUpdateOption)
This method writes, replaces, or removes a value on the target system using the configured data reference.
Public method
UpdateValue(AFValue, AFUpdateOption, AFBufferOption)
This method writes, replaces, or removes a value on the target system using the configured data reference.
Public method
UpdateValues(AFValues, AFUpdateOption)
This method writes or replaces one or more values on the target system using the configured data reference.
Public methodCode example
UpdateValues(AFValues, AFUpdateOption, AFBufferOption)
This method writes or replaces one or more values on the target system using the configured data reference.
Public method
UpdateValuesAsync(AFValues, AFUpdateOption, CancellationToken)
This method writes or replaces one or more values on the target system using the configured data reference.
Public method
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.

Note Notes to Callers
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.

Version Information

AFSDK


See Also

In This Topic
TitleResults for “How to create a CRG?”Also Available in