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

AF SDK Reference

PIServers Class

  • Last UpdatedNov 18, 2025
  • 11 minute read
PIServers Class
The global collection of PIServer objects that represents the known PI Data Archive servers available from a workstation for client applications.

Inheritance Hierarchy

SystemObject
  OSIsoft.AF.PIPIServers

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

Syntax

public sealed class PIServers : IList<PIServer>, 
	ICollection<PIServer>, IEnumerable<PIServer>, IEnumerable, 
	IAFList, IList, ICollection, IAFChangedEvent
Public NotInheritable Class PIServers
	Implements IList(Of PIServer), ICollection(Of PIServer), 
	IEnumerable(Of PIServer), IEnumerable, IAFList, IList, 
	ICollection, IAFChangedEvent

Dim instance As PIServers
public ref class PIServers sealed : IList<PIServer^>, 
	ICollection<PIServer^>, IEnumerable<PIServer^>, IEnumerable, 
	IAFList, IList, ICollection, IAFChangedEvent
[<SealedAttribute>]
type PIServers =  
    class
        interface IList<PIServer>
        interface ICollection<PIServer>
        interface IEnumerable<PIServer>
        interface IEnumerable
        interface IAFList
        interface IList
        interface ICollection
        interface IAFChangedEvent
    end

The PIServers type exposes the following members.

Constructors

  NameDescription
Public method
PIServers
Initializes a new instance of the PIServers collection.

Properties

  NameDescription
Public propertyStatic member
AuthenticationOptions
The authentication options used when making a connection to a PIServer.
Public property
Count
Gets the number of items actually contained in the collection.
Public property
DefaultPIServer
The default PIServer configured for the current client machine.
Public propertyStatic member
DirectoryOptions
The directory options used when looking up a PIServer in the collection.
Public property
Identity
This read-only property contains identity of the object.
Public property
ItemGuid
Gets the item with the specified id.
Public property
ItemInt32
Gets or sets the item at the specified index.
Public property
ItemString
Returns the specified object from the collection by name.

Methods

  NameDescription
Public method
Add
Registers a new PIServer to the list of known servers on the local machine.
Public method
Clear
Unregisters all existing PIServer entries from the list of known PI Data Archive servers on the local machine.
Public method
Contains(Guid)
This method determines whether the collection contains a specific item referenced by id.
Public method
Contains(String)
This method determines whether the collection contains a specific item referenced by name.
Public method
Contains(PIServer)
This method determines whether the collection contains a specific item.
Public method
CopyTo
Copies the entire collection to a compatible one-dimensional Array, starting at the specified index of the target array.
Public method
DisconnectAll
Disconnects all PIServers that are currently connected.
Public method
Equals
Determines whether the specified Object is equal to the current object.
(Overrides ObjectEquals(Object).)
Public method
GetBufferStatus
This method gets the PIBufferStatus of the PI Buffer Subsystem.
Public method
GetEnumerator
Returns an enumerator that iterates through the collection.
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.
(Overrides ObjectGetHashCode.)
Public methodStatic member
GetPIServers(PISystem)
Get the list of known PIServers on the local machine.
Public methodStatic member
GetPIServers(ClaimsIdentity, Boolean)
Get the list of known PIServers on the local machine.
Public methodStatic member
GetPIServers(String, String, Boolean)
Get the list of known PIServers on the local machine.
Public method
GetType
Gets the Type of the current instance.
(Inherited from Object.)
Public method
IndexOf
Searches for the specified object and returns the zero-based index of the first occurrence within the entire collection.
Public method
Refresh
Refresh the list of known PI Data Archive servers on the local machine, where the cached collections of connected servers will be refreshed.
Public method
Refresh(Boolean)
Refresh the list of known PI Data Archive servers on the local machine with the option to refresh cached collections for connected servers.
Public method
Remove(Guid)
Unregisters an existing PIServer with the specified unique identifier.
Public method
Remove(String)
Unregisters an existing PIServer with the specified name.
Public method
Remove(PIServer)
Unregisters the specified PIServer.
Public method
RemoveAt
Unregisters an existing PIServer by removing the entry from the list of known PI Data Archive servers on the local machine.
Public method
Sort
Sorts the items in the entire collection using the default comparer.
Public method
Sort(IComparerPIServer)
Sorts the items in the entire collection using the specified comparer.
Public method
Sort(Int32, Int32, IComparerPIServer)
Sorts the items in a range of items in the collection using the specified comparer.
Public method
ToString
Returns a String that represents the current object.
(Overrides ObjectToString.)

