AFEnumerationValue Class
- Last UpdatedNov 18, 2025
- 7 minute read
- PI System
- AF SDK 2024 R2
- Developer

Inheritance Hierarchy
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
| Name | Description | |
|---|---|---|
| AFEnumerationValue |
Dynamically create an AFEnumerationValue that is not associated
with an AFEnumerationSet or a PISystem.
|
Properties
| Name | Description | |
|---|---|---|
| Database |
This read-only property returns the AFDatabase where this object is defined.
| |
| Description |
Read/write property that provides a more detailed description of the object.
| |
| EnumerationSet |
The enumeration that this object is a member of.
| |
| 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.) | |
| Identity |
This read-only property contains identity of the object.
(Inherited from AFObject.) | |
| IsDeleted |
This read-only property indicates whether the object has been deleted.
(Inherited from AFObject.) | |
| Name |
Read/write property that identifies the name of the object.
| |
| Parent |
The parent of a child hierarchical enumeration value.
| |
| PISystem |
This read-only property allows access to the PISystem associated with this
object.
(Inherited from AFObject.) | |
| ShortName |
The short name of a hierarchical enumeration value.
| |
| UniqueID |
Read-only property that provides the object's ID as a String.
(Inherited from AFObject.) | |
| Value |
The unique numeric value of the AFEnumerationValue within the AFEnumerationSet to which it belongs.
| |
| Values |
The list of child enumeration values.
|
Methods
| Name | Description | |
|---|---|---|
| CompareTo(Object) |
Compares this instance with a specified Object.
(Inherited from AFObject.) | |
| CompareTo(AFObject) |
Compares this instance with a specified AFObject.
(Inherited from AFObject.) | |
| Equals(Object) |
Compares two AFEnumerationValue instances for equivalence.
(Overrides AFObjectEquals(Object).) | |
| Equals(AFEnumerationValue) |
Compares two AFEnumerationValue instances for equivalence.
| |
| Equals(AFObject) |
Indicates whether the current object is equal to another object of the same type.
(Inherited from AFObject.) | |
| 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.) | |
| GetPath |
Returns the full path to the object, using just the names.
(Inherited from AFObject.) | |
| GetPath(AFObject) |
Returns the path to the object relative from another object.
(Inherited from AFObject.) | |
| 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.) | |
| GetType | Gets the Type of the current instance. (Inherited from Object.) | |
| Persist |
This method returns the persistence string for the object.
(Overrides AFObjectPersist.) | |
| ToString |
Returns a String that represents the current object.
(Inherited from AFObject.) |
Operators
| Name | Description | |
|---|---|---|
| Equality |
The equality operator (==) compares its operands to determine if they are equal.
| |
| 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.