AFPort Class
- Last UpdatedNov 18, 2025
- 6 minute read
- PI System
- AF SDK 2024 R2
- Developer
The AFPort defines how connections can be made between
AFBaseElement objects in a model.

Inheritance Hierarchy
Namespace: OSIsoft.AF.Modeling
Assembly: OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.1.1.1182
Syntax
[SerializableAttribute] public sealed class AFPort : AFObject, IComparable<AFPort>
<SerializableAttribute> Public NotInheritable Class AFPort Inherits AFObject Implements IComparable(Of AFPort) Dim instance As AFPort
[SerializableAttribute] public ref class AFPort sealed : public AFObject, IComparable<AFPort^>
[<SealedAttribute>] [<SerializableAttribute>] type AFPort = class inherit AFObject interface IComparable<AFPort> end
The AFPort type exposes the following members.
Properties
| Name | Description | |
|---|---|---|
| AllowedElementCategories |
This collection contains the list of element categories for elements which are allowed
to connect to this port.
| |
| AllowedElementTemplate |
This property is the AFElementTemplate of the elements that are allowed to
connect to this port.
| |
| AllowedElementTypes |
This property is a bitwise combination of the types of elements which are allowed
to connect to this port.
| |
| Database |
This read-only property returns the AFDatabase where this object is defined.
| |
| Description |
Read/write property that provides a more detailed description of the object.
| |
| Element |
This property returns the AFBaseElement object which owns or references this port.
| |
| ElementTemplate |
This read-only property returns the AFElementTemplate which owns this port.
| |
| 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.) | |
| IsDeleted |
This read-only property indicates whether the object has been deleted.
(Inherited from AFObject.) | |
| MaxConnections |
This property specifies the maximum number of connections allowed for this port.
| |
| Name |
This property defines the name that identifies the object.
| |
| PISystem |
This read-only property allows access to the PISystem associated with this
object.
(Inherited from AFObject.) | |
| Type |
This property specifies the direction of the connection from this port.
| |
| UniqueID |
Read-only property that provides the object's ID as a String.
(Inherited from AFObject.) |
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.) | |
| 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.) | |
| 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.) | |
| 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.) | |
| GetType | Gets the Type of the current instance. (Inherited from Object.) | |
| Persist |
This method returns the persistence string for the object.
(Inherited from AFObject.) | |
| ToString |
Returns a String that represents the current object.
(Overrides AFObjectToString.) | |
| ToString(AFModel) |
Formats the port name relative to the specified model.
|
Remarks
The AFPort provides rules based upon its
AllowedElementTemplate and AllowedElementCategories
properties which restrict which elements are allowed to connect to an element
through the port.
Examples
// This example demonstrates how to add a port and set its properties. // Get the Database PISystems myPISystems = new PISystems(); AFDatabase myDB = myPISystems.DefaultPISystem.Databases.DefaultDatabase; // Create Receipt Truck Template AFElementTemplate RecTruckTempl = myDB.ElementTemplates.Add("MyReceiptTruck"); RecTruckTempl.Description = "Receipt Truck Element Template"; // Create a Port AFPort RecTruckPort = RecTruckTempl.Ports.Add("Rec"); RecTruckPort.Description = "Receipt Port"; RecTruckPort.Type = AFPortType.Output; RecTruckPort.MaxConnections = 5; RecTruckTempl.DefaultOutputPort = RecTruckPort; // Display the name and description of the Port Console.WriteLine("Port Name = {0}", RecTruckPort.Name); Console.WriteLine("Description = {0}", RecTruckPort.Description);
' This example demonstrates how to add a port and set its properties. ' Get the Database Dim myPISystems As New PISystems Dim myDB As AFDatabase = myPISystems.DefaultPISystem.Databases.DefaultDatabase ' Create Receipt Truck Template Dim RecTruckTempl As AFElementTemplate = myDB.ElementTemplates.Add("MyReceiptTruck") RecTruckTempl.Description = "Receipt Truck Element Template" ' Create a Port Dim RecTruckPort As AFPort = RecTruckTempl.Ports.Add("Rec") RecTruckPort.Description = "Receipt Port" RecTruckPort.Type = AFPortType.Output RecTruckPort.MaxConnections = 5 RecTruckTempl.DefaultOutputPort = RecTruckPort ' Display the name and description of the Port Console.WriteLine("Port Name = {0}", RecTruckPort.Name) Console.WriteLine("Description = {0}", RecTruckPort.Description)
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.