主要内容

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

add

将属性添加到 AUTOSAR 元素

说明

add(arProps,parentPath,property,name) 将具有指定 name 的复合子元素添加到 parentPath 上的 AUTOSAR 元素,位于指定的 property 下。

示例

add(arProps,parentPath,property,name,childproperty,value) 设置所添加元素的一个指定属性的值。

示例

全部折叠

将数据元素 DE3 添加到发送方接口 Interface1

hModel = "autosar_swc_expfcns";
open_system(hModel);
arProps = autosar.api.getAUTOSARProperties(hModel);
add(arProps,"Interface1","DataElements","DE3");
get(arProps,"Interface1","DataElements")
ans = 1×3 cell
    {'Interface1/DE1'}    {'Interface1/DE2'}    {'Interface1/DE3'}

使用完全限定路径添加模式-切换接口,并将 IsService 属性设置为 true。使用复合属性 ModeGroup 将模式组 mgMode 添加到模式切换接口。

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'}

add(arProps,'/pkg/if/Interface3','ModeGroup','mgModes');
get(arProps,'Interface3','ModeGroup')
ans = 
'Interface3/mgModes'

输入参数

全部折叠

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

示例: arProps

要向其添加指定子属性元素的父 AUTOSAR 元素的路径。

示例: 'Input'

要添加的属性的类型,属于 AUTOSAR 元素的有效属性。

示例: 'DataElements'

要添加的子属性元素的名称。

示例: 'DE1'

要设置的子属性及其值。表 AUTOSAR 元素的属性 列出了与 AUTOSAR 元素关联的属性,有关这些属性的详细信息,请参阅 AUTOSAR Element Properties

示例: 'Name','event1'

版本历史记录

在 R2013b 中推出