Main Content

createModel

Create AUTOSAR architecture model for composition or Simulink behavior model for component

Description

createModel(component,modelName) creates Simulink® behavior model modelName and links the Component block to the behavior model. By default, the behavior of the model is based on the interface of the specified AUTOSAR component. The component argument is a component handle returned by a previous call to addComponent. If not specified, modelName defaults to the name of the AUTOSAR component.

example

createModel(component,modelName,BehaviorType=behavior) creates Simulink behavior model modelName with the modeling style specified by behavior and links the Component block to the behavior model. The component argument is a component handle returned by a previous call to addComponent. If not specified, modelName defaults to the name of the component.

example

createModel(composition,modelName) creates an AUTOSAR architecture model modelName with the same interface as the specified AUTOSAR composition. The composition argument is a composition handle returned by a previous call to addComposition. If not specified, modelName defaults to the name of the AUTOSAR component or composition.

example

Examples

collapse all

For a Composition block in an AUTOSAR architecture model, create and link an AUTOSAR architecture model with a matching interface. By default, the new AUTOSAR architecture model has the same name as the composition.

Create AUTOSAR architecture model.

modelName = "myArchModel";
archModel = autosar.arch.createModel(modelName);

Add a Composition block inside the architecture model.

composition = addComposition(archModel,"Sensors");
addPort(composition,"Sender",{"PPort1","PPort2"});

Add a Component block inside the Composition block.

component = addComponent(composition,"SWC1");
addPort(component,"Sender",{"PPort1","PPort2"});

Create and link a matching AUTOSAR architecture model for Composition block Sensors that contains Component block SWC1.

createModel(composition);

For an AUTOSAR component in an architecture model, create a Simulink behavior model with a matching interface. The function call links the component to the behavior model. By default, the behavior model has the same name as the component and uses a rate-based modeling style, meaning that is has explicitly scheduled rates. For more information about creating rate-based models, see Create Rate-Based Model.

Create AUTOSAR architecture model.

modelName = "myNewArchModel";
archModel = autosar.arch.createModel(modelName);

Add a Component block inside the architecture model.

component = addComponent(archModel,"SWC1");
addPort(component,"Sender",{"PPort1","PPort2"});

Create and link a matching Simulink behavior model.

createModel(component,BehaviorType="RateBased");

Input Arguments

collapse all

AUTOSAR component from which to create a matching Simulink behavior model, specified as a handle returned by a previous call to addComponent.

Example: component

AUTOSAR composition from which to create a matching AUTOSAR architecture model, specified as a handle returned by a previous call to addComposition.

Example: composition

Name of Simulink behavior model or AUTOSAR architecture model, specified as a character vector or string scalar. If not specified, modelName defaults to the name of the component or composition.

Example: "SWC1"

Component behavior, specified as one of these values:

  • "RateBased" — The software creates a model that uses a rate-based modeling style, meaning it has explicitly scheduled rates. For more information about creating rate-based models, see Create Rate-Based Model.

  • "ExportFunction" — The software creates a model that uses an export-function modeling style. For more information about export-function models, see Export-Function Models Overview

If not specified, the behavior of the model is based on the interface of the specified AUTOSAR component.

Example: createModel(component,"Component",BehaviorType="ExportFunction")

Data Types: char | string

Tips

  • You can extract compositions from architecture models, and components from compositions programmatically.

    For example, for example model autosar_tpc_composition you can extract the composition from the architecture model by running these commands in the MATLAB® Command Window.

    openExample("autosar_tpc_composition");
    archModel = autosar.arch.loadModel("autosar_tpc_composition.slx");
    sensorComposition = archModel.Compositions(1)
    sensorComposition = 
    
      Composition with properties:
    
                  Name: 'Sensors'
        SimulinkHandle: 238.0005
                Parent: [1×1 autosar.arch.Model]
            Components: [4×1 autosar.arch.Component]
          Compositions: [0×0 autosar.arch.Composition]
                 Ports: [5×1 autosar.arch.CompPort]
            Connectors: [7×1 autosar.arch.Connector]
              Adapters: [0×0 autosar.arch.Adapter]

    You can also extract a component from a composition by running this command in the MATLAB Command Window.

    component = sensorComposition.Components(1)
    component = 
    
      Component with properties:
    
                  Name: 'Monitor'
        SimulinkHandle: 819.0001
                Parent: [1×1 autosar.arch.Model]
                  Kind: 'Application'
                 Ports: [3×1 autosar.arch.CompPort]
         ReferenceName: 'autosar_tpc_throttle_sensor_monitor'

Version History

Introduced in R2020a