主要内容

mapFunction

Simulink 入口函数映射到 AUTOSAR 可运行实体和软件寻址方法

说明

mapFunction(slMap,slEntryPointFunction,arRunnableName) 将 Simulink® 入口函数 slEntryPointFunction 映射到 AUTOSAR 可运行实体 arRunnableName

示例

mapFunction(slMap,slEntryPointFunction,arRunnableName,Name,Value) 使用一个或多个 Name,Value 对组参量为 AUTOSAR 可运行实体指定附加属性。您可以为可运行实体函数代码和内部数据指定软件寻址方法 (SwAddrMethod)。

示例

示例

全部折叠

在示例模型 autosar_swc 中为 Simulink 入口函数设置 AUTOSAR 映射信息。该模型具有名为 Runnable_Init 的初始化入口函数以及名为 Runnable_1sRunnable_2s 的周期性入口函数。

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

在示例模型 autosar_swc_counter 中为 Simulink 入口函数设置 AUTOSAR SwAddrMethod。该模型具有单任务周期性单步入口函数。

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'

输入参数

全部折叠

模型的 Simulink 到 AUTOSAR 映射信息,以前由 slMap = autosar.api.getSimulinkMapping(model) 返回。model 是一个表示模型名称的句柄、字符向量或字符串标量。

示例: slMap

要为其设置 AUTOSAR 映射信息的入口函数,指定为下表中的值之一。

函数类型
初始化

"Initialize"

终止

"Terminate"

重置

"Reset:slIdentifier",其中 slIdentifier 是模型中重置函数的名称

周期性(隐式任务)

"Periodic:slIdentifier",其中 slIdentifier 是对应的周期注解,如时间图例中所示

示例:"Periodic:D1"

提示

对于单任务周期函数,您可以使用不带 :slIdentifier "Periodic"

分区(显式任务)

"Partition:slIdentifier",其中 slIdentifier 是分区名称,如调度编辑器中所示

示例:"Partition:P1"

客户端-服务器配置中的 Simulink 函数

"SimulinkFunction:slIdentifier",其中 slIdentifier 是模型中全局 Simulink 函数的名称。

例如,在 AUTOSAR Server Model Configuration and Code Generation的示例模型中指定 "SimulinkFunction:readData"

导出

"ExportedFunction:slIdentifier",其中 slIdentifier 是驱动函数调用子系统控制端口的 Inport 模块的名称;或如果它由 In Bus Element 模块驱动,则为端口的名称

例如,进行如下指定:

  • 在示例模型 autosar_swc_slfcns 中指定 "ExportedFunction:Trigger_1s"

  • 在示例模型 autosar_swc_fcncalls 中指定 "ExportedFunction:FunctionTrigger"

要将指定的 Simulink 入口函数对象映射到的 AUTOSAR 可运行实体的名称。

示例: 'Runnable_2s'

名称-值参数

全部折叠

将可选参量对组指定为 Name1=Value1,...,NameN=ValueN,其中 Name 是参量名称,Value 是对应的值。名称-值参量必须出现在其他参量之后,但对各个参量对组的顺序没有要求。

如果使用的是 R2021a 之前的版本,请使用逗号分隔每个名称和值,并用引号将 Name 引起来。

示例: 'SwAddrMethod','CODE' 为 AUTOSAR 可运行实体函数指定 SwAddrMethod CODE

指定对 AUTOSAR 函数有效的 SwAddrMethod 名称。代码生成使用 SwAddrMethod 名称将 AUTOSAR 可运行实体函数分组到一个内存段中。有关该函数的有效 SwAddrMethod 值的列表,请查看代码映射编辑器的入口函数选项卡。有关详细信息,请参阅Configure SwAddrMethod

示例: 'SwAddrMethod','CODE'

指定对 AUTOSAR 内部数据有效的 SwAddrMethod 名称。代码生成使用 SwAddrMethod 名称将 AUTOSAR 可运行实体内部数据分组到一个内存段中。有关该内部数据的有效 SwAddrMethod 值的列表,请查看代码映射编辑器的入口函数选项卡。有关详细信息,请参阅Configure SwAddrMethod

为可运行实体内部数据 SwAddrMethod 生成代码需要将模型配置选项代码生成 > 接口 > 为每个入口函数生成单独的内部数据 (GroupInternalDataByFunction) 设置为 on

示例: 'SwAddrMethodForInternalData','VAR'

版本历史记录

在 R2013b 中推出