Click or drag to resize
OSIsoft, LLC

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: 2.10.6.195
Syntax
public class AFListData

The AFListData type exposes the following members.

Methods
  NameDescription
Public methodEndOfStream
Get the end-of-stream value for each attribute in this list.
Public methodEndOfStreamAsync
Returns an end-of-stream AFValue for each attribute in this list.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodCode exampleFilteredSummaries
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 methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodInterpolatedValue
Returns a interpolated value for each attribute in this list based on the passed time.
Public methodInterpolatedValueAsync
Returns an AFValue for each attribute in this list based on the passed time.
Public methodCode exampleInterpolatedValues
Retrieves interpolated values over the specified time range at the specified sampling interval.
Public methodCode exampleInterpolatedValuesAtTimes
Retrieves interpolated values at the specified times.
Public methodCode examplePlotValues
Retrieves values over the specified time range suitable for plotting over the number of intervals (typically represents pixels).
Public methodRecordedValue
Returns a recorded value for each attribute in this list based on the passed time and mode.
Public methodRecordedValueAsync
Returns a recorded AFValue for each attribute in this list based on the passed time and mode.
Public methodCode exampleRecordedValues
Returns a list of compressed values for the requested time range from the source provider.
Public methodRecordedValuesAtTimes
Retrieves recorded values at the specified times.
Public methodCode exampleRecordedValuesByCount
This method returns a specified number of compressed values beginning at the requested start time in the direction specified.
Public methodStatic memberReplaceValues(AFTimeRange, IListAFValues)
This method removes existing data for each AFAttribute within the specified AFTimeRange and inserts the specified values.
Public methodStatic memberReplaceValues(AFTimeRange, IListAFValues, AFBufferOption)
This method removes existing data for each AFAttribute within the specified AFTimeRange and inserts the specified values.
Public methodCode exampleSummaries
Returns several summaries over a time range for each interval within the range for each AFAttribute in the list.
Public methodCode exampleSummary
Returns several summaries for a list of attributes over a single time range.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodStatic memberCode exampleUpdateValues(IListAFValue, AFUpdateOption)
Write, update, or remove a AFAttribute value for each AFValue in the specified list.
Public methodStatic memberCode exampleUpdateValues(IListAFValue, AFUpdateOption, AFBufferOption)
Write, update, or remove a AFAttribute value for each AFValue in the specified list.
Top
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 only available in the .NET 4 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);
}
Version Information

AFSDK

Supported in: 2.10.5, 2.10, 2.9.5, 2.9, 2.8.5, 2.8, 2.7.5, 2.7, 2.6, 2.5
See Also
Enabling Operational Intelligence