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

AF SDK Reference

AFDataReference Class

  • Last UpdatedNov 18, 2025
  • 21 minute read
AFDataReference Class
The AFDataReference is used by an AFAttribute and AFAttributeTemplate to define the information necessary and implement the mechanism used to read, calculate, and write a value (or series of values), given the specified context.

Inheritance Hierarchy

SystemObject
  OSIsoft.AFAFObject
    OSIsoft.AF.AssetAFDataReference

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

Syntax

[SerializableAttribute]
public abstract class AFDataReference : AFObject, 
	IComparable<AFDataReference>
<SerializableAttribute>
Public MustInherit Class AFDataReference
	Inherits AFObject
	Implements IComparable(Of AFDataReference)

Dim instance As AFDataReference
[SerializableAttribute]
public ref class AFDataReference abstract : public AFObject, 
	IComparable<AFDataReference^>
[<AbstractClassAttribute>]
[<SerializableAttribute>]
type AFDataReference =  
    class
        inherit AFObject
        interface IComparable<AFDataReference>
    end

The AFDataReference type exposes the following members.

Properties

  NameDescription
Public property
Attribute
This property returns the attribute that owns this object.
Public property
ConfigString
This property represents the current configuration of the Data Reference as a string suitable for displaying to an end-user and/or setting its configuration.
Public property
ConfigStringStored
Returns the currently stored configuration string.
Public property
Database
This read-only property returns the AFDatabase where this object is defined.
Public property
Description
Read-only property that provides more detailed description of the object.
Public property
DisplayDigits
The DisplayDigits property controls the format of numeric values on displays and in reports.
Public property
EditorType
This method returns the Type of the editor that is used to configure this data reference.
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
IsConfigured
This method returns if the DR instance is properly configured.
Public property
IsDeleted
This read-only property indicates whether the object has been deleted.
(Inherited from AFObject.)
Public property
IsInitializing
Indicates that the AFDataReference is in the process of being initialized.
Public property
Name
Read-only property that identifies the name of the object.
Public property
Path
This read-only property returns the path name to this object.
Public property
PIPoint
Returns the PIPoint associated with this AFDataReference.
Public property
PISystem
This read-only property allows access to the PISystem associated with this object.
(Inherited from AFObject.)
Public property
PlugIn
This read-only property returns the AFPlugIn used to create this instance of the plugin.
Public property
ServerTime
Gets the current time of the server associated with this AFDataReference.
Public property
ServerTimeSource
Gets the server time source associated with this AFDataReference.
Public property
ServerTimeZone
Gets the current time zone of the server associated with this AFDataReference.
Public property
Span
This property represents the span of values for this AFDataReference.
Public property
Step
This property returns if the value returned for this AFDataReference is stepped.
Public property
SupportedContexts
This read-only property specifies which of the data reference contexts are supported when getting and/or setting values.
Public property
SupportedDataMethods
This read-only property specifies which of the data methods are supported by the data reference.
Public property
SupportedMethods
This read-only property specifies which of the data reference methods are supported.
Public property
Template
This property returns the attribute template that owns this object.
Public property
UniqueID
Read-only property that provides the object's ID as a String.
(Inherited from AFObject.)
Public property
UOM
This property represents the source unit of measure (UOM) for the values represented by the DataReference.
Public property
ValueEditorType
This method returns the Type of the editor that is used to display and modify a value provided by this data reference.
Public property
Zero
This property represents the zero or low range value for this AFDataReference.

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 methodCode example
CreateConfig
This method is invoked by the user to update the attribute configuration relative to a foreign system.
Public methodStatic member
CreateConfig(AFDatabase, EventHandlerAFProgressEventArgs)
Executes the create configuration function of the data references found within the attributes and its children of a database.
Public methodStatic member
CreateConfig(PISystem, EventHandlerAFProgressEventArgs)
Executes the create configuration function of the data references found within the attributes and its children of a PI System.
Public methodStatic member
CreateConfig(IList, Boolean, EventHandlerAFProgressEventArgs)
Executes the create configuration function of the data references found within the list of attributes and or elements.
Public methodStatic member
CreateConfig(AFAttribute, Boolean, EventHandlerAFProgressEventArgs)
Executes the create configuration function of the data reference found within the specified attribute, and optionally, any child attributes.
Public methodStatic member
CreateConfig(AFBaseElement, Boolean, EventHandlerAFProgressEventArgs)
Executes the create configuration function of the data references found within the attributes of the element, and optionally, its children.
Public methodStatic member
CreateConfigEventFrames(AFDatabase, Object, Object, EventHandlerAFProgressEventArgs)
Executes the create configuration function of the data references found within the attributes and its children of a database.
Public methodStatic member
CreateConfigEventFrames(PISystem, Object, Object, EventHandlerAFProgressEventArgs)
Executes the create configuration function of the data references found within the attributes and its children of a PI System.
Public method
DefaultSaveConfigChanges
Called by the protected SaveConfigChanges method to perform the default actions to save the configuration changes.
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
FilterCreateConfigSupportedAttributes
Filter out attributes that do not support CreateConfig.
Public method
FilteredSummaries
Returns several summaries for a single attribute over a time range for each interval within the range.
Public method
FilteredSummariesAsync
This method, when supplied a filter expression that evaluates to true or false, evaluates it over the passed time range. For the time ranges where the expression evaluates to true, the method calculates the requested summaries on the source attribute.
Public method
GetAnnotation
Gets the annotation associated with a single historical event.
Public method
GetAttribute
Retrieve the attribute for the specified name relative to the attribute in this Data Reference.
Public method
GetAttributeTemplate
Retrieve the attribute template for the specified name relative to the attribute template in this Data Reference.
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
GetInputs
This method provides the data reference a mechanism to specify the attributes it will use during its calculation.
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 methodStatic member
GetPIPointDataReference
This method will return the AFPlugIn for the PIPoint data reference.
Public method
GetToolTip
Returns a tool tip suitable for displaying the current configuration.
Public method
GetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodStatic member
GetValue(AFAttributeList, Object, Object)
This method gets the value for multiple attributes based upon the data reference configuration within the specified context.
Public method
GetValue(Object, Object, AFAttributeList, AFValues)
This method gets the value based upon the data reference configuration within the specified context.
Public method
GetValues
This method gets a collection of AFValue objects for an attribute based upon the data reference configuration within the specified AFTimeRange context.
Public method
InterpolatedValue
Returns a single AFValue whose value is interpolated at the passed time.
Public method
InterpolatedValueAsync
Returns a single AFValue whose value is interpolated at the passed time.
Public method
InterpolatedValuesAtTimes
Retrieves interpolated values at the specified times.
Public method
InterpolatedValuesAtTimesAsync
Retrieves interpolated values at the specified times.
Public method
InterpolatedValuesByCount
Retrieves interpolated values over the specified time range evenly spaced using the numberOfValues.
Public method
InterpolatedValuesByCountAsync
This method returns the specified number of interpolated values evenly spaced throughout the specified timeRange.
Public methodStatic member
IsRepairSupported
Checks whether attributes support Repair function.
Public methodStatic member
IsReplacePIServerSupported(AFAttribute)
Checks whether attributes and attribute templates support ReplacePIServer method.
Public methodStatic member
IsReplacePIServerSupported(AFAttributeTemplate)
Checks whether attributes supports ReplacePIServer.
Public method
Persist
This method returns the persistence string for the object.
(Overrides AFObjectPersist.)
Public method
PlotValues
Returns a single AFValue whose value is interpolated at the passed time.
Public method
PlotValuesAsync
Retrieves values over the specified time range suitable for plotting over the number of intervals (typically represents pixels).
Public method
RecordedValue
Returns a single recorded AFValue based on the passed time and mode.
Public method
RecordedValueAsync
Returns a single recorded AFValue based on the passed time and mode.
Public method
RecordedValues
Returns a list of compressed values for the requested time range from the source provider.
Public method
RecordedValuesAsync
Returns a list of values for the requested time range from the source provider.
Public method
RecordedValuesAtTimes
Retrieves recorded values at the specified times.
Public method
RecordedValuesAtTimesAsync
Retrieves recorded values at the specified times.
Public method
RecordedValuesByCount
This method returns a specified number of compressed values beginning at the requested start time in the direction specified.
Public method
RecordedValuesByCountAsync
This method returns a specified number of compressed values beginning at the requested start time in the direction specified.
Public methodStatic member
Repair(AFDatabase, EventHandlerAFProgressEventArgs)
Executes the repair function on the PI Point or PI Point Array data references found within the attributes and its children of a database. When PI point ids or point names in the ConfigString no longer match those on the PI Data Archive, a repair fixes the mismatch.
Public methodStatic member
Repair(PISystem, EventHandlerAFProgressEventArgs)
Executes the repair function on the PI Point or PI Point Array data references found within the attributes and its children of a PI System. When point ids or point names in the ConfigString no longer match those on the PI Data Archive, a repair fixes the mismatch.
Public methodStatic member
RepairEventFrames(AFDatabase, Object, Object, EventHandlerAFProgressEventArgs)
Executes the repair function on the PI Point or PI Point Array data references found within the attributes and its children of event frames of a database. When point ids or point names in the ConfigString no longer match those on the PI Data Archive, a repair fixes the mismatch.
Public methodStatic member
RepairEventFrames(PISystem, Object, Object, EventHandlerAFProgressEventArgs)
Executes the repair function on the PI Point or PI Point Array data references found within the attributes and its children of event frames of a PI System. When point ids or point names in the ConfigString no longer match those on the PI Data Archive, a repair fixes the mismatch.
Public methodStatic member
ReplacePIServer(AFDatabase, String, String, EventHandlerAFProgressEventArgs)
Replaces the PI Data Archive server name with another server on the PI Point and PI Point Array data references found within the attributes and attribute templates and its children of a database.
Public methodStatic member
ReplacePIServer(PISystem, String, String, EventHandlerAFProgressEventArgs)
Replaces the PI Data Archive server name with another server name on the PI Point and PI Point Array data references found within the attributes and attribute templates and its children of a PI System.
Public methodStatic member
ReplacePIServerEventFrames(AFDatabase, String, String, Object, Object, EventHandlerAFProgressEventArgs)
Replaces the PI Data Archive server with another server on the PI Point and PI Point Array data references found within the attributes and attribute templates and its children of event frames of a database.
Public methodStatic member
ReplacePIServerEventFrames(PISystem, String, String, Object, Object, EventHandlerAFProgressEventArgs)
Replaces the PI Data Archive server with another server on the PI Point and PI Point Array data references found within the attributes and attribute templates and its children of event frames of a PI System.
Public method
ReplaceValues(AFTimeRange, AFValues)
This method removes existing data within the specified AFTimeRange and inserts the specified values on the target system using the configured data reference.
Public method
ReplaceValues(AFTimeRange, AFValues, AFBufferOption)
This method removes existing data within the specified AFTimeRange and inserts the specified values on the target system using the configured data reference.
Public method
ReplaceValuesAsync(AFTimeRange, AFValues, CancellationToken)
This method removes existing data within the specified AFTimeRange and inserts the specified values on the target system using the configured data reference.
Public method
ReplaceValuesAsync(AFTimeRange, AFValues, AFBufferOption, CancellationToken)
This method removes existing data within the specified AFTimeRange and inserts the specified values on the target system using the configured data reference.
Public method
SetAnnotation
Associates the annotation with the passed in value.
Public method
SetSaveConfigChangesHandler
Set the handler used for saving ConfigString changes.
Public method
SetValue
This method sets the value based upon the data reference configuration within the specified context.
Public method
Summaries
Returns several summaries for a single attribute over a time range for each interval within the range.
Public method
SummariesAsync
Returns several summaries for a single attribute over a time range for each interval within the range.
Public method
Summary
Returns several summaries for a single attribute over a single time range.
Public method
SummaryAsync
Returns several summaries for a single attribute over a single time range.
Public method
ToString
Returns a String that represents the current object.
(Overrides AFObjectToString.)
Public method
UpdateValue(AFValue, AFUpdateOption)
This method writes, replaces, or removes a value on the target system using the configured data reference.
Public method
UpdateValue(AFValue, AFUpdateOption, AFBufferOption)
This method writes, replaces, or removes a value on the target system using the configured data reference.
Public method
UpdateValues(AFValues, AFUpdateOption)
This method writes or replaces one or more values on the target system using the configured data reference.
Public methodCode example
UpdateValues(AFValues, AFUpdateOption, AFBufferOption)
This method writes or replaces one or more values on the target system using the configured data reference.
Public method
UpdateValuesAsync(AFValues, AFUpdateOption, CancellationToken)
This method writes or replaces one or more values on the target system using the configured data reference.
Public method
UpdateValuesAsync(AFValues, AFUpdateOption, AFBufferOption, CancellationToken)
This method writes or replaces one or more values on the target system using the configured data reference.
Public methodStatic member
UsesInternalAFValue
Determines if the specified AFPlugIn uses the SetInternalAFValue method for storing values.

