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

AF SDK Reference

AFEnumerationValue Class

  • Last UpdatedNov 18, 2025
  • 7 minute read
AFEnumerationValue Class
The AFEnumerationValue represents a specific condition of an enumerated set It is similar to a PI Digital State.

Inheritance Hierarchy

SystemObject
  OSIsoft.AFAFObject
    OSIsoft.AF.AssetAFEnumerationValue

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

Syntax

[SerializableAttribute]
public sealed class AFEnumerationValue : AFObject, 
	IComparable<AFEnumerationValue>, IConvertible, IEquatable<AFEnumerationValue>
<SerializableAttribute>
Public NotInheritable Class AFEnumerationValue
	Inherits AFObject
	Implements IComparable(Of AFEnumerationValue), IConvertible, 
	IEquatable(Of AFEnumerationValue)

Dim instance As AFEnumerationValue
[SerializableAttribute]
public ref class AFEnumerationValue sealed : public AFObject, 
	IComparable<AFEnumerationValue^>, IConvertible, IEquatable<AFEnumerationValue^>
[<SealedAttribute>]
[<SerializableAttribute>]
type AFEnumerationValue =  
    class
        inherit AFObject
        interface IComparable<AFEnumerationValue>
        interface IConvertible
        interface IEquatable<AFEnumerationValue>
    end

The AFEnumerationValue type exposes the following members.

Constructors

  NameDescription
Public method
AFEnumerationValue
Dynamically create an AFEnumerationValue that is not associated with an AFEnumerationSet or a PISystem.

Properties

  NameDescription
Public property
Database
This read-only property returns the AFDatabase where this object is defined.
Public property
Description
Read/write property that provides a more detailed description of the object.
Public property
EnumerationSet
The enumeration that this object is a member of.
Public property
ID
Read-only property that provides a unique identifier for the object to be used for quick access that is not dependent upon the index.
(Inherited from AFObject.)
Public property
Identity
This read-only property contains identity of the object.
(Inherited from AFObject.)
Public property
IsDeleted
This read-only property indicates whether the object has been deleted.
(Inherited from AFObject.)
Public property
Name
Read/write property that identifies the name of the object.
Public property
Parent
The parent of a child hierarchical enumeration value.
Public property
PISystem
This read-only property allows access to the PISystem associated with this object.
(Inherited from AFObject.)
Public property
ShortName
The short name of a hierarchical enumeration value.
Public property
UniqueID
Read-only property that provides the object's ID as a String.
(Inherited from AFObject.)
Public property
Value
The unique numeric value of the AFEnumerationValue within the AFEnumerationSet to which it belongs.
Public property
Values
The list of child enumeration values.

Methods

  NameDescription
Public method
CompareTo(Object)
Compares this instance with a specified Object.
(Inherited from AFObject.)
Public method
CompareTo(AFObject)
Compares this instance with a specified AFObject.
(Inherited from AFObject.)
Public method
Equals(Object)
Compares two AFEnumerationValue instances for equivalence.
(Overrides AFObjectEquals(Object).)
Public method
Equals(AFEnumerationValue)
Compares two AFEnumerationValue instances for equivalence.
Public method
Equals(AFObject)
Indicates whether the current object is equal to another object of the same type.
(Inherited from AFObject.)
Public method
GetHashCode
Gets the hash code for this instance of the object which is suitable for use in hashing algorithms and data structures like a hash table.
(Overrides AFObjectGetHashCode.)
Public method
GetPath
Returns the full path to the object, using just the names.
(Inherited from AFObject.)
Public method
GetPath(AFObject)
Returns the path to the object relative from another object.
(Inherited from AFObject.)
Public method
GetPath(AFEncodeType, AFObject)
Returns the path to the object relative from another object, using the name and/or id as specified by encodeType.
(Inherited from AFObject.)
Public method
GetType
Gets the Type of the current instance.
(Inherited from Object.)
Public method
Persist
This method returns the persistence string for the object.
(Overrides AFObjectPersist.)
Public method
ToString
Returns a String that represents the current object.
(Inherited from AFObject.)

