Main Content

getFunction

Get AUTOSAR mapping information for Simulink entry-point function

Description

arRunnableName = getFunction(slMap,slEntryPointFunction) returns the name of the AUTOSAR runnable arRunnableName mapped to Simulink® entry-point function slEntryPointFunction.

example

[arRunnableName,arRunnableSwAddrMethod,arInternalDataSwAddrMethod] = getFunction(slMap,slEntryPointFunction) returns the names of function and internal data software address methods (SwAddrMethods) defined for the mapped AUTOSAR runnable. If a SwAddrMethod is not defined, the function returns '<None>'.

example

Examples

collapse all

Get the name of the AUTOSAR runnable mapped to a Simulink entry-point function in the example model autosar_swc. The model has an initialize entry-point function named Runnable_Init and periodic entry-point functions named Runnable_1s and Runnable_2s.

hModel = 'autosar_swc';
openExample(hModel);
slMap=autosar.api.getSimulinkMapping(hModel);
arRunnableName=getFunction(slMap,'Initialize')
arRunnableName =
    'Runnable_Init'

Get AUTOSAR SwAddrMethod names for a Simulink entry-point function in the example model autosar_swc_counter. The model has a single-tasking periodic entry-point function.

hModel = 'autosar_swc_counter';
openExample(hModel);

% Add SwAddrMethods myCODE and myVAR to the AUTOSAR component
arProps = autosar.api.getAUTOSARProperties(hModel);
addPackageableElement(arProps,'SwAddrMethod',...
    '/Company/Powertrain/DataTypes/SwAddrMethods','myCODE',...
    'SectionType','Code')
swAddrPaths = find(arProps,[],'SwAddrMethod','PathType','FullyQualified',...
    'SectionType','Code')
addPackageableElement(arProps,'SwAddrMethod',...
    '/Company/Powertrain/DataTypes/SwAddrMethods','myVAR',...
    'SectionType','Var')
swAddrPaths = find(arProps,[],'SwAddrMethod','PathType','FullyQualified',...
    'SectionType','Var')

% Set code generation parameter for runnable internal data SwAddrMethods
set_param(hModel,'GroupInternalDataByFunction','on')

% Map periodic function and internal data to myCODE and myVAR SwAddrMethods
slMap = autosar.api.getSimulinkMapping(hModel);
mapFunction(slMap,'Periodic','Runnable_Step',...
    'SwAddrMethod','myCODE','SwAddrMethodForInternalData','myVAR')

% Return AUTOSAR mapping information for periodic function
[arRunnableName,arRunnableSwAddrMethod,arInternalDataSwAddrMethod] = ...
    getFunction(slMap,'Periodic')
swAddrPaths =
  1×2 cell array
    {'/Company/Powertrain/DataTypes/SwAddrMethods/CODE'}
    {'/Company/Powertrain/DataTypes/SwAddrMethods/myCODE'}

swAddrPaths =
  1×2 cell array
    {'/Company/Powertrain/DataTypes/SwAddrMethods/VAR'}
    {'/Company/Powertrain/DataTypes/SwAddrMethods/myVAR'}

arRunnableName =
    'Runnable_Step'

arRunnableSwAddrMethod =
    'myCODE'

arInternalDataSwAddrMethod =
    'myVAR'

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

entry-point function to get AUTOSAR mapping information of, specified as one of the values in the table.

Function TypeValue
Initialize

"Initialize"

Terminate

"Terminate"

Reset

"Reset:slIdentifier", where slIdentifier is the name of the reset function in the model

Periodic (implicit task)

"Periodic:slIdentifier", where slIdentifier is the corresponding period annotation, as displayed in the Timing Legend

Example: "Periodic:D1"

Tip

For a single-tasking periodic function, you can use "Periodic" without :slIdentifier .

Partition (explicit task)

"Partition:slIdentifier", where slIdentifier is the partition name, as displayed in the Schedule Editor

Example: "Partition:P1"

Simulink function in client-server configuration

"SimulinkFunction:slIdentifier", where slIdentifier is the name of a global Simulink function in the model.

For example, specify "SimulinkFunction:readData" in the example model in AUTOSAR Server Model Configuration and Code Generation.

Exported

"ExportedFunction:slIdentifier", where slIdentifier is the name of the Inport block that drives the control port of the function-call subsystem, or the name of the port if it is driven by an In Bus Element block

For example, specify:

  • "ExportedFunction:Trigger_1s" in example model autosar_swc_slfcns.

  • "ExportedFunction:FunctionTrigger" in example model autosar_swc_fcncalls.

Output Arguments

collapse all

Variable that returns the name of the AUTOSAR runnable mapped to the specified Simulink entry-point function object.

Example: arRunnableName

Variable that returns the name of the SwAddrMethod defined for the AUTOSAR runnable function.

Example: arRunnableSwAddrMethod

Variable that returns the name of the SwAddrMethod defined for the AUTOSAR runnable internal data.

Example: arInternalDataSwAddrMethod

Version History

Introduced in R2013b