AFConnections.Add Method (AFPort, AFPort)
- Last UpdatedNov 18, 2025
- 2 minute read
- PI System
- AF SDK 2024 R2
- Developer
The Add method creates a new connection between ports of two elements in
the model.
Namespace: OSIsoft.AF.Modeling
Assembly: OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.1.1.1182
Syntax
public AFConnection Add( AFPort sourcePort, AFPort destinationPort )
Public Function Add ( sourcePort As AFPort, destinationPort As AFPort ) As AFConnection Dim instance As AFConnections Dim sourcePort As AFPort Dim destinationPort As AFPort Dim returnValue As AFConnection returnValue = instance.Add(sourcePort, destinationPort)
public: AFConnection^ Add( AFPort^ sourcePort, AFPort^ destinationPort )
member Add : sourcePort : AFPort * destinationPort : AFPort -> AFConnection
Parameters
- sourcePort
- Type: OSIsoft.AF.ModelingAFPort
The source AFPort object of the connection. The port type must be either Output or Undirected. - destinationPort
- Type: OSIsoft.AF.ModelingAFPort
The destination AFPort object of the connection. The port type must be either Input or Undirected.
Return Value
Type: AFConnectionReturns the newly created object that was added.
Exceptions
| Exception | Condition |
|---|---|
| InvalidOperationException | Thrown if the connection between the specified sourcePort and destinationPort is not valid. |
Remarks
The two elements being connected must already be defined for the model. The
direction of connection is determined by the order of the parameters and the
port types being connected. See documentation about AFPortType
for more information. The rules for allowed connections is controlled by the
definition of the AFPort objects being connected. If you want
to connect the default ports of two elements, it is convenient to use the
AFBaseElement.DefaultInputPort,
AFBaseElement.DefaultOutputPort, or
AFBaseElement.DefaultUndirectedPort
properties.