Remarks

Data References are defined and implemented by AFPlugIns which inherit from this abstract class.

Note Notes to Implementers

AFDataReference is an extension mechanism that allows an attribute to read and write data from sources outside of AF. OSIsoft provides several pre-defined AFDataReferences for accessing PI Points, accessing Table data, computing formulas, and other tasks. It is possible to extend the capabilities of AF by writing custom data references. Common examples of custom AFDataReferences include custom computations or reading and writing data that resides outside the PI System.

Each custom AFDataReference class implementation requires a unique System.Runtime.InteropServices.GuidAttribute attribute to be specified to uniquely identify the data reference in AF. A System.SerializableAttribute and System.ComponentModel.DescriptionAttribute are also required on the class before an AFDataReference can be used in AF.

Custom AFDataReferences can store configuration data as part of an AFAttribute definition, supply a user interface to permit AF users to configure the AFDataReference, and compute values by accessing their own values and using other AFAttributes as inputs. AFDataReferences can also write back data values to data stores outside the PI System. AFDataReferences can differ in the capabilities and complexity of their implementation, and a custom AFDataReference can implement only the subset of capabilities necessary to meet the functional needs of the AFDataReference. Other required functionality is provided by the AFDataReference base class. The capabilities of custom AFDataReferences are exposed using the SupportedMethods and SupportedDataMethods properties.

