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

AF SDK Reference

PIDataPipe Class

  • Last UpdatedNov 18, 2025
  • 7 minute read
PIDataPipe Class
The PIDataPipe is used to subscribe for data change events on a list of PIPoint instances. The PIPoint instances do not have to be associated with the same PIServer. PIDataPipe instances can sign up for archive, snapshot or timeseries events. The pipe type is specified when the data pipe object is constructed.

Inheritance Hierarchy

SystemObject
  OSIsoft.AF.PIPIDataPipe

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

Syntax

public sealed class PIDataPipe : IDisposable
Public NotInheritable Class PIDataPipe
	Implements IDisposable

Dim instance As PIDataPipe
public ref class PIDataPipe sealed : IDisposable
[<SealedAttribute>]
type PIDataPipe =  
    class
        interface IDisposable
    end

The PIDataPipe type exposes the following members.

Constructors

  NameDescription
Public method
PIDataPipe
Constructs a new PIDataPipe used to sign up for events on a list of PIPoint objects

Properties

  NameDescription
Public property
DataPipeStatistics
Contains statistics for the most recent signup or event scan.

Methods

  NameDescription
Public method
AddSignups
Adds a list of PIPoint objects to be monitored by the data pipe. The method returns server level and point level errors in AFErrorsTKey .
Public method
AddSignupsWithInitEvents
Adds a list of PIPoint objects to be monitored by the data pipe and returns the initial events for this list of new signup objects. PIserver level and point level errors can be accessed in the AFListResultsTKey, TResult
Public method
AsReadOnly
Returns a read only list of PIPoint objects currently monitored by the data pipe.
Public method
Close
Terminates the data pipe's connection to the PIServers associated with the monitored PIPoint objects.
Public method
Dispose
Terminates the data pipe's connection to the PIServers associated with the monitored PIPoint objects. This method also releases the resources used by the PIDataPipe. Calling any method after the object has been disposed will result in an exception being thrown.
Public method
Equals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public method
GetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public method
GetObserverEvents
Trigger retrieval of new events that occurred on the PIPoint objects monitored by the data pipe. The new events will be sent to the IObserver objects registered with the data pipe.
Public method
GetType
Gets the Type of the current instance.
(Inherited from Object.)
Public method
GetUpdateEvents
Retrieves new events that occurred on the PIPoint objects monitored by the data pipe.
Public method
ListSignUpsByServer
Return a list of PIPoint objects monitored by the data pipe for the requested PIServer.
Public method
RemoveSignups
Remove a list of PIPoint objects being monitored by the data pipe. The method returns server level and point level errors in AFErrorsTKey .
Public method
Subscribe
Register an IObserver for AFDataPipeEvent with the PIDataPipe. All the AFDataPipeEvents received by the data pipe will be sent to the IObserver.
Public method
ToString
Returns a string that represents the current object.
(Inherited from Object.)

Remarks

There are two ways to get the data change events: a) direct GetUpdateEvents method to get events; b) through IObserver of AFDataPipeEvent. The IObserver pattern provides significant performance improvement over direct GetUpdateEvents method for high throughput scenario. Application will have to implement the IObserver and register the IObserver with the data pipe via the Subscribe(IObserverAFDataPipeEvent) method.

Note Notes to Callers
This method, property, or class is not available in the legacy .NET 3.5 version of the SDK.

Examples

// This example demonstrates how to create a PIDataPipe that receives
// snapshot events for a list of PIPoint objects.

// Get default PI Data Archive
PIServer myServer = PIServers.GetPIServers().DefaultPIServer;

// List to hold the PIPoint objects that we will sign up for updates on
List<string> nameList = new List<string>();
List<string> ptattList = new List<string>();

// Add points we are interested in
nameList.Add("sinusoid");
nameList.Add("sinusoidu");
nameList.Add("cdt158");
nameList.Add("cdm158");
ptattList.Add(PICommonPointAttributes.PointType);
ptattList.Add(PICommonPointAttributes.Zero);
ptattList.Add(PICommonPointAttributes.Span);

IList<PIPoint> myList = PIPoint.FindPIPoints(myServer, nameList, ptattList);

List<AFDataPipeEvent> pipeResults = new List<AFDataPipeEvent>();

// Create a new data pipe for snapshot events
using (PIDataPipe myDataPipe = new PIDataPipe(AFDataPipeType.Snapshot))
{
    // Sign up for updates on the points
    myDataPipe.AddSignups(myList);

    // For the next 30 seconds...
    for (int secondsIndex = 0; secondsIndex < 30; secondsIndex++)
    {
        // Get events that have occurred in the last second
        AFListResults<PIPoint, AFDataPipeEvent> myResults = myDataPipe.GetUpdateEvents(10);

        // If there are some results
        if (myResults.Results.Count > 0)
        {
            // For each event...
            foreach (AFDataPipeEvent mySnapshotEvent in myResults.Results)
            {
                // If the event was added or updated in the snapshot...
                if (mySnapshotEvent.Action == AFDataPipeAction.Add ||
                    mySnapshotEvent.Action == AFDataPipeAction.Update)
                {
                    // Display the new value
                    DisplaySnapshot(mySnapshotEvent.Value.PIPoint.Name, mySnapshotEvent.Value.Value);
                }
                pipeResults.Add(mySnapshotEvent);
            }
        }

        // Wait one second
        System.Threading.Thread.Sleep(1000);
    }
}
' This example demonstrates how to create a PIDataPipe that receives
' snapshot events for a list of PIPoint objects.

' Get default PI Data Archive
Dim myServer As PIServer = PIServers.GetPIServers().DefaultPIServer

' List to hold the PIPoint objects that we will sign up for updates on
Dim myList As List(Of PIPoint) = New List(Of PIPoint)

' Add points we are interested in
myList.Add(PIPoint.FindPIPoint(myServer, "sinusoid"))
myList.Add(PIPoint.FindPIPoint(myServer, "sinusoidu"))
myList.Add(PIPoint.FindPIPoint(myServer, "cdt158"))
myList.Add(PIPoint.FindPIPoint(myServer, "cdm158"))

' Create a new data pipe for snapshot events
Dim myDataPipe As PIDataPipe = New PIDataPipe(AFDataPipeType.Snapshot)

' Sign up for updates on the points
myDataPipe.AddSignups(myList)
System.Threading.Thread.Sleep(2000)  '//make sure no timing issue in testcase 

' For the next 30 seconds...
For secondsIndex As Integer = 1 To 30

    'Get events that have occurred in the last second
    Dim myResults As AFListResults(Of PIPoint, AFDataPipeEvent) = myDataPipe.GetUpdateEvents(10)

    ' For each event...
    For Each mySnapshotEvent As AFDataPipeEvent In myResults.Results

        ' If the event was added or updated in the snapshot...
        If mySnapshotEvent.Action = AFDataPipeAction.Add OrElse mySnapshotEvent.Action = AFDataPipeAction.Update Then

            ' Display the new value
            DisplaySnapshot(mySnapshotEvent.Value.PIPoint.Name, mySnapshotEvent.Value.Value)

        End If
    Next

    System.Threading.Thread.Sleep(1000)
Next

' Release resources
myDataPipe.Dispose()

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.

private static void DisplaySnapshot(string tagName, object value)
{
    // Display the tag name along with the new snapshot value
    Console.WriteLine("PI Point: {0} Snapshot Value: {1}", tagName, value);
}
Private Shared Sub DisplaySnapshot(tagName As String, value As Object)

    ' Display the tag name along with the new snapshot value
    Console.WriteLine("PI Point: {0} Snapshot Value: {1}", tagName, value)

End Sub

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