Operators

  NameDescription
Public operatorStatic member
Equality
The equality operator (==) compares its operands to determine if they are equal.
Public operatorStatic member
Inequality
The inequality operator (!=) compares its operands to determine if they are not equal.

Remarks

An AFEnumerationValue consists of a Name property and a Value property. The Name is unique string within the enumeration that typically describes the condition or state being represented. Most object names have some characters that are not allowed. The Name of an enumeration value does not have the same restrictions and allow any character except non-printable characters. The Name is the preferred means of accessing an enumeration value. The Value is a unique numeric value which is also associated with the enumeration. The Value is used to provide a quicker, and less memory intensive representation of an enumeration's value.

A dynamic or disconnected AFEnumerationValue can be created that is not associated with an AFEnumerationSet or a PISystem. This type of AFEnumerationValue is normally used to represent a PISDK.DigitalState object.

Examples

// This example demonstrates how to create an enumeration 
// value type and add it as the type of an attribute,
// as well as setting a value with it.

// Get the Database
PISystems myPISystems = new PISystems();
AFDatabase myDB = myPISystems.DefaultPISystem.Databases.DefaultDatabase;

// Create the Enumeration Set
AFEnumerationSet myEnumerationSet = myDB.EnumerationSets.Add("Speed");
myEnumerationSet.Description = "Motor Speeds";

// Add the Enumeration Values
myEnumerationSet.Add("Stop", 0);
myEnumerationSet.Add("Slow", 1);
myEnumerationSet.Add("Medium", 5);
myEnumerationSet.Add("Fast", 10);

// Display the Name and Description of the EnumerationSet
Console.WriteLine("Name of EnumerationSet = {0}", myEnumerationSet.Name);
Console.WriteLine("Description = {0}", myEnumerationSet.Description);

// Display each value in the EnumerationSet
foreach (AFEnumerationValue eVal in myEnumerationSet)
{
    Console.WriteLine("Name in set = {0}", eVal.Name);
    Console.WriteLine("Value in set = {0}", eVal.Value);
}

// Create an Element
AFElement myElement = myDB.Elements.Add("MyElement");

// Create an Attribute
AFAttribute myAttribute = myElement.Attributes.Add("MyAttribute");

// Set the EnumerationSet for an Attibute
myAttribute.TypeQualifier = myEnumerationSet;
myAttribute.SetValue(myEnumerationSet["Stop"], null);
' This example demonstrates how to create an enumeration 
' value type and add it as the type of an attribute,
' as well as setting a value with it.

' Get the Database
Dim myPISystems As New PISystems()
Dim myDB As AFDatabase = myPISystems.DefaultPISystem.Databases.DefaultDatabase

' Create the Enumeration Set
Dim myEnumerationSet As AFEnumerationSet = myDB.EnumerationSets.Add("Speed")
myEnumerationSet.Description = "Motor Speeds"

' Add the Enumeration Values
myEnumerationSet.Add("Stop", 0)
myEnumerationSet.Add("Slow", 1)
myEnumerationSet.Add("Medium", 5)
myEnumerationSet.Add("Fast", 10)

' Display the Name and Description of the EnumerationSet
Console.WriteLine("Name of EnumerationSet = {0}", myEnumerationSet.Name)
Console.WriteLine("Description = {0}", myEnumerationSet.Description)

' Display each value in the EnumerationSet
Dim eVal As AFEnumerationValue
For Each eVal In myEnumerationSet
    Console.WriteLine("Name in set = {0}", eVal.Name)
    Console.WriteLine("Value in set = {0}", eVal.Value)
Next eVal

' Create an Element
Dim myElement As AFElement = myDB.Elements.Add("MyElement")

' Create an Attribute
Dim myAttribute As AFAttribute = myElement.Attributes.Add("MyAttribute")

' Set the EnumerationSet for an Attribute
myAttribute.TypeQualifier = myEnumerationSet
myAttribute.SetValue(myEnumerationSet("Stop"), Nothing)

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

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