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

Inheritance Hierarchy
OSIsoft.AF.AssetAFValue
Namespace: OSIsoft.AF.Asset
Assembly: OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.1.1.1182
Syntax
[SerializableAttribute] public sealed class AFValue : ISerializable, IPIPersist, IComparable, IComparable<AFValue>, IEquatable<AFValue>
<SerializableAttribute> Public NotInheritable Class AFValue Implements ISerializable, IPIPersist, IComparable, IComparable(Of AFValue), IEquatable(Of AFValue) Dim instance As AFValue
[SerializableAttribute] public ref class AFValue sealed : ISerializable, IPIPersist, IComparable, IComparable<AFValue^>, IEquatable<AFValue^>
[<SealedAttribute>] [<SerializableAttribute>] type AFValue = class interface ISerializable interface IPIPersist interface IComparable interface IComparable<AFValue> interface IEquatable<AFValue> end
The AFValue type exposes the following members.
Constructors
| Name | Description | |
|---|---|---|
| AFValue |
This is the default constructor which creates a new AFValue
object with default values for its properties.
| |
| AFValue(Object) |
This is the constructor for an AFValue object which specifies
the value and uses defaults for all the other properties.
| |
| AFValue(AFValue) |
This is the copy constructor which creates a new AFValue
object with the same values as the specified AFValue object.
| |
| AFValue(Object, AFTime) |
This is the constructor for an AFValue object which specifies
the value and timestamp and uses defaults for all the other properties.
| |
| AFValue(Object, UOM) |
This is the constructor for an AFValue object which specifies
the value and unit of measure and uses defaults for all the other properties.
| |
| AFValue(Object, AFTime, UOM) |
This is the constructor for an AFValue object which specifies
the value, timestamp, and unit of measure and uses defaults for all the other properties.
| |
| AFValue(AFAttribute, Object, AFTime) |
This is the constructor for an AFValue object which specifies
the Attribute, the value, and timestamp and uses defaults
for all the other properties.
| |
| AFValue(Object, AFTime, UOM, AFValueStatus) |
This is the constructor for an AFValue object which specifies
all the properties.
| |
| AFValue(AFAttribute, Object, AFTime, UOM) |
This is the constructor for an AFValue object which specifies
the Attribute, the value, timestamp, and unit of measure and
uses defaults for all the other properties.
| |
| AFValue(AFAttribute, Object, AFTime, UOM, AFValueStatus) |
This is the constructor for an AFValue object which specifies
the Attribute for the value and all the properties of the value.
|
Properties
| Name | Description | |
|---|---|---|
| AdditionalInfo |
This property holds additional information associated with the value.
| |
| Annotated |
Indicates whether the value contains an annotation.
| |
| Attribute |
This property returns the AFAttribute associated with the value.
| |
| IsGood |
Indicates whether the value is good or bad.
| |
| PIPoint |
This property returns the PIPoint associated with the value.
| |
| Questionable |
Indicates whether the value has been identified as irregular in some way by an application.
| |
| Status |
Indicates the various conditions of the value.
| |
| Substituted |
Indicates whether value has been replaced after it was originally written.
| |
| Timestamp |
The timestamp associated with the value.
| |
| UOM |
This property contains the unit of measure (UOM) of the value.
| |
| Value |
This property contains the actual value.
| |
| ValueType |
Returns the Type for the value held by this AFValue.
| |
| ValueTypeCode |
Returns the TypeCode for the value held by this AFValue.
|
Methods
| Name | Description | |
|---|---|---|
| CompareTo(Object) |
Compares this instance with a specified Object.
| |
| CompareTo(AFValue) |
Compares this instance with a specified AFValue.
| |
| Convert(UOM) |
Returns a new AFValue in the specified UOM.
| |
| Convert(UOMGroup) | ||
| ConvertForAttribute |
Converts the current value using the type and units of measure configured for the specified attribute.
| |
| Create(AFAttribute, Double, AFTime, UOM, AFValueStatus, Object) | ||
| Create(AFAttribute, Int32, AFTime, UOM, AFValueStatus, Object) | ||
| Create(AFAttribute, Single, AFTime, UOM, AFValueStatus, Object) | ||
| CreateSystemNoDataFound |
This method will create an AFValue object with a system state of NoData as its AFEnumerationValue
with a Bad status that is associated with an AFAttribute.
| |
| CreateSystemStateValue(AFSystemStateCode, AFTime) |
This method will create an AFValue object with a system AFEnumerationValue
as its value with a Bad status that is not associated with an AFAttribute.
| |
| CreateSystemStateValue(AFAttribute, AFSystemStateCode, AFTime) |
This method will create an AFValue object with a system AFEnumerationValue
as its value with a Bad status that is associated with an AFAttribute.
| |
| DefaultValue |
Gets the default value for the specified type.
| |
| DisplayValue(Decimal, Int32, IFormatProvider) |
Displays the Decimal value based upon the specified number of display digits.
| |
| DisplayValue(Double, Int32, IFormatProvider) |
Displays the Double value based upon the specified number of display digits.
| |
| DisplayValue(Int32, IFormatProvider, Boolean) | ||
| DisplayValue(Object, Int32, IFormatProvider) |
Displays the Object value based upon the specified number of display digits.
| |
| DisplayValue(Single, Int32, IFormatProvider) |
Displays the Single value based upon the specified number of display digits.
| |
| Equals(Object) |
Determines whether the specified Object is equal to the current object.
(Overrides ObjectEquals(Object).) | |
| Equals(AFValue) |
Indicates whether the current object is equal to another object of the same type.
| |
| FromPIValue(Object) | Obsolete.
This method sets the value of this AFValue object from a
PISDK.PIValue object.
| |
| FromPIValue(Boolean, Object) | Obsolete.
This method sets the value of this AFValue object from a
PISDK.PIValue object.
| |
| FromPIValue(Object, Type, Object, AFEnumerationSet, UOM) | Obsolete.
This method sets the value of this AFValue object from a
PISDK.PIValue object, converting to the appropriate type as necessary.
| |
| GetAnnotation |
Gets the annotation associated with this AF value.
| |
| GetAnnotations |
Gets the annotation associated for each AF value in the specified list.
| |
| 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 ObjectGetHashCode.) | |
| GetType | Gets the Type of the current instance. (Inherited from Object.) | |
| Persist |
This method returns the persistence string for the object.
| |
| SetAnnotation |
Associates an annotation with this AF value.
| |
| ToPIValue | Obsolete.
This method returns the value of this object as a new PISDK.PIValue object.
| |
| ToPIValue(Object) | Obsolete.
This method sets the value of the passed in PISDK.PIValue object to the
value of this AFValue object.
| |
| ToString |
Returns a String that represents the current object.
(Overrides ObjectToString.) | |
| ValueAsDouble |
Returns the value held by this AFValue as a Double.
The value will be converted if possible.
If the value cannot be converted an exception will be throw.
The value can be checked before performing the conversion using the Type or TypeCode property.
| |
| ValueAsInt32 |
Returns the value held by this AFValue as a Int32.
The value will be converted if possible.
If the value cannot be converted an exception will be throw.
The value can be checked before performing the conversion using the Type or TypeCode property.
| |
| ValueAsSingle |
Returns the value held by this AFValue as a Single.
The value will be converted if possible.
If the value cannot be converted an exception will be throw.
The value can be checked before performing the conversion using the Type or TypeCode property.
|
Operators
| Name | Description | |
|---|---|---|
| Equality |
The equality operator (==) compares its operands to determine if they are equal.
| |
| GreaterThan |
The greater than relation operator (>) compares its operands to determine
which one is greater than the other.
| |
| GreaterThanOrEqual |
The greater than or equal relation operator (>=) compares its operands to determine
which one is greater than or equal to the other.
| |
| Inequality |
The inequality operator (!=) compares its operands to determine if they are not equal.
| |
| LessThan |
The less than relation operator (<) compares its operands to determine
which one is less than the other.
| |
| LessThanOrEqual |
The less than or equal relation operator (<=) compares its operands to determine
which one is less than or equal to the other.
|
Remarks
The AFValue object contains properties for the actual value (Value), the value's timestamp (Timestamp), status (Status, IsGood, Substituted, Questionable), and unit of measure (UOM). The actual value may be of any type, however, in order for a value to be saved, it must either be a .NET base type, a .NET serializable type, or support the PI SDK's IPIPersist interface. This means it is possible to save values such as arrays, System.Data.DataSet's, PI SDK objects, and references to other AF SDK objects.
If the type is an Exception, then it will be persisted to the PI AF Server as a string so that the error message can be viewed by older clients that may not have the exception type defined. The Status of the value will not be modified. This means that the value could initially be an exception, but change to a string when reloaded from the PI AF Server.
Examples
// This example shows how to create a dynamic attribute and obtain // the values of an attribute over a specified time range. // Get the Database PISystems myPISystems = new PISystems(); PISystem myPISystem = myPISystems.DefaultPISystem; AFDatabase myDB = myPISystem.Databases.DefaultDatabase; // Create the Attribute AFAttribute myAttribute = new AFAttribute(myDB); myAttribute.Name = "Sinusoid"; myAttribute.Type = typeof(float); myAttribute.DefaultUOM = myPISystem.UOMDatabase.UOMs["m"]; myAttribute.DataReferencePlugIn = AFDataReference.GetPIPointDataReference(myPISystem); myAttribute.ConfigString = @"\\%Server%\Sinusoid"; // Set the Time Range AFTimeRange myTimeRange = new AFTimeRange(); myTimeRange.StartTime = new AFTime(DateTime.UtcNow.AddHours(-1)); myTimeRange.EndTime = AFTime.Now; // Display each Value of the Attribute during the Time Range AFValues myValues = myAttribute.GetValues(myTimeRange, 0, null); Console.WriteLine("Number of values = {0}", myValues.Count); foreach (AFValue myValue in myValues) { Console.WriteLine("Annotated = {0}", myValue.Annotated); Console.WriteLine("IsGood = {0}", myValue.IsGood); Console.WriteLine("Questionable = {0}", myValue.Questionable); Console.WriteLine("Substituted = {0}", myValue.Substituted); Console.WriteLine("TimeStamp = {0}", myValue.Timestamp.LocalTime); Console.WriteLine("UOM = {0}", myValue.UOM); Console.WriteLine("Value = {0}", myValue.Value); }
' This example shows how to create a dynamic attribute and obtain ' the values of an attribute over a specified time range. ' Get the Database Dim myPISystems As New PISystems Dim myPISystem As PISystem = myPISystems.DefaultPISystem Dim myDB As AFDatabase = myPISystem.Databases.DefaultDatabase ' Create the Attribute Dim myAttribute As New AFAttribute(myDB) myAttribute.Name = "Sinusoid" myAttribute.Type = GetType(Double) myAttribute.DefaultUOM = myPISystem.UOMDatabase.UOMs("m") myAttribute.DataReferencePlugIn = AFDataReference.GetPIPointDataReference(myPISystem) myAttribute.ConfigString = "\\%Server%\Sinusoid" ' Set the Time Range Dim myTimeRange As New AFTimeRange() myTimeRange.StartTime = New AFTime(DateTime.UtcNow.AddHours(-1)) myTimeRange.EndTime = AFTime.Now ' Display each Value of the Attribute during the Time Range Dim myValues As AFValues = myAttribute.GetValues(myTimeRange, 0, Nothing) Console.WriteLine("Number of values = {0}", myValues.Count) Dim myValue As AFValue For Each myValue In myValues Console.WriteLine("Annotated = {0}", myValue.Annotated) Console.WriteLine("IsGood = {0}", myValue.IsGood) Console.WriteLine("Questionable = {0}", myValue.Questionable) Console.WriteLine("Substituted = {0}", myValue.Substituted) Console.WriteLine("TimeStamp = {0}", myValue.Timestamp.LocalTime) Console.WriteLine("UOM = {0}", myValue.UOM) Console.WriteLine("Value = {0}", myValue.Value) Next myValue
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.