mapFunction
将 Simulink 入口函数映射到 AUTOSAR 可运行实体和软件寻址方法
语法
说明
mapFunction( 将 Simulink® 入口函数 slMap,slEntryPointFunction,arRunnableName)slEntryPointFunction 映射到 AUTOSAR 可运行实体 arRunnableName。
mapFunction( 使用一个或多个 slMap,slEntryPointFunction,arRunnableName,Name,Value)Name,Value 对组参量为 AUTOSAR 可运行实体指定附加属性。您可以为可运行实体函数代码和内部数据指定软件寻址方法 (SwAddrMethod)。
示例
在示例模型 autosar_swc 中为 Simulink 入口函数设置 AUTOSAR 映射信息。该模型具有名为 Runnable_Init 的初始化入口函数以及名为 Runnable_1s 和 Runnable_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 映射信息的入口函数,指定为下表中的值之一。
| 函数类型 | 值 |
|---|---|
| 初始化 | |
| 终止 | |
| 重置 | |
| 周期性(隐式任务) | 示例:
提示 对于单任务周期函数,您可以使用不带
|
| 分区(显式任务) | 示例: |
| 客户端-服务器配置中的 Simulink 函数 | 例如,在 AUTOSAR Server Model Configuration and Code Generation的示例模型中指定 |
| 导出 | 例如,进行如下指定:
|
要将指定的 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 中推出
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)