Main Content

mapState

Map Simulink block state to AUTOSAR variable

Description

example

mapState(slMap,slStateOwnerBlock,'',arVarType) maps the Simulink® block state associated with state owner block slStateOwnerBlock to an AUTOSAR variable of type arVarType for AUTOSAR run-time calibration. AUTOSAR variable types include ArTypedPerInstanceMemory and StaticMemory.

mapState(slMap,slStateOwnerBlock,slState,arVarType) maps Simulink block state slState associated with state owner block slStateOwnerBlock to an AUTOSAR variable of type arVarType. Specify a nonempty slState argument only for blocks with multiple states.

mapState(slMap,slStateOwnerBlock,slState,arVarType,Name,Value) specifies additional properties for an AUTOSAR ArTypedPerInstanceMemory or StaticMemory variable by using one or more Name,Value pair arguments.

Examples

collapse all

Set AUTOSAR mapping and property information for the Simulink block state for Unit Delay block X in example model autosar_swc_counter. The state owner block has one state.

hModel = 'autosar_swc_counter';
addpath(fullfile(matlabroot,'/examples/autosarblockset/main'));
open_system(hModel);
slMap = autosar.api.getSimulinkMapping(hModel);

mapState(slMap,'autosar_swc_counter/X','','ArTypedPerInstanceMemory',...
    'SwCalibrationAccess','ReadWrite')
arMappedTo = getState(slMap,'autosar_swc_counter/X')
arValue = getState(slMap,'autosar_swc_counter/X','','SwCalibrationAccess')
arMappedTo =
    'ArTypedPerInstanceMemory'

arValue =
    'ReadWrite'

Input Arguments

collapse all

Simulink to AUTOSAR mapping information for a model, previously returned by slMap = autosar.api.getSimulinkMapping(model). model is a handle, character vector, or string scalar representing the model name.

Example: slMap

Handle or path to Simulink state owner block to set AUTOSAR mapping information for.

Example: 'autosar_swc_counter/X'

Name of Simulink state associated with state owner block slStateOwnerBlock. Specify a nonempty state name only for blocks with multiple states. If slState is empty, the function sets mapping information for the first state in the block.

Example: ''

Type of AUTOSAR variable to map the specified Simulink block state to. Valid AUTOSAR variable types include ArTypedPerInstanceMemory, StaticMemory, and Auto. To accept software mapping defaults, specify Auto.

Example: 'ArTypedPerInstanceMemory'

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: 'SwCalibrationAccess','ReadWrite' specifies read-write access to the variable for run-time calibration.

Specify display format for the AUTOSAR variable. AUTOSAR display format specifications control the width and precision display for calibration and measurement data. For more information, see Configure DisplayFormat.

Example: 'DisplayFormat','%2.6f'

Specify whether to include C type qualifier volatile in generated code for the AUTOSAR variable.

Example: 'IsVolatile','true'

Optionally specify an AUTOSAR additional native type qualifier to include in generated code for the AUTOSAR variable.

Example: 'Qualifier','test_qualifier'

Specify a short name for the AUTOSAR variable. If unspecified, ARXML export generates a short name, which is based on the state name if one exists. If the state is unnamed, the generated short name can differ from the block name.

Example: 'ShortName','PIM_X'

Specify a SwAddrMethod name that is valid for the AUTOSAR variable. Code generation uses the SwAddrMethod name to group AUTOSAR variables in a memory section for access by calibration and measurement tools. For a list of valid SwAddrMethod values for the variable, see the Code Mappings editor, Signals/States tab. For more information, see Configure SwAddrMethod.

Example: 'SwAddrMethod','VAR'

Specify how calibration and measurement tools can access the AUTOSAR variable. Valid access values include ReadOnly, ReadWrite, and NotAccessible. For more information, see Configure SwCalibrationAccess.

Example: 'SwCalibrationAccess','ReadWrite'

Version History

Introduced in R2018b