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

AF SDK Reference

AFListData Class

  • Last UpdatedNov 18, 2025
  • 9 minute read
AFListData Class
The AFListData object is associated with a AFAttributeList and is used to retrieve and set extended historical data for multiple attributes. It is accessed through the Data property of an AFAttributeList.

Inheritance Hierarchy

SystemObject
  OSIsoft.AF.DataAFListData

Namespace:  OSIsoft.AF.Data
Assembly:  OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.1.1.1182

Syntax

public class AFListData
Public Class AFListData

Dim instance As AFListData
public ref class AFListData
type AFListData =  class end

The AFListData type exposes the following members.

Methods

  NameDescription
Public method
EndOfStream
Get the end-of-stream value for each attribute in this list.
Public method
EndOfStreamAsync
Returns an end-of-stream AFValue for each attribute in this list.
Public method
Equals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodCode example
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
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 interpolated value for each attribute in this list based on the passed time.
Public method
InterpolatedValueAsync
Returns an AFValue for each attribute in this list based on the passed time.
Public methodCode example
InterpolatedValues
Retrieves interpolated values over the specified time range at the specified sampling interval.
Public methodCode example
InterpolatedValuesAtTimes
Retrieves interpolated values at the specified times.
Public methodCode example
PlotValues
Retrieves values over the specified time range suitable for plotting over the number of intervals (typically represents pixels).
Public method
RecordedValue
Returns a recorded value for each attribute in this list based on the passed time and mode.
Public method
RecordedValueAsync
Returns a recorded AFValue for each attribute in this list based on the passed time and mode.
Public methodCode example
RecordedValues
Returns a list of compressed values for the requested time range from the source provider.
Public method
RecordedValuesAtTimes
Retrieves recorded values at the specified times.
Public methodCode example
RecordedValuesByCount
This method returns a specified number of compressed values beginning at the requested start time in the direction specified.
Public methodStatic member
ReplaceValues(AFTimeRange, IListAFValues)
This method removes existing data for each AFAttribute within the specified AFTimeRange and inserts the specified values.
Public methodStatic member
ReplaceValues(AFTimeRange, IListAFValues, AFBufferOption)
This method removes existing data for each AFAttribute within the specified AFTimeRange and inserts the specified values.
Public methodCode example
Summaries
Returns several summaries over a time range for each interval within the range for each AFAttribute in the list.
Public methodCode example
Summary
Returns several summaries for a list of attributes over a single time range.
Public method
ToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodStatic memberCode example
UpdateValues(IListAFValue, AFUpdateOption)
Write, update, or remove a AFAttribute value for each AFValue in the specified list.
Public methodStatic memberCode example
UpdateValues(IListAFValue, AFUpdateOption, AFBufferOption)
Write, update, or remove a AFAttribute value for each AFValue in the specified list.

Remarks

This AFListData provides increased performance when operating on a number of attributes at one time.

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 update multiple values using
// the AFListData.UpdateValues method

// Get the Database and UOMs
PISystems myPISystems = new PISystems();
PISystem myPISystem = myPISystems.DefaultPISystem;
AFDatabase myDB = myPISystem.Databases.DefaultDatabase;
UOM uomYard = myPISystem.UOMDatabase.UOMs["yard"];
UOM uomSqFoot = myPISystem.UOMDatabase.UOMs["square foot"];
UOM uomLiter = myPISystem.UOMDatabase.UOMs["liter"];

// Create the Element
AFElement myElement = myDB.Elements.Add("MyElement");
AFAttribute myAttribute = myElement.Attributes.Add("MyAttribute");
myAttribute.Type = typeof(double);
myAttribute = myElement.Attributes.Add("MyAttribute2");
myAttribute.Type = typeof(double);

// Create List of Attributes and their new values
AFTime newTime = new AFTime("T-1d", CultureInfo.CurrentCulture);
AFAttributeList attrList = new AFAttributeList();
List<AFValue> newValues = new List<AFValue>();
Random randomValues = new Random();

