主要内容

本页翻译不是最新的。点击此处可查看最新英文版本。

find

查找 AUTOSAR 元素

说明

paths = find(arProps,rootPath,category) 返回与 category 匹配的 AUTOSAR 元素的 paths,从路径 rootPath 开始。

paths = find(arProps,rootPath,category,'PathType',value) 指定返回的 paths 是完全限定还是部分限定。

示例

paths = find(arProps,rootPath,category,property,value) 对元素的指定 category 属性指定约束值,从而缩小搜索范围。

示例

示例

全部折叠

对于模型,查找属性 IsServicefalse 的发送方-接收方接口,并返回完全限定路径。

hModel = 'autosar_swc_expfcns';
open_system(hModel);
arProps = autosar.api.getAUTOSARProperties(hModel);
ifPaths = find(arProps,[],'SenderReceiverInterface',...
  'IsService',false,'PathType','FullyQualified')
ifPaths = 1×2 cell
    {'/pkg/if/Interface1'}    {'/pkg/if/Interface2'}

对于模型,添加模式切换接口,然后使用 find 列出了模型中模型切换接口的路径。

hModel = 'mAutosarMsConfigAfter';
open_system(hModel);
arProps = autosar.api.getAUTOSARProperties(hModel);
addPackageableElement(arProps,'ModeSwitchInterface','/pkg/if','Interface3',...
  'IsService',true);
ifPaths = find(arProps,[],'ModeSwitchInterface','PathType','FullyQualified')
ifPaths = 1×3 cell
    {'/pkg/if/myMsIf'}    {'/pkg/if/MsIf2'}    {'/pkg/if/Interface3'}

输入参数

全部折叠

模型的 AUTOSAR 属性信息,以前由 arProps = autosar.api.getAUTOSARProperties(model) 返回。model 是一个表示模型名称的句柄、字符向量或字符串标量。

示例: arProps

指定查找指定类型的 AUTOSAR 元素的起点的路径。[] 表示组件的根。

示例: []

要为其返回路径的 AUTOSAR 元素的类型。

示例: 'SenderReceiverInterface'

指定 FullyQualified 以返回完全限定路径。

示例: 'PathType','FullyQualified'

指定元素类别的有效属性,以及搜索中该属性要匹配的值。表 AUTOSAR 元素的属性 列出了与 AUTOSAR 元素关联的属性,有关这些属性的详细信息,请参阅 AUTOSAR Element Properties

示例: 'IsService',true

输出参量

全部折叠

返回 AUTOSAR 元素路径的变量。

示例: ifPaths

版本历史记录

在 R2013b 中推出