Main Content

Define AUTOSAR Component Behavior by Creating or Linking Models

After you add and connect Software Component and Software Composition blocks in an AUTOSAR architecture model, add Simulink® behavior to the components. For each AUTOSAR Software Component block, you can:

  • Create a model based on the block interface.

  • Link to an implementation model.

  • Create a model from an AUTOSAR XML (ARXML) component description.

To initiate these actions, select a Software Component block, place your cursor over the displayed ellipsis, and select a component model cue — Create Model, Link to Model, or Create Component Model from ARXML.

The selections open dialog boxes that help you create or link a model that defines the Simulink behavior of the component.

The creation and linking actions can be initiated in other ways, for example, from an architecture block context menu or from the toolstrip Modeling tab.

After you associate an implementation model with an AUTOSAR component, if you have Embedded Coder® software, you can use component block cues or right-click options to generate code and export ARXML files. The ARXML export uses the XML options of the parent architecture model.

When the components in an architecture model have defined behavior, you can simulate the behavior of the aggregated components. See Configure AUTOSAR Scheduling and Simulation.

Create Model Based on Block Interface

To create a stub implementation model and map it to an AUTOSAR software component, use the Software Component block cue Create Model.

Clicking the cue creates a model based on the interface of the authored component. Ports that you created on the Software Component block are present in the implementation model.

  1. Create or open an architecture model. To create a model, open the Simulink Start Page. Under AUTOSAR Blockset, open the Software Architecture template.

  2. From the Modeling tab or the palette, add a Software Component block to the model and name it Controller. The Property Inspector displays the component Kind property as Application, which is correct for this component.

  3. Click the block edges to add require (input) ports named APP_Percent and TPS_Percent and a provide (output) port named ThrCmd_Percent. (For a controller component with the same naming, see the example Author AUTOSAR Compositions and Components in Architecture Model.)

  4. Select the Controller block, place your cursor over the displayed ellipsis, and select cue Create Model. A model creation dialog box opens.

    1. Enter a name for the new model or accept the block name default.

    2. Select a custom Simulink template for the new model or accept the default, a blank template. For more information about creating your own Simulink templates, see Create Template from Model.

    To create a stub implementation model and map it to the AUTOSAR Controller component, click OK.

  5. Model Controller.slx is created in the working folder. To view the initial model content, open the Controller block. The ports are stubbed with Ground and Terminator blocks so that the model can immediately be updated and simulated.

  6. In the open Controller model, to view the model mapping and dictionary, open the AUTOSAR Component Designer app. This view shows the mapping and properties of the model port APP_Percent.Value. The model port maps to AUTOSAR component port APP_Percent.

  7. After creating the stub model representation of the AUTOSAR component, use Simulink tools to develop the component implementation. You refine the AUTOSAR configuration and create algorithmic model content. For an example Controller block implementation, see the model autosar_tpc_controller provided with example Author AUTOSAR Compositions and Components in Architecture Model.

Link to Implementation Model

To reference an existing Simulink implementation model from an AUTOSAR software component, use the Software Component block cue Link to Model. Clicking the cue initiates linking of the component block to an implementation model that you specify. By linking to existing models, you can deploy verified implementation models in your AUTOSAR design without requalification.

The implementation model must meet model linking requirements. The model must:

  • Use the same AUTOSAR target as the architecture model.

  • Have a complete mapping of Simulink model elements to AUTOSAR component elements.

  • Implement root-level ports with In Bus Element and Out Bus Element blocks instead of Inport and Outport blocks.

  • Use a fixed-step solver.

  • Map to an AUTOSAR software component that is not already mapped to a different model in the composition hierarchy.

If the specified implementation model meets the linking requirements, the software links the component block to the model and updates the block and model interfaces to match.

If the implementation model does not meet one or more of the linking requirements, the software opens the AUTOSAR Model Linker app, which offers fixes for the unmet requirements. For example, if an implementation model uses root Inport and Outport blocks, the app offers to fix the issue by converting the signal ports to bus ports. When you click Fix All, the software fixes the unmet requirements and finishes linking the component block to the model.

