Main Content

linkToModel

Link AUTOSAR architecture component or composition to Simulink implementation model

Since R2020a

Description

example

linkToModel(component,modelName) links the specified AUTOSAR architecture component to existing Simulink® implementation model modelName. The component inherits the interface of the linked implementation model. The component argument is a component handle returned by a previous call to addComponent.

example

linkToModel(composition,modelName) links the specified AUTOSAR architecture composition to an existing Simulink implementation model modelName. The composition argument is a composition handle returned by a previous call to addComposition.

Examples

collapse all

In an architecture model, link an AUTOSAR component to a Simulink® implementation model. The component inherits the interface of the linked implementation model.

Create an AUTOSAR architecture model and add a component.

modelName = "myArchModel";
archModel = autosar.arch.createModel(modelName);
component = addComponent(archModel,"SWC1");

Load the example model autosar_swc, and programmatically set the XML Options Source property to Inherit.

load_system("autosar_swc_controller_bus");
arProps = autosar.api.getAUTOSARProperties("autosar_swc_controller_bus");
set(arProps,"XmlOptions","XmlOptionsSource","Inherit");

Link the architecture model to the Simulink implementation model, inheriting the implementation model's interface.

linkToModel(component,"autosar_swc_controller_bus")

If the implementation model is linked to a data dictionary you need to set the XML Options Source property using the dictionary AUTOSAR properties.

modelName = "newArchModel";
archModel = autosar.arch.createModel(modelName);
component = addComponent(archModel,"SWC2");

Load the example model autosar_tpc_controller, which is linked to the data dictionary tpc_interfaces.sldd.

load_system("autosar_tpc_controller.slx");

Using the data dictionary AUTOSAR properties object, sect the XML Options Source property to Inherit.

dictProps = autosar.api.getAUTOSARProperties("tpc_interfaces.sldd");
set(dictProps,"XmlOptions","XmlOptionsSource","Inherit");

Now link the architecture model to the Simulink implementation model, inheriting the implementation model's interface.

linkToModel(component,"autosar_tpc_controller")

To save your changes use the saveChanges function. For this example close connections to tpc_interfaces.sldd and discard the unsaved change.

Simulink.data.dictionary.closeAll("tpc_interfaces.sldd","-discard")

In an architecture model, link an AUTOSAR composition to a Simulink implementation model.

Create AUTOSAR architecture model and add a composition inside the architecture model.

modelName = 'myArchModel';
archModel = autosar.arch.createModel(modelName);
composition = addComposition(archModel,'Referenced_Sensors');

Open the 'autosar_tpc_composition' model and link it to the composition, Referenced_Sensors, in the Simulink implementation model, archModel.

openExample('autosar_tpc_composition');
linkToModel(composition, 'autosar_tpc_composition');

Input Arguments

collapse all

AUTOSAR architecture component to link to the specified Simulink implementation model. The argument is a component handle returned by a previous call to addComponent.

Example: component

AUTOSAR architecture composition to link to the specified Simulink implementation model. The argument is a composition handle returned by a previous call to addComposition.

Example: composition

Name of the Simulink implementation model to create, based on the specified AUTOSAR architecture component or composition. If not specified, modelName defaults to the name of the component or composition.

Example: 'SWC1'

Version History

Introduced in R2020a