SupportedMethods is used to define the methods that are exposed in a custom AFDataReference by returning members of the AFDataReferenceMethod enumeration. Only methods that are returned from this property will be called.

OSIsoft.AF.Data support can be added to a custom AFDataReference by overriding SupportedDataMethods and returning the set of OSIsoft.AF.Data methods supported by the AFDataReference. Supported OSIsoft.AF.Data methods are defined using the AFDataMethods enumeration.

Storing configuration is achieved by overriding the default implementation of the ConfigString property. The ConfigString property will be persisted as part of the AFAttribute definition. The ConfigString is usually used to store navigation or connection information to access data values returned in the GetValue(Object, Object, AFAttributeList, AFValues) and GetValues(Object, AFTimeRange, Int32, AFAttributeList, AFValues) methods, or set in the SetValue(Object, AFValue) method.

A configuration user interface can be provided by overriding the EditorType property. The EditorType must be a .NET Type that inherits from System.Windows.Forms. The constructor of the EditorType must accept an AFDataReference and a Boolean in the constructor. The EditorType user interface should modify the ConfigString in the AFDataReference to persist changes.

Retrieval of custom values is enabled by overriding the GetValue(Object, Object, AFAttributeList, AFValues) and GetValues(Object, AFTimeRange, Int32, AFAttributeList, AFValues) methods which are called when the AFAttribute hosting the AFDataReference is instantiated.