To link an AUTOSAR software component to an existing Simulink implementation model:

  1. Create or open an architecture model. To create a model, open the Simulink Start Page. Under AUTOSAR Blockset, open the Software Architecture template.

  2. For the purposes of this example, link the Component2 block to an implementation model that is not already configured for architecture model use. For example, select a model that is not configured for AUTOSAR or uses signal ports instead of bus ports at the root level. This example uses the swc model from the AUTOSAR examples folder. To copy the swc model file to your working folder, enter this MATLAB® command:

    copyfile(fullfile(matlabroot,'examples/autosarblockset/main/swc.slx'),'.')
  3. Select the Component2 block, place your cursor over the displayed ellipsis, and select cue Link to Model. In the Link to Model dialog box, browse to the implementation model swc.

    To reference the implementation model from the AUTOSAR Component2 component, click OK.

  4. If the specified implementation model does not meet one or more of the linking requirements, the software opens the AUTOSAR Model Linker app, which offers fixes for the unmet requirements. Here is the view that opens for swc.

    If the Linking Requirements pane displays a Fix All button, you are ready to fix the unmet linking requirements and link the component block to the implementation model. Click Fix All.

    If the implementation model does not have a complete AUTOSAR component mapping, as in this example, you must map the model before linking. Click Next and work through mapping panes Set Component and Set Interfaces. For more information, see Create AUTOSAR Software Component in Simulink. When you complete the Set Interfaces pane, click Fix All.

  5. Simulink links the Component2 block to model swc and updates the block interface to match the model implementation.

  6. To view the model content, open the Component2 block. In the open Component2 model, to view the model mapping and dictionary, open the AUTOSAR Component Designer app.

  7. After linking the AUTOSAR component to the implementation model, you can connect the component block to other blocks or root ports in the design.

Create Model from ARXML Component Description

To create an AUTOSAR implementation model from an ARXML component description and map it to an AUTOSAR software component, use the Software Component block cue Create Component Model from ARXML.

Clicking the cue creates a model based on a specified ARXML description, links the component block to the model, and updates the block and model interfaces to match.

  1. Create or open an architecture model. To create a model, open the Simulink Start Page. Under AUTOSAR Blockset, open the Software Architecture template.

  2. From the Modeling tab or the palette, add a Software Component block to the model and name it Controller. The Property Inspector displays the component Kind property as Application, which is correct for this component.

  3. The example Import AUTOSAR XML Descriptions Into Simulink provides an ARXML file that includes a controller component description. The ARXML file is on the default MATLAB search path. If you need to copy the ARXML file to your working folder, enter this MATLAB command:

    copyfile(fullfile(matlabroot,...
        'examples/autosarblockset/data/ThrottlePositionControlComposition.arxml'),'.')
  4. Select the Controller block, place your cursor over the displayed ellipsis, and select cue Create Component Model from ARXML. The AUTOSAR Importer App opens.

    Work through the import and model creation procedure.

  5. In the Select ARXML pane, browse to one or more AUTOSAR XML files that provide one or more software component descriptions. This example uses a file copied in an earlier step, ThrottlePositionControlComposition.arxml. To import the description, click Next.

  6. In the Create Component pane, select the software component from which to create a model. From the list of components imported in the previous step, this example selects Controller.

    To view optional settings for model creation, select Configure Modeling Options.

    You can:

    • Model periodic runnables as atomic subsystems or function-call subsystems, or accept a default modeling style selection (Auto).

    • Select an existing AUTOSAR runnable as the initialization runnable for the component. In this example, Controller_Init is available for selection.

    • Specify a Simulink data dictionary into which to import data objects corresponding to AUTOSAR data types in the XML file. If the specified dictionary does not already exist, the importer creates it. The model is then associated with the data dictionary.

    • Select an AUTOSAR PredefinedVariant defined in the AUTOSAR XML file to initialize SwSystemconst data that serves as input to control variation points. For more information, see Control AUTOSAR Variants with Predefined Value Combinations. In this example, no PredefinedVariant is available for selection.

    For more information about model creation options and behavior, see createComponentAsModel.

  7. To create the model and map it to the AUTOSAR Controller component, click Finish. Simulink creates model Controller.slx in the working folder and updates the block interface to match the model implementation.

  8. To view the model content, open the Controller block. In the open Controller model, to view the model mapping and dictionary, open the AUTOSAR Component Designer app.

  9. After creating the AUTOSAR implementation model and linking the AUTOSAR component to it, connect the component block to other blocks or root ports in the design. For a fully connected controller component, see example Author AUTOSAR Compositions and Components in Architecture Model.

See Also

|

Related Topics