Click or drag to resize
OSIsoft, LLC

AFValue Class

The AFValue object is used to represent the value of an AFAttribute along with a timestamp, status, and unit of measure.

Inheritance Hierarchy
SystemObject
  OSIsoft.AF.AssetAFValue

Namespace:  OSIsoft.AF.Asset
Assembly:  OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 2.10.6.195
Syntax
[SerializableAttribute]
public sealed class AFValue : ISerializable, 
	IPIPersist, IComparable, IComparable<AFValue>, IEquatable<AFValue>

The AFValue type exposes the following members.

Constructors
  NameDescription
Public methodAFValue
This is the default constructor which creates a new AFValue object with default values for its properties.
Public methodAFValue(Object)
This is the constructor for an AFValue object which specifies the value and uses defaults for all the other properties.
Public methodAFValue(AFValue)
This is the copy constructor which creates a new AFValue object with the same values as the specified AFValue object.
Public methodAFValue(Object, AFTime)
This is the constructor for an AFValue object which specifies the value and timestamp and uses defaults for all the other properties.
Public methodAFValue(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.
Public methodAFValue(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.
Public methodAFValue(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.
Public methodAFValue(Object, AFTime, UOM, AFValueStatus)
This is the constructor for an AFValue object which specifies all the properties.
Public methodAFValue(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.
Public methodAFValue(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.
Top
Properties
  NameDescription
Public propertyAdditionalInfo
This property holds additional information associated with the value.
Public propertyAnnotated
Indicates whether the value contains an annotation.
Public propertyAttribute
This property returns the AFAttribute associated with the value.
Public propertyIsGood
Indicates whether the value is good or bad.
Public propertyPIPoint
This property returns the PIPoint associated with the value.
Public propertyQuestionable
Indicates whether the value has been identified as irregular in some way by an application.
Public propertyStatus
Indicates the various conditions of the value.
Public propertySubstituted
Indicates whether value has been replaced after it was originally written.
Public propertyTimestamp
The timestamp associated with the value.
Public propertyUOM
This property contains the unit of measure (UOM) of the value.
Public propertyValue
This property contains the actual value.
Public propertyValueType
Returns the Type for the value held by this AFValue.
Public propertyValueTypeCode
Returns the TypeCode for the value held by this AFValue.
Top
Methods
  NameDescription
Public methodCompareTo(Object)
Compares this instance with a specified Object.
Public methodCompareTo(AFValue)
Compares this instance with a specified AFValue.
Public methodConvert(UOM)
Returns a new AFValue in the specified UOM.
Public methodCode exampleConvert(UOMGroup)
Returns a new AFValue in the UOM specified by the UOMGroup.
Public methodConvertForAttribute
Converts the current value using the type and units of measure configured for the specified attribute.
Public methodStatic memberCreate(AFAttribute, Double, AFTime, UOM, AFValueStatus, Object)
This method will create an AFValue object of Double type that is associated with an AFAttribute.
Public methodStatic memberCreate(AFAttribute, Int32, AFTime, UOM, AFValueStatus, Object)
This method will create an AFValue object of Int32 type that is associated with an AFAttribute.
Public methodStatic memberCreate(AFAttribute, Single, AFTime, UOM, AFValueStatus, Object)
This method will create an AFValue object of Single type that is associated with an AFAttribute.
Public methodStatic memberCreateSystemNoDataFound
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.
Public methodStatic memberCreateSystemStateValue(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.
Public methodStatic memberCreateSystemStateValue(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.
Public methodStatic memberDefaultValue
Gets the default value for the specified type.
Public methodStatic memberDisplayValue(Decimal, Int32, IFormatProvider)
Displays the Decimal value based upon the specified number of display digits.
Public methodStatic memberDisplayValue(Double, Int32, IFormatProvider)
Displays the Double value based upon the specified number of display digits.
Public methodDisplayValue(Int32, IFormatProvider, Boolean)
Displays the Value based upon the value's Type with the option to add the value's UOM abbreviation.
Public methodStatic memberDisplayValue(Object, Int32, IFormatProvider)
Displays the Object value based upon the specified number of display digits.
Public methodStatic memberDisplayValue(Single, Int32, IFormatProvider)
Displays the Single value based upon the specified number of display digits.
Public methodEquals(Object)
Determines whether the specified Object is equal to the current object.
(Overrides ObjectEquals(Object).)
Public methodEquals(AFValue)
Indicates whether the current object is equal to another object of the same type.
Public methodFromPIValue(Object) Obsolete.
This method sets the value of this AFValue object from a PISDK.PIValue object.
Public methodFromPIValue(Boolean, Object) Obsolete.
This method sets the value of this AFValue object from a PISDK.PIValue object.
Public methodFromPIValue(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.
Public methodCode exampleGetAnnotation
Gets the annotation associated with this AF value.
Public methodStatic memberGetAnnotations
Gets the annotation associated for each AF value in the specified list.
Public methodGetHashCode
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.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodPersist
This method returns the persistence string for the object.
Public methodCode exampleSetAnnotation
Associates an annotation with this AF value.
Public methodToPIValue Obsolete.
This method returns the value of this object as a new PISDK.PIValue object.
Public methodToPIValue(Object) Obsolete.
This method sets the value of the passed in PISDK.PIValue object to the value of this AFValue object.
Public methodToString
Returns a String that represents the current object.
(Overrides ObjectToString.)
Public methodValueAsDouble
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.
Public methodValueAsInt32
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.
Public methodValueAsSingle
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.
Top
Operators
  NameDescription
Public operatorStatic memberEquality
The equality operator (==) compares its operands to determine if they are equal.
Public operatorStatic memberGreaterThan
The greater than relation operator (>) compares its operands to determine which one is greater than the other.
Public operatorStatic memberGreaterThanOrEqual
The greater than or equal relation operator (>=) compares its operands to determine which one is greater than or equal to the other.
Public operatorStatic memberInequality
The inequality operator (!=) compares its operands to determine if they are not equal.
Public operatorStatic memberLessThan
The less than relation operator (<) compares its operands to determine which one is less than the other.
Public operatorStatic memberLessThanOrEqual
The less than or equal relation operator (<=) compares its operands to determine which one is less than or equal to the other.
Top
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);
}
Version Information

AFSDK

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, 2.4
See Also
Enabling Operational Intelligence