Setting of values is accomplished by overriding the SetValue(Object, AFValue) method to write to a data store outside the PI System or to write a transformed/calculated value to a PI Data or PI AF Server. For this method to be called, it must be specified in the SupportedDataMethods property.

A custom AFDataReference can reference other AFAttributes in AF. These references and other persistent configuration data can be configured in the EditorType user interface and stored in the ConfigString property of the AFDataReference. If the custom AFDataReference supports referencing other AFAttributes then the implementer should override the GetInputs(Object) method to return the list of AFAttributes referenced by the custom AFDataReference. When this is done, AF will return the current values of the AFAttributes to the GetValue(Object, Object, AFAttributeList, AFValues) and GetValues(Object, AFTimeRange, Int32, AFAttributeList, AFValues) methods. Implementing GetInputs(Object) will provide better performance than retrieving attribute values in the AFDataReference implementation.

During development a custom AFDataReference can be tested by running the RegPlugin.exe or RegPlugin64.exe tool that is installed with the AF SDK. These tools can be found in the same directory where the AF SDK was installed. It is recommended that initial development of custom AFDataReferences occur on a PI AF Server that is not being used in production. When a custom data reference is tested and ready to be deployed in production, running RegPlugIn.exe or RegPlugin64.exe specifying the production server will deploy the custom AFDataReference.

Examples