Events

  NameDescription
Public eventCode example
Changed
Event is raised when the object or one of its sub-objects is changed.
Public eventCode example
ConnectFailed
Occurs when the connection to a PIServer fails and not performing an auto prompt.

Operators

  NameDescription
Public operatorStatic member
Equality
The equality operator (==) compares its operands to determine if they are equal.
Public operatorStatic member
Inequality
The inequality operator (!=) compares its operands to determine if they are not equal.

Extension Methods

  NameDescription
Public Extension Method
AggregatePIServer
Performs all requested aggregates on the specified items.
(Defined by AFAggregate.)
Public Extension Method
AggregateAsyncPIServer
Performs all requested aggregates on the specified items asynchronously.
(Defined by AFAggregate.)
Public Extension Method
BinnedSummaryPIServer, TBin
Generates a summary broken down by the specified bins for items matching the search criteria.
(Defined by AFAggregate.)
Public Extension Method
BinnedSummaryAsyncPIServer, TBin
Generates a summary broken down by the specified bins for items matching the search criteria asynchronously.
(Defined by AFAggregate.)
Public Extension MethodCode example
ChunkedByPIServer
This extension method breaks up search results into chunks to make it easier to page through and process IEnumerableT collections in chunks.
(Defined by AFSDKExtension.)
Public Extension Method
FrequencyDistributionPIServer
Generates a frequency distribution for the specified items.
(Defined by AFAggregate.)
Public Extension Method
FrequencyDistributionAsyncPIServer
Generates a frequency distribution for the specified items asynchronously.
(Defined by AFAggregate.)
Public Extension Method
GroupedSummaryPIServer
Generates a summary broken down by group for the specified items.
(Defined by AFAggregate.)
Public Extension Method
GroupedSummaryAsyncPIServer
Generates a histogram for the specified items asynchronously.
(Defined by AFAggregate.)
Public Extension Method
HistogramPIServer, TBin
Generates a histogram for the specified items with the specified weighting.
(Defined by AFAggregate.)
Public Extension Method
HistogramAsyncPIServer, TBin
Generates a histogram for the specified items with the specified weighting asynchronously.
(Defined by AFAggregate.)
Public Extension Method
SummaryPIServer(String, AFSummaryTypes)Overloaded.
Summarizes the specified items.
(Defined by AFAggregate.)
Public Extension Method
SummaryPIServer(String, AFSummaryTypes, String)Overloaded.
Summarizes the specified items with the specified weighting.
(Defined by AFAggregate.)
Public Extension Method
SummaryAsyncPIServer(String, AFSummaryTypes, CancellationToken)Overloaded.
Summarizes the specified items asynchronously.
(Defined by AFAggregate.)
Public Extension Method
SummaryAsyncPIServer(String, AFSummaryTypes, String, CancellationToken)Overloaded.
Summarizes the specified items with the specified weighting asynchronously.
(Defined by AFAggregate.)

Remarks

This is the list of known PIServers on the workstation for client applications. This list of PIServers can be manipulated with the methods of this object. For example, the Add(String) method is used to add a PIServer to this workstation. This allows the client to connect to an existing PIServer that was previously installed on the network. The DirectoryOptions controls the behavior when looking up items in the collection.

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

Examples

PIServers myPIServers = new PIServers();

