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

AF SDK Reference

AFEnumerationSet Class

  • Last UpdatedNov 18, 2025
  • 14 minute read
AFEnumerationSet Class
The AFEnumerationSet represents a user-defined set of named constant values. It is also used to represent a PI Digital State Set.

Inheritance Hierarchy

SystemObject
  OSIsoft.AFAFObject
    OSIsoft.AF.AssetAFEnumerationSet

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

Syntax

[SerializableAttribute]
public sealed class AFEnumerationSet : AFObject, 
	IAFTransactable, IAFChangedEvent, IAFSecurable, IComparable<AFEnumerationSet>, 
	IList<AFEnumerationValue>, ICollection<AFEnumerationValue>, IEnumerable<AFEnumerationValue>, 
	IEnumerable, IList, ICollection
<SerializableAttribute>
Public NotInheritable Class AFEnumerationSet
	Inherits AFObject
	Implements IAFTransactable, IAFChangedEvent, IAFSecurable, IComparable(Of AFEnumerationSet), 
	IList(Of AFEnumerationValue), ICollection(Of AFEnumerationValue), IEnumerable(Of AFEnumerationValue), 
	IEnumerable, IList, ICollection

Dim instance As AFEnumerationSet
[SerializableAttribute]
public ref class AFEnumerationSet sealed : public AFObject, 
	IAFTransactable, IAFChangedEvent, IAFSecurable, IComparable<AFEnumerationSet^>, 
	IList<AFEnumerationValue^>, ICollection<AFEnumerationValue^>, IEnumerable<AFEnumerationValue^>, 
	IEnumerable, IList, ICollection
[<SealedAttribute>]
[<SerializableAttribute>]
type AFEnumerationSet =  
    class
        inherit AFObject
        interface IAFTransactable
        interface IAFChangedEvent
        interface IAFSecurable
        interface IComparable<AFEnumerationSet>
        interface IList<AFEnumerationValue>
        interface ICollection<AFEnumerationValue>
        interface IEnumerable<AFEnumerationValue>
        interface IEnumerable
        interface IList
        interface ICollection
    end

The AFEnumerationSet type exposes the following members.

Constructors

  NameDescription
Public method
AFEnumerationSet
Initializes a new instance of the class with default values.
Public method
AFEnumerationSet(String)
Initializes a new instance of the class with the specified name.

Properties

  NameDescription
Public property
CheckOutInfo
This read-only property returns the checked out status information for the object.
Public property
Count
Gets the number of items actually contained in the collection.
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
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
IsDirty
This read-only property indicates whether the object has been modified since the last save to the PI AF Server.
Public property
IsNew
This read-only property indicates whether the object is new and has never been saved to the PI AF Server.
Public property
ItemGuid
Gets the item with the specified id.
Public property
ItemInt32
Gets or sets the item at the specified index.
Public property
ItemString
Returns the specified object from the collection by name.
Public property
Name
Read/write property that identifies the name of the object.
Public property
PIServer
Returns a reference to the PIServer associated with this AFEnumerationSet or if it is not associated with one.
Public property
PISystem
This read-only property allows access to the PISystem associated with this object.
(Inherited from AFObject.)
Public property
Security
This read-only property returns the AFSecurity information for the object.
Public propertyStatic member
SystemStateSet
The standard system enumeration set.
Public property
UniqueID
Read-only property that provides the object's ID as a String.
(Inherited from AFObject.)

Methods

  NameDescription
