Main Content

Configure AUTOSAR Inter-Runnable Variables

In an AUTOSAR software component with multiple runnables, inter-runnable variables (IRVs) are used to communicate data between runnables. In Simulink®, you model IRVs using data transfer lines that connect subsystems. In an application with multiple rates, the data transfer lines might include Rate Transition blocks to handle transitions between differing rates.

These examples show how to use the AUTOSAR property and map functions to configure AUTOSAR IRVs without or with rate transitions.

Configure Inter-Runnable Variable for Data Transfer Line

This example shows how to add, configure, and map AUTOSAR inter-runnable variables (IRVs) to the example model autosar_swc_expfcns.

Add and Configure IRVs

Using example model autosar_swc_expfcns and the relevant autosar.api.getAUTOSARProperties object add an IRV myIRV with SwCalibrationAccess ReadWrite.

hModel = "autosar_swc_expfcns";
open_system(hModel);
arProps = autosar.api.getAUTOSARProperties(hModel);

irvName = "myIrv";
swCalibValue = "ReadWrite";
swc = get(arProps,"XmlOptions","ComponentQualifiedName")
swc = 
'/pkg/swc/ASWC'
ib = get(arProps,swc,"Behavior")
ib = 
'ASWC/IB'
irvs = get(arProps,ib,"IRV")'
irvs = 4x1 cell
    {'ASWC/IB/IRV1'}
    {'ASWC/IB/IRV2'}
    {'ASWC/IB/IRV3'}
    {'ASWC/IB/IRV4'}

add(arProps,ib,"IRV",irvName,"SwCalibrationAccess",swCalibValue);
irvs = get(arProps,ib,"IRV");

Map Simulink Signals to AUTOSAR IRVs

Using the object functions of the autosar.api.getSimulinkMapping object, slMap, map Simulink signal irv1 to AUTOSAR IRV myIRV. Set the data access mode to Explicit.

slMap=autosar.api.getSimulinkMapping(hModel);
listOfDataTransfers = find(slMap, "DataTransfers")
listOfDataTransfers = 1x4 string
    "irv3"    "irv1"    "irv2"    "irv4"

irvAccess = "Explicit";
[arIrvName,arDataAccessMode] = getDataTransfer(slMap,"irv1");
mapDataTransfer(slMap,"irv1",irvName,irvAccess);
[arIrvName,arDataAccessMode] = getDataTransfer(slMap,"irv1")
arIrvName = 
'myIrv'
arDataAccessMode = 
'Explicit'

To pass validation, you will need to remove any redundant IRVs in the AUTOSAR configuration.

irvs = get(arProps,ib,"IRV");
delete(arProps,[ib,'/IRV1'])
irvs = get(arProps,ib,"IRV")'
irvs = 4x1 cell
    {'ASWC/IB/IRV2' }
    {'ASWC/IB/IRV3' }
    {'ASWC/IB/IRV4' }
    {'ASWC/IB/myIrv'}

Configure Inter-Runnable Variable for Data Transfer with Rate Transition.

This example:

  1. Opens a model with multiple rates.

  2. Adds an AUTOSAR inter-runnable variable (IRV) to the model.

  3. Maps a Simulink® Rate Transition block to the IRV.

Open the model 'mMultitasking_4rates'.

hModel = 'mMultitasking_4rates';
open_system(hModel);

Use AUTOSAR property functions.

arProps = autosar.api.getAUTOSARProperties(hModel);

Retrieve AUTOSAR internal behavior and add IRV 'myIrv' with SwCalibrationAccess ReadWrite.

irvName = 'myIrv';
swCalibValue = 'ReadWrite';
swc = get(arProps,'XmlOptions','ComponentQualifiedName')
swc = 
'/mMultitasking_4rates_pkg/mMultitasking_4rates_swc/mMultitasking_4rates'
ib = get(arProps,swc,'Behavior')
ib = 
'mMultitasking_4rates/Behavior'
irvs = get(arProps,ib,'IRV')
irvs = 1x3 cell
    {'mMultitasking_4rates/Behavior/IRV1'}    {'mMultitasking_4rates/Behavior/IRV2'}    {'mMultitasking_4rates/Behavior/IRV3'}

add(arProps,ib,'IRV',irvName,'SwCalibrationAccess',swCalibValue);
irvs = get(arProps,ib,'IRV');

Use AUTOSAR map functions:

slMap=autosar.api.getSimulinkMapping(hModel);

Map the Simulink Real-Time block 'RateTransition2' to AUTOSAR IRV 'myIrv' with access mode Explicit.

irvAccess = 'Explicit';
[arIrvName,arDataAccessMode] = getDataTransfer(slMap,'mMultitasking_4rates/RateTransition2');
mapDataTransfer(slMap,'mMultitasking_4rates/RateTransition2',irvName,irvAccess);
[arIrvName,arDataAccessMode] = getDataTransfer(slMap,'mMultitasking_4rates/RateTransition2')
arIrvName = 
'myIrv'
arDataAccessMode = 
'Explicit'

To pass validation, remove any redundant IRV in the AUTOSAR configuration.

irvs = get(arProps,ib,'IRV');
delete(arProps,[ib,'/IRV3'])
irvs = get(arProps,ib,'IRV')
irvs = 1x3 cell
    {'mMultitasking_4rates/Behavior/IRV1'}    {'mMultitasking_4rates/Behavior/IRV2'}    {'mMultitasking_4rates/Behavior/myIrv'}

See Also

Objects

Functions

Related Topics