主要内容

setInterface

R2026b

Assign port interface to AUTOSAR component, composition, or architecture port

Description

setInterface(port,interface) assigns the port interface specified by interface to the AUTOSAR component, composition, or architecture port specified by port. Use this function to associate a sender-receiver or client-server interface from a Simulink® data dictionary with a component, composition, or architecture port.

example

setInterface(port,[]) clears the interface assigned to the port specified by port.

Examples

collapse all

This example shows how to create a Simulink.dictionary.archdata.DataInterface object in a linked data dictionary and assign it to a component port in an AUTOSAR architecture model.

Create an architecture model, add a component, add a receiver port, and then populate the component with a Simulink behavior model.

arch = autosar.arch.createModel("Architecture");
comp = addComponent(arch,"MySWC");
addPort(comp,"Receiver","SensorInput");
createModel(comp,"autosar_component");

Create a Simulink.dictionary.archdata.DataInterface object in a linked data dictionary and add a data element to the interface.

dictName = "dictionary.sldd";
archdata = Simulink.dictionary.archdata.open(dictName);
dataIf = addDataInterface(archdata,"SensorInterface");
addElement(dataIf,"SensorValue");

Link the data dictionary to the architecture model, and assign the interface to the receiver port.

linkDictionary(arch,"dictionary.sldd");
port = comp.Ports(1);
setInterface(port,dataIf);

Verify the interface assignment by querying the Interface property of the port.

port.Interface
ans = 
  DataInterface with properties:

           Name: 'SensorInterface'
    Description: ''
       Elements: [1×1 Simulink.dictionary.archdata.DataElement]
          Owner: [1×1 Simulink.dictionary.ArchitecturalData]

Input Arguments

collapse all

AUTOSAR component, composition, or architecture port, specified as an autosar.arch.CompPort or autosar.arch.ArchPort object.

Port interface to assign to the port, specified as a Simulink.dictionary.archdata.DataInterface object or Simulink.dictionary.archdata.ServiceInterface object. Create interfaces by using the addInterface function on a Simulink.dictionary.ArchitecturalData object.

To remove an existing interface assignment from a port, specify [].

Version History

Introduced in R2021a