Public method
Add(AFEnumerationValue)
The Add method adds the specified AFEnumerationValue to the AFEnumerationSet.
Public method
Add(String, Int32)
The Add method creates a new AFEnumerationValue and adds it to the collection with the specified name and value.
Public methodCode example
ApplyChanges
This method applies the changes to the object and makes those changes available to other objects for the current user.
Public method
AreEquivalent
This method compares two AFEnumerationSet objects for equivalence.
Public methodCode example
CheckIn
This method checks in (commits) all the changes to the object by saving the information to persistent storage.
Public method
CheckOut
This method locks the object so that its configuration can be modified.
Public methodStatic member
CheckOutEnumerationSets
Check out the objects with the specified unique identifiers at the specified query date.
Public method
Clear
Removes all items from the collection.
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
Contains(Guid)
This method determines whether the collection contains a specific item referenced by id.
Public method
Contains(Int32)
This method determines whether the collection contains a specific item value.
Public method
Contains(String)
This method determines whether the collection contains a specific item referenced by name.
Public method
Contains(AFEnumerationValue)
This method determines whether the collection contains a specific item.
Public method
CopyTo
Copies the entire collection to a compatible one-dimensional Array, starting at the specified index of the target array.
Public methodStatic member
DeleteEnumerationSets
Delete the objects with the specified unique identifiers.
Public method
Equals(Object)
Determines whether the specified Object is equal to the current object.
(Inherited from AFObject.)
Public method
Equals(AFObject)
Indicates whether the current object is equal to another object of the same type.
(Inherited from AFObject.)
Public methodStatic member
FindEnumerationSet
Retrieves the AFEnumerationSet object with the specified unique identifier.
Public methodStatic member
FindEnumerationSets(PISystem, Guid)
Performs a search within the PISystem to retrieve a collection of AFEnumerationSet objects with the specified list of unique identifiers.
Public methodStatic member
FindEnumerationSets(AFDatabase, String, AFSearchField, AFSortField, AFSortOrder, Int32)
Performs a non-paged text search within the AFDatabase to retrieve a collection of AFEnumerationSet objects which have a field that match the specified query string.
Public methodStatic member
GetBySystemStateCode
Gets the specified AFEnumerationValue from the SystemStateSet collection by its AFSystemStateCode.
Public method
GetByValue
Gets the specified AFEnumerationValue from the collection by its value.
Public method
GetEnumerator
Returns an enumerator that iterates through the collection.
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.
(Inherited from AFObject.)
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
GetSecurity
Gets the AFSecurity information of the specified security item associated with the object.
Public method
GetType
Gets the Type of the current instance.
(Inherited from Object.)
Public method
IndexOf
Searches for the specified object and returns the zero-based index of the first occurrence within the entire collection.
Public methodStatic member
LoadEnumerationSets(IListAFEnumerationSet)
Loads the specified list AFEnumerationSet objects.
Public methodStatic member
LoadEnumerationSets(PISystem, Guid)
Loads the AFEnumerationSet objects with the specified unique identifiers.
Public method
Persist
This method returns the persistence string for the object.
(Overrides AFObjectPersist.)
Public method
Refresh
Refreshes the client with any changes that have been made to the object since loaded.
Public method
Remove(Guid)
Removes the item with the specified id from the collection.
Public method
Remove(Int32)
The Remove method removes the item from the collection by its value.
Public method
Remove(String)
The Remove method removes the item from the collection by name.
Public method
Remove(AFEnumerationValue)
Removes the first occurrence of a specific object from the collection.
Public method
RemoveAt
Removes the item at the specified index of the collection.
Public method
Sort
Sorts the items in the entire collection using the default comparer.
Public method
Sort(IComparerAFEnumerationValue)
Sorts the items in the entire collection using the specified comparer.
Public method
Sort(Int32, Int32, IComparerAFEnumerationValue)
Sorts the items in a range of items in the collection using the specified comparer.
Public method
ToString
Returns a String that represents the current object.
(Inherited from AFObject.)
Public method
UndoCheckOut
This method discards all the changes to the object and all sub-objects since the last call to CheckOut. Any changes since the check out will be lost.

Events

  NameDescription
Public eventCode example
Changed
Event is raised when the object or one of its sub-objects is changed.

Extension Methods

  NameDescription
Public Extension Method
AggregateAFEnumerationValue
Performs all requested aggregates on the specified items.
(Defined by AFAggregate.)
Public Extension Method
AggregateAsyncAFEnumerationValue
Performs all requested aggregates on the specified items asynchronously.
(Defined by AFAggregate.)
Public Extension Method
BinnedSummaryAFEnumerationValue, TBin
Generates a summary broken down by the specified bins for items matching the search criteria.
(Defined by AFAggregate.)
Public Extension Method
BinnedSummaryAsyncAFEnumerationValue, TBin
Generates a summary broken down by the specified bins for items matching the search criteria asynchronously.
(Defined by AFAggregate.)
Public Extension MethodCode example
ChunkedByAFEnumerationValue
This extension method breaks up search results into chunks to make it easier to page through and process IEnumerableT collections in chunks.
(Defined by AFSDKExtension.)
Public Extension Method
FrequencyDistributionAFEnumerationValue
Generates a frequency distribution for the specified items.
(Defined by AFAggregate.)
Public Extension Method
FrequencyDistributionAsyncAFEnumerationValue
Generates a frequency distribution for the specified items asynchronously.
(Defined by AFAggregate.)
Public Extension Method
GroupedSummaryAFEnumerationValue
Generates a summary broken down by group for the specified items.
(Defined by AFAggregate.)
Public Extension Method
GroupedSummaryAsyncAFEnumerationValue
Generates a histogram for the specified items asynchronously.
(Defined by AFAggregate.)
Public Extension Method
HistogramAFEnumerationValue, TBin
Generates a histogram for the specified items with the specified weighting.
(Defined by AFAggregate.)
Public Extension Method
HistogramAsyncAFEnumerationValue, TBin
Generates a histogram for the specified items with the specified weighting asynchronously.
(Defined by AFAggregate.)
Public Extension Method
SummaryAFEnumerationValue(String, AFSummaryTypes)Overloaded.
Summarizes the specified items.
(Defined by AFAggregate.)
Public Extension Method
SummaryAFEnumerationValue(String, AFSummaryTypes, String)Overloaded.
Summarizes the specified items with the specified weighting.
(Defined by AFAggregate.)
Public Extension Method
SummaryAsyncAFEnumerationValue(String, AFSummaryTypes, CancellationToken)Overloaded.
Summarizes the specified items asynchronously.
(Defined by AFAggregate.)
Public Extension Method
SummaryAsyncAFEnumerationValue(String, AFSummaryTypes, String, CancellationToken)Overloaded.
Summarizes the specified items with the specified weighting asynchronously.
(Defined by AFAggregate.)

Remarks

The collection of available enumeration sets is maintained by the AFDatabase and PIServer. The SystemStateSet property returns the standard system enumeration set.

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