// Create Dynamic Attribute to a PIPoint to Update
PIServer piServer = PIServers.GetPIServers().DefaultPIServer;
if (PIPoint.TryFindPIPoint(piServer, "MyTestPoint#1", out PIPoint point))
{
    myAttribute = new AFAttribute(point);
    myAttribute.DefaultUOM = uomLiter;
    myAttribute.ConfigString += ";ReadOnly=False";
    attrList.Add(myAttribute);
    newValues.Add(new AFValue(myAttribute, randomValues.NextDouble(), newTime, uomLiter));
}
if (PIPoint.TryFindPIPoint(piServer, "MyTestPoint#2", out point))
{
    myAttribute = new AFAttribute(point);
    myAttribute.DefaultUOM = uomYard;
    myAttribute.ConfigString += ";UOM=ft;ReadOnly=True";
    attrList.Add(myAttribute);
    newValues.Add(new AFValue(myAttribute, randomValues.NextDouble(), newTime, uomYard));
}

// Get some Attributes from the Element to Update
myAttribute = myElement.Attributes["MyAttribute"];
attrList.Add(myAttribute);
newValues.Add(new AFValue(myAttribute, 100, newTime, uomSqFoot));
myAttribute = myElement.Attributes["MyAttribute2"];
attrList.Add(myAttribute);
newValues.Add(new AFValue(myAttribute, 200, newTime, null));

// Get the Current Values for the Attributes
AFValues currentValues = attrList.GetValue(newTime);
Console.WriteLine("Current Values:");
foreach (AFValue value in currentValues)
{
    Console.WriteLine("  {0}: '{1} {2}' at '{3}'",
        value.Attribute, value.Value, value.UOM, value.Timestamp);
}

// Update the Attribute Values and Display any Errors
AFErrors<AFValue> errors =
    AFListData.UpdateValues(newValues, AFUpdateOption.Replace);
if (errors != null && errors.HasErrors)
{
    Console.WriteLine("\nErrors returned from AFListData.UpdateValues:");

    // Display Value errors
    if (errors.Errors != null && errors.Errors.Count > 0)
    {
        foreach (var item in errors.Errors)
        {
            Console.WriteLine("  AFValue '{0}': {1}", item.Key, item.Value);
        }
    }

    // Display error from the PI Data Archive
    if (errors.PIServerErrors != null && errors.PIServerErrors.Count > 0)
    {
        foreach (var item in errors.PIServerErrors)
        {
            Console.WriteLine("  AFValue '{0}': {1}", item.Key, item.Value);
        }
    }

    // Display PI System errors
    if (errors.PISystemErrors != null && errors.PISystemErrors.Count > 0)
    {
        foreach (var item in errors.PISystemErrors)
        {
            Console.WriteLine("  AFValue '{0}': {1}", item.Key, item.Value);
        }
    }
}

// Get the Updated Current Values for the Attributes
currentValues = attrList.GetValue(newTime);
Console.WriteLine("\nUpdated Current Values:");
foreach (AFValue value in currentValues)
{
    Console.WriteLine("  {0}: '{1} {2}' at '{3}'",
        value.Attribute, value.Value, value.UOM, value.Timestamp);
}
' This example demonstrates how to update multiple values using
' the AFListData.UpdateValues method

' Get the Database and UOMs
Dim myPISystems As PISystems = New PISystems
Dim myPISystem As PISystem = myPISystems.DefaultPISystem
Dim myDB As AFDatabase = myPISystem.Databases.DefaultDatabase
Dim uomYard As UOM = myPISystem.UOMDatabase.UOMs("yard")
Dim uomSqFoot As UOM = myPISystem.UOMDatabase.UOMs("square foot")
Dim uomLiter As UOM = myPISystem.UOMDatabase.UOMs("liter")

' Create the Element
Dim myElement As AFElement = myDB.Elements.Add("MyElement")
Dim myAttribute As AFAttribute = myElement.Attributes.Add("MyAttribute")
Dim someType As Type = GetType(Double)
myAttribute.Type = GetType(Double)
myAttribute = myElement.Attributes.Add("MyAttribute2")
myAttribute.Type = GetType(Double)

