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.

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. For example:

  1. Create or open an architecture model. For example, use the Simulink Start Page to create a model from the AUTOSAR Blockset Software Architecture template.

  2. From the Modeling tab or the palette, add a Software Component block to the model and name it Controller. Leave the component Kind property set to Application.

  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 a Template from a 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. 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 AUTOSAR implementation model from an AUTOSAR software component, use the Software Component block cue Link to Model. Potentially, model linking allows you to deploy verified implementation models in your AUTOSAR design without requalification.

Clicking the cue links the Software Component block to a specified model and updates the block and model interfaces to match. If you link to a model that uses root Inport and Outport blocks, the software converts the model signal ports to bus ports. For more information, see Configure AUTOSAR Ports By Using Simulink Bus Ports.

To link an AUTOSAR component to an AUTOSAR implementation model:

  1. Create or open an architecture model. For example, use the Simulink Start Page to create a model from the AUTOSAR Blockset Software Architecture template.

  2. From the Modeling tab or the palette, add a Software Component block to the model and name it Controller. Leave the component Kind property set to Application.

  3. The example Author AUTOSAR Compositions and Components in Architecture Model provides a controller implementation model. To copy the model file to your working folder, enter this MATLAB command:

    copyfile(fullfile(matlabroot,'examples/autosarblockset/main/autosar_tpc_controller.slx'),'.')
  4. Select the Controller 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 autosar_tpc_controller.slx.

    To reference the controller implementation model from the AUTOSAR Controller component, click OK. Simulink links the Controller block to model autosar_tpc_controller and updates the block interface to match the model implementation.

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

  6. After linking the AUTOSAR component to the AUTOSAR implementation model, 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.

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. For example:

  1. Create or open an architecture model. For example, use the Simulink Start Page to create a model from the AUTOSAR Blockset Software Architecture template.

  2. From the Modeling tab or the palette, add a Software Component block to the model and name it Controller. Leave the component Kind property set to Application.

  3. The example Import AUTOSAR Software Component 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 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