// This data reference reads and writes an integer value that is 
// persisted in the ConfigString property
[Serializable]
[Guid("c9d5bf73-9d26-42c1-9716-d890c0a56914")]
[Description("SampleCS; CSharp Sample Data Reference.")]
public class SampleDR : AFDataReference
{
    int _value = 42;
    public override AFDataReferenceMethod SupportedMethods
    {
        get
        {
            return (AFDataReferenceMethod.GetValue | AFDataReferenceMethod.GetValues | AFDataReferenceMethod.SetValue);
        }
    }
    public override AFDataMethods SupportedDataMethods
    {
        get 
        { 
            return base.DefaultSupportedDataMethods; 
        }
    }
    public override AFValues GetValues(object context, AFTimeRange timeRange, int numberOfValues, AFAttributeList inputAttributes, AFValues[] inputValues)
    {
        return base.GetValues(context, timeRange, numberOfValues, inputAttributes, inputValues);
    }
    public override AFValue GetValue(object context, object timeContext, AFAttributeList inputAttributes, AFValues inputValues)
    {
        return new AFValue(_value, AFTime.Now);
    }

    // In most cases the ConfigString stores information
    // on how to retrieve the data values instead of the 
    // data itself, and the data value from a SetValue call
    // is stored in an AFAttribute,  PI tag, or other store. 
    // In this simple example we store the data itself in the ConfigString.
    public override void SetValue(object context, AFValue newValue)
    {
        if (newValue != null && newValue.Value != null)
            this.ConfigString = newValue.Value.ToString();
        else
            this.ConfigString = String.Empty;
    }
    public override string ConfigString
    {
        get 
        { 
            return this._value.ToString(CultureInfo.InvariantCulture); 
        }
        set
        {
            if (System.Int32.TryParse(value, out _value))
            {
                base.ConfigString = value;
                base.SaveConfigChanges();
            }
        }
    }
}
' This data reference reads and writes an integer value that is 
' persisted in the ConfigString property
<Serializable(), _
 Guid("c9d5bf74-9d26-42c1-9716-d890c0a56914"), _
 Description("SampleVB; VB.Net Sample Data Reference.")> _
Public Class SampleDR
    Inherits AFDataReference

    Private _value As Integer = 42

    Public Overrides ReadOnly Property SupportedMethods _
            As AFDataReferenceMethod
        Get
            Return (AFDataReferenceMethod.GetValue _
                        Or (AFDataReferenceMethod.GetValues _
                            Or AFDataReferenceMethod.SetValue))
        End Get
    End Property

    Public Overrides ReadOnly Property SupportedDataMethods As AFDataMethods
        Get
            Return MyBase.DefaultSupportedDataMethods
        End Get
    End Property

    Public Overrides Function GetValues(ByVal context As Object, _
                                        ByVal timeRange As AFTimeRange, _
                                        ByVal numberOfValues As Integer, _
                                        ByVal inputAttributes _
                                            As AFAttributeList, _
                                        ByVal inputValues() As AFValues) _
                                    As AFValues
        Return MyBase.GetValues(context, timeRange, numberOfValues, _
                                inputAttributes, inputValues)
    End Function

    Public Overrides Function GetValue(ByVal context As Object, _
                                       ByVal timeContext As Object, _
                                       ByVal inputAttributes _
                                            As AFAttributeList, _
                                       ByVal inputValues As AFValues) _
                                   As AFValue
        Return New AFValue(_value, AFTime.Now)
    End Function

    ' In most cases the ConfigString stores information
    ' on how to retrieve the data values instead of the 
    ' data itself, and the data value from a SetValue call
    ' is stored in an AFAttribute,  PI tag, or other store. 
    ' In this simple example we store  the data in the ConfigString.
    Public Overrides Sub SetValue(ByVal context As Object, _
                                  ByVal newValue As AFValue)
        If ((Not (newValue) Is Nothing) _
         AndAlso (Not (newValue.Value) Is Nothing)) Then
            Me.ConfigString = newValue.Value.ToString
        Else
            Me.ConfigString = String.Empty
        End If
    End Sub

    Public Overrides Property ConfigString As String
        Get
            Return Me._value.ToString(CultureInfo.InvariantCulture)
        End Get
        Set(value As String)
            If System.Int32.TryParse(value, _value) Then
                MyBase.ConfigString = value
                MyBase.SaveConfigChanges()
            End If
        End Set
    End Property
End Class

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