' Create List of Attributes and their new values
Dim newTime As AFTime = New AFTime("T-1d", CultureInfo.CurrentCulture)
Dim attrList As AFAttributeList = New AFAttributeList
Dim newValues As List(Of AFValue) = New List(Of AFValue)
Dim randomValues As Random = New Random

' Create Dynamic Attribute to a PIPoint to Update
Dim piServer As PIServer = PIServers.GetPIServers.DefaultPIServer
Dim point As PIPoint = Nothing
If PIPoint.TryFindPIPoint(piServer, "MyTestPoint#1", point) Then
    myAttribute = New AFAttribute(point)
    myAttribute.DefaultUOM = uomLiter
    myAttribute.ConfigString = (myAttribute.ConfigString + ";ReadOnly=False")
    attrList.Add(myAttribute)
    newValues.Add(New AFValue(myAttribute, randomValues.NextDouble, newTime, uomLiter))
End If
If PIPoint.TryFindPIPoint(piServer, "MyTestPoint#2", point) Then
    myAttribute = New AFAttribute(point)
    myAttribute.DefaultUOM = uomYard
    myAttribute.ConfigString = (myAttribute.ConfigString + ";UOM=ft;ReadOnly=True")
    attrList.Add(myAttribute)
    newValues.Add(New AFValue(myAttribute, randomValues.NextDouble, newTime, uomYard))
End If

' Get some Attributes from the Element to Update
myAttribute = myElement.Attributes("MyAttribute")
attrList.Add(myAttribute)
newValues.Add(New AFValue(myAttribute, 100, newTime, uomSqFoot))
myAttribute = myElement.Attributes("MyAttribute2")
attrList.Add(myAttribute)
newValues.Add(New AFValue(myAttribute, 200, newTime, Nothing))

' Get the Current Values for the Attributes
Dim currentValues As AFValues = attrList.GetValue(newTime)
Console.WriteLine("Current Values:")
For Each value As AFValue In currentValues
    Console.WriteLine("  {0}: '{1} {2}' at '{3}'", value.Attribute, value.Value, value.UOM, value.Timestamp)
Next

' Update the Attribute Values and Display any Errors
Dim errors As AFErrors(Of AFValue) = AFListData.UpdateValues(newValues, AFUpdateOption.Replace)
If (Not errors Is Nothing AndAlso errors.HasErrors) Then
    Console.WriteLine("Errors returned from AFListData.UpdateValues:")

    ' Display Value Errors
    If (Not errors.Errors Is Nothing AndAlso errors.Errors.Count > 0) Then
        For Each item As KeyValuePair(Of AFValue, Exception) In errors.Errors
            Console.WriteLine("  AFValue '{0}': {1}", item.Key, item.Value)
        Next
    End If

    ' Display PI Data Archive Errors
    If (Not errors.PIServerErrors Is Nothing AndAlso errors.PIServerErrors.Count > 0) Then
        For Each item As KeyValuePair(Of PIServer, Exception) In errors.PIServerErrors
            Console.WriteLine("  AFValue '{0}': {1}", item.Key, item.Value)
        Next
    End If

    ' Display PI System Errors
    If (Not errors.PISystemErrors Is Nothing AndAlso errors.PISystemErrors.Count > 0) Then
        For Each item As KeyValuePair(Of PISystem, Exception) In errors.PISystemErrors
            Console.WriteLine("  AFValue '{0}': {1}", item.Key, item.Value)
        Next
    End If


End If

' Get the Updated Current Values for the Attributes
currentValues = attrList.GetValue(newTime)
Console.WriteLine("Updated Current Values:")
For Each value As AFValue In currentValues
    Console.WriteLine("  {0}: '{1} {2}' at '{3}'", value.Attribute, value.Value, value.UOM, value.Timestamp)
Next

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
Related Links
TitleResults for “How to create a CRG?”Also Available in