AFDataReference Class
- Last UpdatedNov 18, 2025
- 21 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 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
| Name | Description | |
|---|---|---|
| Attribute |
This property returns the attribute that owns this object.
| |
| 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.
| |
| ConfigStringStored |
Returns the currently stored configuration string.
| |
| Database |
This read-only property returns the AFDatabase where this object is defined.
| |
| Description |
Read-only property that provides more detailed description of the object.
| |
| DisplayDigits |
The DisplayDigits property controls the format of numeric values on displays and in reports.
| |
| EditorType |
This method returns the Type of the editor that is used to configure this
data reference.
| |
| 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.) | |
| IsConfigured |
This method returns if the DR instance is properly configured.
| |
| IsDeleted |
This read-only property indicates whether the object has been deleted.
(Inherited from AFObject.) | |
| IsInitializing |
Indicates that the AFDataReference is in the process
of being initialized.
| |
| Name |
Read-only property that identifies the name of the object.
| |
| Path |
This read-only property returns the path name to this object.
| |
| PIPoint |
Returns the PIPoint associated with this AFDataReference.
| |
| PISystem |
This read-only property allows access to the PISystem associated with this
object.
(Inherited from AFObject.) | |
| PlugIn |
This read-only property returns the AFPlugIn used to create
this instance of the plugin.
| |
| ServerTime |
Gets the current time of the server associated with this AFDataReference.
| |
| ServerTimeSource |
Gets the server time source associated with this AFDataReference.
| |
| ServerTimeZone |
Gets the current time zone of the server associated with this AFDataReference.
| |
| Span |
This property represents the span of values for this AFDataReference.
| |
| Step |
This property returns if the value returned for this
AFDataReference is stepped.
| |
| SupportedContexts |
This read-only property specifies which of the data reference contexts are
supported when getting and/or setting values.
| |
| SupportedDataMethods |
This read-only property specifies which of the data methods are supported by
the data reference.
| |
| SupportedMethods |
This read-only property specifies which of the data reference methods are supported.
| |
| Template |
This property returns the attribute template that owns this object.
| |
| UniqueID |
Read-only property that provides the object's ID as a String.
(Inherited from AFObject.) | |
| UOM |
This property represents the source unit of measure (UOM) for the values
represented by the DataReference.
| |
| ValueEditorType |
This method returns the Type of the editor that is used to display and modify a value
provided by this data reference.
| |
| Zero |
This property represents the zero or low range value for this AFDataReference.
|
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.) | |
| CreateConfig |
This method is invoked by the user to update the attribute configuration relative to a foreign system.
| |
| CreateConfig(AFDatabase, EventHandlerAFProgressEventArgs) |
Executes the create configuration function of the data references found
within the attributes and its children of a database.
| |
| CreateConfig(PISystem, EventHandlerAFProgressEventArgs) |
Executes the create configuration function of the data references found
within the attributes and its children of a PI System.
| |
| CreateConfig(IList, Boolean, EventHandlerAFProgressEventArgs) |
Executes the create configuration function of the data references found
within the list of attributes and or elements.
| |
| CreateConfig(AFAttribute, Boolean, EventHandlerAFProgressEventArgs) |
Executes the create configuration function of the data reference found
within the specified attribute, and optionally, any child attributes.
| |
| CreateConfig(AFBaseElement, Boolean, EventHandlerAFProgressEventArgs) |
Executes the create configuration function of the data references found
within the attributes of the element, and optionally, its children.
| |
| CreateConfigEventFrames(AFDatabase, Object, Object, EventHandlerAFProgressEventArgs) |
Executes the create configuration function of the data references found
within the attributes and its children of a database.
| |
| 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.
| |
| DefaultSaveConfigChanges |
Called by the protected SaveConfigChanges method to perform the default actions to save
the configuration changes.
| |
| Equals(Object) |
Determines whether the specified Object is equal to the current object.
(Inherited from AFObject.) | |
| Equals(AFObject) |
Indicates whether the current object is equal to another object of the same type.
(Inherited from AFObject.) | |
| FilterCreateConfigSupportedAttributes |
Filter out attributes that do not support CreateConfig.
| |
| FilteredSummaries |
Returns several summaries for a single attribute over a time range for each interval within the range.
| |
| 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.
| |
| GetAnnotation |
Gets the annotation associated with a single historical event.
| |
| GetAttribute |
Retrieve the attribute for the specified name
relative to the attribute in this Data Reference.
| |
| GetAttributeTemplate |
Retrieve the attribute template for the specified name
relative to the attribute template in this Data Reference.
| |
| 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.) | |
| GetInputs |
This method provides the data reference a mechanism to specify the attributes
it will use during its calculation.
| |
| 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.) | |
| GetPIPointDataReference |
This method will return the AFPlugIn for the PIPoint
data reference.
| |
| GetToolTip |
Returns a tool tip suitable for displaying the current configuration.
| |
| GetType | Gets the Type of the current instance. (Inherited from Object.) | |
| GetValue(AFAttributeList, Object, Object) |
This method gets the value for multiple attributes based upon the data reference
configuration within the specified context.
| |
| GetValue(Object, Object, AFAttributeList, AFValues) |
This method gets the value based upon the data reference configuration
within the specified context.
| |
| GetValues |
This method gets a collection of AFValue objects for an attribute based upon
the data reference configuration within the specified AFTimeRange context.
| |
| InterpolatedValue |
Returns a single AFValue whose value is
interpolated at the passed time.
| |
| InterpolatedValueAsync |
Returns a single AFValue whose value is
interpolated at the passed time.
| |
| InterpolatedValuesAtTimes |
Retrieves interpolated values at the specified times.
| |
| InterpolatedValuesAtTimesAsync |
Retrieves interpolated values at the specified times.
| |
| InterpolatedValuesByCount |
Retrieves interpolated values over the specified time range evenly spaced using the numberOfValues.
| |
| InterpolatedValuesByCountAsync |
This method returns the specified number of interpolated values evenly spaced throughout the specified timeRange.
| |
| IsRepairSupported |
Checks whether attributes support Repair function.
| |
| IsReplacePIServerSupported(AFAttribute) |
Checks whether attributes and attribute templates support ReplacePIServer method.
| |
| IsReplacePIServerSupported(AFAttributeTemplate) |
Checks whether attributes supports ReplacePIServer.
| |
| Persist |
This method returns the persistence string for the object.
(Overrides AFObjectPersist.) | |
| PlotValues |
Returns a single AFValue whose value is
interpolated at the passed time.
| |
| PlotValuesAsync |
Retrieves values over the specified time range suitable for plotting over the number of intervals (typically represents pixels).
| |
| RecordedValue |
Returns a single recorded AFValue based on the
passed time and mode.
| |
| RecordedValueAsync |
Returns a single recorded AFValue based on the
passed time and mode.
| |
| RecordedValues |
Returns a list of compressed values for the requested time range
from the source provider.
| |
| RecordedValuesAsync |
Returns a list of values for the requested time range
from the source provider.
| |
| RecordedValuesAtTimes |
Retrieves recorded values at the specified times.
| |
| RecordedValuesAtTimesAsync |
Retrieves recorded values at the specified times.
| |
| RecordedValuesByCount |
This method returns a specified number of compressed values beginning at the requested start time in the direction specified.
| |
| RecordedValuesByCountAsync |
This method returns a specified number of compressed values beginning at the requested start time in the direction specified.
| |
| 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.
| |
| 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.
| |
| 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.
| |
| 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.
| |
| 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.
| |
| 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.
| |
| 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.
| |
| 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.
| |
| 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.
| |
| 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.
| |
| 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.
| |
| 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.
| |
| SetAnnotation |
Associates the annotation with the passed in value.
| |
| SetSaveConfigChangesHandler |
Set the handler used for saving ConfigString changes.
| |
| SetValue |
This method sets the value based upon the data reference configuration
within the specified context.
| |
| Summaries |
Returns several summaries for a single attribute over a time range for each interval within the range.
| |
| SummariesAsync |
Returns several summaries for a single attribute over a time range for each interval within the range.
| |
| Summary |
Returns several summaries for a single attribute over a single time range.
| |
| SummaryAsync |
Returns several summaries for a single attribute over a single time range.
| |
| ToString |
Returns a String that represents the current object.
(Overrides AFObjectToString.) | |
| UpdateValue(AFValue, AFUpdateOption) |
This method writes, replaces, or removes a value on the target system using the configured data reference.
| |
| UpdateValue(AFValue, AFUpdateOption, AFBufferOption) |
This method writes, replaces, or removes a value on the target system using the configured data reference.
| |
| UpdateValues(AFValues, AFUpdateOption) |
This method writes or replaces one or more values on the target system using the configured data reference.
| |
| UpdateValues(AFValues, AFUpdateOption, AFBufferOption) |
This method writes or replaces one or more values on the target system using the configured data reference.
| |
| UpdateValuesAsync(AFValues, AFUpdateOption, CancellationToken) |
This method writes or replaces one or more values on the target system using the configured data reference.
| |
| UpdateValuesAsync(AFValues, AFUpdateOption, AFBufferOption, CancellationToken) |
This method writes or replaces one or more values on the target system using the configured data reference.
| |
| 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.
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.