主要内容

autosar.arch.CompPort

R2026b

AUTOSAR component or composition port in architecture model

    Description

    An autosar.arch.CompPort object represents a port on an AUTOSAR software component or composition in an AUTOSAR software architecture model. Use this object to query port properties and assign interfaces to ports.

    Creation

    Create an autosar.arch.CompPort object by using the addPort function to add a port to an autosar.arch.Component or autosar.arch.Composition object.

    port = addPort(comp,"Receiver","RecvPort")
    ports = addPort(comp,"Sender",{"SndPort1","SndPort2"})
    port =
    
      CompPort with properties:
    
                  Name: 'RecvPort'
             Interface: []
                  Kind: 'Receiver'
             Connected: 0
                Parent: [1×1 autosar.arch.Component]
        SimulinkHandle: 7.0001
    Ports are also returned by the find function or by accessing the Ports property of a component or composition.

    Properties

    expand all

    Name of port, specified as a character vector or string scalar.

    Data Types: char | string

    This property is read-only.

    Port interface assigned to this port, represented as a Simulink.dictionary.archdata.PortInterface object. To assign an interface to a port, use the setInterface function. When no interface is assigned, this property is empty.

    This property is read-only.

    Direction and communication pattern of the port, represented as "Receiver", "Sender", "Client", or "Server". This property is set when you specify the portKind argument when creating the port by using the addPort function. For models configured for the AUTOSAR Classic Platform, valid values are "Receiver" and "Sender". For models configured for the AUTOSAR Adaptive Platform, all four values are valid.

    Data Types: char

    This property is read-only.

    Whether port is connected to another port, represented as a logical value. A value of 1 (true) indicates the port is connected to another port through a connector. A value of 0 (false) indicates the port is not connected.

    Data Types: logical

    This property is read-only.

    Component or composition that owns the port, represented as an autosar.arch.Component or autosar.arch.Composition object.

    This property is read-only.

    Simulink block handle, represented as a double.

    Data Types: double

    Object Functions

    setInterfaceAssign port interface to AUTOSAR component, composition, or architecture port
    getArchPortGet architecture port corresponding to component or composition port
    destroyRemove and delete AUTOSAR architecture element

    Examples

    collapse all

    Add sender and receiver ports to a component and query port properties.

    Create an architecture model and add a component.

    archModel = autosar.arch.createModel("MyArchModel");
    comp = addComponent(archModel,"ControlSWC");

    Add sender and receiver ports to the component.

    rcvPort = addPort(comp,"Receiver","SensorInput");
    sndPort = addPort(comp,"Sender","ActuatorCmd");

    Query port properties.

    rcvPort.Kind
    rcvPort.Connected
    ans =
    
        'Receiver'
    
    ans =
    
      logical
    
       0

    Assign a sender-receiver interface from an architecture data dictionary to a component port.

    Create an architecture model, add a component, and add a receiver port.

    archModel = autosar.arch.createModel("InterfaceExample");
    comp = addComponent(archModel,"MySWC");
    rcvPort = addPort(comp,"Receiver","SensorInput");

    Create a sender-receiver interface in an architecture data dictionary.

    dictName = "MyDictionary";
    archDict = Simulink.dictionary.archdata.open(dictName);
    srInterface = addInterface(archDict,"SensorInterface","SenderReceiverInterface");

    Assign the interface to the port using the setInterface function.

    setInterface(rcvPort,srInterface);

    Verify the interface assignment.

    rcvPort.Interface
    ans =
    
      SenderReceiverInterface with properties:
    
                Name: 'SensorInterface'
        DataElements: [0x0 archdata.DataElement]

    Version History

    Introduced in R2021a