// Display information for Default PIServer
PIConnectionInfo myConnectionInfo = myPIServers.DefaultPIServer.ConnectionInfo;
Console.WriteLine("Name of Default PIServer = {0}", myPIServers.DefaultPIServer.Name);
Console.WriteLine("Host used to connect to Default PIServer = {0}", myConnectionInfo.Host);
Console.WriteLine("Port used to connect to Default PIServer = {0}", myConnectionInfo.Port);
Console.WriteLine();

// Display the number of PIServers
Console.WriteLine("PIServer count = {0}", myPIServers.Count);

// Display PIServer information
foreach (PIServer server in myPIServers)
{
    Console.WriteLine("   Name of PIServer = {0}", server.Name);
    if (server.UniqueID != "")
        Console.WriteLine("   UniqueID of PIServer = {0}", server.UniqueID);
    else
        Console.WriteLine("   UniqueID of PIServer = n/a");
    if (server.ServerVersion != "")
        Console.WriteLine("   Version of PIServer = {0}", server.ServerVersion);
    else
        Console.WriteLine("   Version of PIServer = n/a");
    Console.WriteLine();
}

// Get the PIServer on the specified computer
PIServer myPIServer = PIServer.FindPIServer(piServerName);

// Display information about the PIServer
Console.WriteLine("Name of the local PIServer = {0}", myPIServer.Name);
Console.WriteLine("ID of the PIServer = {0}", myPIServer.ID);
Console.WriteLine("PIServer Current Time = {0}", myPIServer.ServerTime);
Console.WriteLine("PIServer TimeZone = {0}", myPIServer.ServerTimeZone);
Console.WriteLine();

// Remove PIServer if it exists
if (myPIServers["NewPIServer"] != null)
{
    myPIServers.Remove("NewPIServer");
}

// Add a new PIServer without validating host address
PIServers.DirectoryOptions = PISystems.AFDirectoryOptions.None;
PIServer newPIServer = myPIServers.Add("NewPIServer");
newPIServer.ConnectionInfo.Host = "NewHostAddress";
Dim myPIServers As New PIServers()

' Display information for Default PIServer
Dim myConnectionInfo As PIConnectionInfo = myPIServers.DefaultPIServer.ConnectionInfo
Console.WriteLine("Name of Default PIServer = {0}", myPIServers.DefaultPIServer.Name)
Console.WriteLine("Host used to connect to Default PIServer = {0}", myConnectionInfo.Host)
Console.WriteLine("Port used to connect to Default PIServer = {0}", myConnectionInfo.Port)
Console.WriteLine()

' Display the number of PIServers
Console.WriteLine("PIServer count = {0}", myPIServers.Count)

' Display PIServer information
For Each server As PIServer In myPIServers
    Console.WriteLine("   Name of PIServer = {0}", server.Name)
    If server.UniqueID <> "" Then
        Console.WriteLine("   UniqueID of PIServer = {0}", server.UniqueID)
    Else
        Console.WriteLine("   UniqueID of PIServer = n/a")
    End If
    If server.ServerVersion <> "" Then
        Console.WriteLine("   Version of PIServer = {0}", server.ServerVersion)
    Else
        Console.WriteLine("   Version of PIServer = n/a")
    End If
    Console.WriteLine()
Next

' Get the PIServer on the specified computer
Dim myPIServer As PIServer = PIServer.FindPIServer(piServerName)

' Display information about the PIServer
Console.WriteLine("Name of the local PIServer = {0}", myPIServer.Name)
Console.WriteLine("ID of the PIServer = {0}", myPIServer.ID)
Console.WriteLine("PIServer Current Time = {0}", myPIServer.ServerTime)
Console.WriteLine("PIServer TimeZone = {0}", myPIServer.ServerTimeZone)
Console.WriteLine()

' Remove PIServer if it exists
If myPIServers("NewPIServer") IsNot Nothing Then
    myPIServers.Remove("NewPIServer")
End If

' Add a new PIServer without validating host address
PIServers.DirectoryOptions = PISystems.AFDirectoryOptions.None
Dim newPIServer As PIServer = myPIServers.Add("NewPIServer")
newPIServer.ConnectionInfo.Host = "NewHostAddress"

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