主要内容

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

get

获取 AUTOSAR 元素的属性

说明

pValue = get(arProps,elementPath,property) 返回 elementPath 上 AUTOSAR 元素的指定属性的值。

示例

示例

全部折叠

对于模型,获取发送方-接收方接口 Interface1IsService 属性的值。变量 IsService 返回 false (0),表示发送方-接收方接口不是服务。

hModel = 'autosar_swc_expfcns';
openExample(hModel);
arProps = autosar.api.getAUTOSARProperties(hModel);
isService = get(arProps,'Interface1','IsService')
isService =
  logical
   0

对于 AUTOSAR 模型,要为将可运行实体 Runnable1symbol 属性设置为 test_symbol 做准备,请获取 AUTOSAR 组件限定名称和现有可运行实体符号名称。

hModel = 'autosar_swc_expfcns';
openExample(hModel);
arProps = autosar.api.getAUTOSARProperties(hModel);
compQName = get(arProps,'XmlOptions','ComponentQualifiedName');
runnables = find(arProps,compQName,'Runnable','PathType','FullyQualified');
runnables(2)
ans =
  1×1 cell array
    {'/pkg/swc/ASWC/IB/Runnable1'}
get(arProps,runnables{2},'symbol')
ans =
    'Runnable1'
set(arProps,runnables{2},'symbol','test_symbol')
get(arProps,runnables{2},'symbol')
ans =
    'test_symbol'

输入参数

全部折叠

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

示例: arProps

要为其返回属性值的 AUTOSAR 元素的路径。

示例: 'Input'

要为其返回值的属性,属于 AUTOSAR 元素的有效属性。

示例: 'IsService'

输出参量

全部折叠

返回指定 AUTOSAR 属性值的变量。对于复合属性或引用其他属性的属性,返回值是属性的路径。

示例: ifPaths

版本历史记录

在 R2013b 中推出