主要内容

本页采用了机器翻译。点击此处可查看英文原文。

applyStereotype

为架构模型元素应用构造型

说明

applyStereotype(element,stereotype) 将一个构造型应用于一个架构模型元素(如果该构造型尚未应用于一个模型元素)。构造型可应用于架构、组件、端口、连接器、接口、分配和函数模型元素。函数模型元素只适用于软件架构。

示例

示例

全部折叠

创建一个带有名为 Component 的组件的模型。

model = systemcomposer.createModel("archModel");
systemcomposer.openModel("archModel");
arch = get(model,"Architecture");
comp = addComponent(arch,"Component");

创建带有构造型和属性的配置文件,打开配置文件编辑器,然后将配置文件应用到模型。

profile = systemcomposer.profile.Profile.createProfile("LatencyProfile");
latencybase = profile.addStereotype("LatencyBase");
latencybase.addProperty("latency",Type="double");
latencybase.addProperty("dataRate",Type="double",DefaultValue="10");
systemcomposer.profile.editor(profile)
model.applyProfile("LatencyProfile");

将构造型应用于组件,并获取组件上的构造型。

comp.applyStereotype("LatencyProfile.LatencyBase");
stereotypes = getStereotypes(comp)
stereotypes =

  1×1 cell array

    {'LatencyProfile.LatencyBase'}

输入参数

全部折叠

构造型的名称,指定为 "<profile>.<stereotype>" 形式的字符向量或字符串。配置文件必须已经导入模型。

数据类型: char | string

详细信息

全部折叠

版本历史记录

在 R2019a 中推出