主要内容

getFunction

R2026b

获取 Simulink 入口函数的 AUTOSAR 映射信息

描述

arRunnableName = getFunction(slMap,slEntryPointFunction) 返回映射到 Simulink® 入口函数 slEntryPointFunction 的 AUTOSAR 可运行实体 arRunnableName 的名称。

示例

[arRunnableName,arRunnableSwAddrMethod,arInternalDataSwAddrMethod] = getFunction(slMap,slEntryPointFunction) 返回为映射的 AUTOSAR 可运行实体定义的函数和内部数据软件寻址方法 (SwAddrMethod) 的名称。如果未定义 SwAddrMethod,则该函数返回 '<None>'。

示例

示例

全部折叠

获取示例模型 autosar_swc 中映射到 Simulink 入口函数的 AUTOSAR 可运行实体的名称。该模型具有名为 Runnable_Init 的初始化入口函数以及名为 Runnable_1s 和 Runnable_2s 的周期性入口函数。

hModel = 'autosar_swc';
openExample(hModel);
slMap=autosar.api.getSimulinkMapping(hModel);
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 可运行实体名称的变量。

示例: arRunnableName

返回为 AUTOSAR 可运行实体函数定义的 SwAddrMethod 的名称的变量。

示例: arRunnableSwAddrMethod

返回为 AUTOSAR 可运行实体内部数据定义的 SwAddrMethod 的名称的变量。

示例: arInternalDataSwAddrMethod

版本历史记录

在 R2013b 中推出

全部展开