SysML v2 Deep Dive 4 min read

Lesson 8: Ports, Conjugation & Interfaces

In SysML v1, modeling interfaces was often a struggle. You had to choose between "Proxy Ports" (typed by Interface Blocks) and "Full Ports" (typed by regular Blocks), and manually manage "Flow Properties" and directions across deep hierarchies.

In SysML v2, ports and interfaces follow the general Definition-Usage Pattern used throughout the language. We use port def to define the blueprint of the endpoint, port for its actual usage, and interface def to define the connection protocol between them. Crucially, we introduce Conjugation (~), which allows us to define a Port once and mathematically "flip" the directions of the interactions features in that Port. Features with direction in become out and vice versa, and features with direction inout or no direction remain unchanged.

The Concepts: Endpoint vs. Connection Type

To model a precise connection, you need to define two distinct concepts :

  1. port def (The Endpoint): Defines the "shape" of the pin or socket. It specifies interaction features—the capacity to receive (in) or send (out) items, data, or energy.
  2. interface def (The Connection Protocol): This is the Type (the blueprint) of the connection. It defines the structure of the "wire" or protocol that connects two ports. It is not the physical connection itself; it is the definition of what a valid connection looks like.

Defining Ports and Using Conjugation

Notice the use of the tilde (~). We define the FuelingPort once. The Tank uses it as defined, while the Nozzle uses it "conjugated" (~).

Textual code:

package InterfaceDefinitions {
    import ISQ::*; // Standard Quantities Library
    
    item def Fuel;

    // 1. The Port Definition (The Endpoint)
    // Defines the fueling port with directed features (Capacity to exchange)
    port def FuelingPort {
        in item fuel : Fuel; 
        out attribute vaporPressure : Pressure;
    }

    // 2. The Interface Definition (The Connection Protocol)
    // This defines the TYPE of connection allowed.
    // It specifies that any connection of this type must link a standard port 
    // to a conjugated port.
    interface def RefuelingProtocol {
        end tankPort : FuelingPort;
        end nozzlePort : ~FuelingPort;
    }

    // 3. The Component (The Socket side)
    part def FuelTank {
        // The tank receives fuel (in)
        port fillerCap : FuelingPort;
    }
    
    part fuelTank: FuelTank;

    // 4. The Opposing Component (The Plug side)
    part def RefuelingNozzle {
        // The nozzle emits fuel. The '~' reverses the direction 
        // of the interaction features defined in FuelingPort.
        port nozzle : ~FuelingPort;
    }
    
    part refuelingNozzle: RefuelingNozzle;
    
    interface refuelingProtocol: RefuelingProtocol
        connect fuelTank.fillerCap to refuelingNozzle.nozzle;
}

Graphical Notation:

Lesson 8

Understanding the Graphical Notation: When rendered in an Interconnection View, ports are displayed as small squares on the boundary of their owning parts—very similar to SysML v1 Internal Block Diagrams (IBDs). The solid line between them represents the connect statement. The connection is perfectly valid without ever needing to define a completely separate FuelingPort block.


Deep Dive: Semantics of Interaction

  1. Interaction Features (Not just "Flow"): In port def FuelingPort, the line in item fuel does not mean fuel is constantly flowing. It defines an interaction feature—specifically, the capacity of that port to accept fuel objects. The actual flow is a dynamic performance modeled later.
  2. Conjugation Precision (~): The tilde (~) operator does not reverse everything; it specifically reverses the direction of interaction features.
    • in item becomes out item.
    • out attribute becomes in attribute.
    • This ensures the Nozzle (Provider) and Tank (Consumer) are mathematically compatible without creating a duplicate "Mirror" part def or port def.
  3. Interface Def vs. Interface Usage: It is critical to distinguish the Definition from the Usage.
    • interface def is the Protocol (e.g., USB-C Spec).
    • interface usage (or connector) is the Cable (e.g., the specific cable on my desk). You will learn more about connection usages (or the connect keyword) in later lessons.

💡 V1 vs. V2 Cheat Sheet

SysML v1SysML v2
«InterfaceBlock»port def
«ProxyPort»port (typed by a port def)
Flow Property (direction=in)in item (or in directed feature)
Association / Association Blockconnection def / interface def
isConjugated=true~ (conjugation operator)

Next Lesson

We will look at Connections. Now that we have the Ports (endpoints) and the Interface Definition (protocol), we will dive deeper into how to wire them together to establish complex system topologies using connect.

SysML v2

SysModeler Team

Engineering & Product