Click or drag to resize
OSIsoft, LLC

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

Namespace:  OSIsoft.AF.PI
Assembly:  OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version:
public sealed class PIDataPipe : IDisposable

The PIDataPipe type exposes the following members.

Public methodPIDataPipe
Constructs a new PIDataPipe used to sign up for events on a list of PIPoint objects
Public propertyDataPipeStatistics
Contains statistics for the most recent signup or event scan.
Public methodAddSignups
Public methodAddSignupsWithInitEvents
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 methodAsReadOnly
Returns a read only list of PIPoint objects currently monitored by the data pipe.
Public methodClose
Terminates the data pipe's connection to the PIServers associated with the monitored PIPoint objects.
Public methodDispose
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 methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetObserverEvents
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 methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodGetUpdateEvents
Retrieves new events that occurred on the PIPoint objects monitored by the data pipe.
Public methodListSignUpsByServer
Return a list of PIPoint objects monitored by the data pipe for the requested PIServer.
Public methodRemoveSignups
Remove a list of PIPoint objects being monitored by the data pipe. The method returns server level and point level errors in AFErrorsTKey .
Public methodSubscribe
Register an IObserver for AFDataPipeEvent with the PIDataPipe. All the AFDataPipeEvents received by the data pipe will be sent to the IObserver.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)

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 only available in the .NET 4 version of the SDK.

// 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

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

    // 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);

        // Wait one second
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);
Version Information


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