Click or drag to resize
OSIsoft, LLC

AFAnnotations Class

A list of structured AFAnnotation objects associated with an historical data event.

Inheritance Hierarchy

Namespace:  OSIsoft.AF.Data
Assembly:  OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version:
public sealed class AFAnnotations : IList<AFAnnotation>, 
	ICollection<AFAnnotation>, IEnumerable<AFAnnotation>, IEnumerable, 
	IList, ICollection

The AFAnnotations type exposes the following members.

Public methodAFAnnotations
Initializes a new instance of the AFAnnotations class
Public propertyCount
Gets the number of items actually contained in the collection.
Public propertyItem
Gets or sets the item at the specified index.
Public methodAdd
Create a new AFAnnotation object and adds it to the list.
Public methodClear
Removes all items from the collection.
Public methodContains
The Contains method determines if an AFAnnotation exists in the list.
Public methodCopyTo
Copies the entire collection to a compatible one-dimensional Array, starting at the specified index of the target array.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodGetEnumerator
Returns an enumerator that iterates through the collection.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodIndexOf
Searches for the specified object and returns the zero-based index of the first occurrence within the entire collection.
Public methodInsert
Inserts an item into the collection at the specified index.
Public methodRemove
Removes the first occurrence of a specific object from the collection.
Public methodRemoveAt
Removes the item at the specified index of the collection.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Extension Methods

A list of structured AFAnnotation objects associated with an historical data event. This list can be returned from the AFValue.GetAnnotation method. Because it is a list, there can be more than one structured AFAnnotation per AFValue. This collection of annotations is only used with structured historical data events. Annotations associated with asset data such as AFEventFrame or AFElement are returned as a simple list of AFAnnotation objects and do not use this class.

Important note Important
This list only supports PIPoint annotations.

Note Notes to Callers
This method, property, or class is only available in the .NET 4 version of the SDK.

// This example demonstrates how to create an attribute for an
// element and retrieve and set annotations on values.

// 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;ReadOnly=False";

// Create New Simple Annotation
AFValue myValue1 = new AFValue(155.432, AFTime.Now);
myValue1.SetAnnotation("New Event with Simple Annotation");
myAttribute.Data.UpdateValue(myValue1, AFUpdateOption.InsertNoCompression);

// Update an Existing Annotation
myAttribute.Data.UpdateValue(myValue1, AFUpdateOption.Replace);

// Create an AFFile to be used as an Annotation value
string path = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "TestFile.txt");
using (System.IO.File.Create(path)) { }
AFFile myFile = new AFFile();

// Create New Structured Annotation
AFAnnotations myAnnotations = new AFAnnotations();
AFValue myValue2 = new AFValue(255.543);
AFAnnotation myAnnotation = myAnnotations.Add("Annotation#1", 400.456);
myAnnotation.Description = "1st Annotation is a Double.";
myAnnotation = myAnnotations.Add("Annotation#2", "My Annotation Value");
myAnnotation.Description = "2nd Annotation is a String.";
myAnnotation = myAnnotations.Add("Annotation#3", myFile);
myAnnotation.Description = "3rd Annotation is an AFFile.";
myAttribute.Data.UpdateValue(myValue2, AFUpdateOption.InsertNoCompression);

// Read Annotations
object theAnnotation = myValue1.GetAnnotation();
DisplayAnnotation(myValue1, theAnnotation);

theAnnotation = myValue2.GetAnnotation();
DisplayAnnotation(myValue2, theAnnotation);

AFValue myValue = myAttribute.GetValue();
theAnnotation = myValue.GetAnnotation();
DisplayAnnotation(myValue, theAnnotation);
/// <summary>
/// Display information about the annotated value.
/// </summary>
/// <param name="theValue">
/// The AFValue associated with the specified annotation value.
/// </param>
/// <param name="theAnnotation">
/// The annotation value associated with the specified AFValue.
/// </param>
static private void DisplayAnnotation(AFValue theValue, object theAnnotation)
    AFAnnotations theAnnotations = theAnnotation as AFAnnotations;
    if (theAnnotations == null)
        Console.WriteLine("Simple Annotation for Value '{0}' = '{1}'", theValue, theAnnotation);
        Console.WriteLine("Structured Annotation for Value '{0}':", theValue);
        foreach (AFAnnotation item in theAnnotations)
            Console.WriteLine("  Value = '{0}', Description = '{1}', Creator = '{2}'",
                item.Value, item.Description, item.Creator);
Version Information


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