主要内容

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

setDefaultElementStereotype

为元素设置默认构造型

自 R2021b 起

说明

setDefaultElementStereotype(stereotype,elementType,stereotypeName) 指定子元素的默认构造型 stereotypeName,其父元素 elementType 类型已应用了构造型 stereotype

示例

示例

全部折叠

创建延迟特性配置文件并保存。

profile = systemcomposer.profile.Profile.createProfile("LatencyProfile");

latencybase = profile.addStereotype("LatencyBase");
latencybase.addProperty("latency",Type="double");
latencybase.addProperty("dataRate",Type="double",DefaultValue="10");

connLatency = profile.addStereotype("ConnectorLatency",...
Parent="LatencyProfile.LatencyBase");
connLatency.addProperty("secure",Type="boolean");
connLatency.addProperty("linkDistance",Type="double");

nodeLatency = profile.addStereotype("NodeLatency",...
Parent="LatencyProfile.LatencyBase");
nodeLatency.addProperty("resources",Type="double",DefaultValue="1");

portLatency = profile.addStereotype("PortLatency",...
Parent="LatencyProfile.LatencyBase");
portLatency.addProperty("queueDepth",Type="double");
portLatency.addProperty("dummy",Type="int32");

profile.save

LatencyProfile.NodeLatency 构造型指定为组件构造型。设置默认组件构造型。

nodeLatency.AppliesTo = "Component";
nodeLatency.setDefaultElementStereotype("Component","LatencyProfile.NodeLatency")

创建模型,将配置文件应用于模型,然后添加一个组件。在组件上应用构造型。然后,打开配置文件编辑器

modelName = "archModel";
arch = systemcomposer.createModel(modelName);
systemcomposer.openModel(modelName);
arch.applyProfile("LatencyProfile");
newComponent = addComponent(arch.Architecture,"Component");
newComponent.applyStereotype("LatencyProfile.NodeLatency");
systemcomposer.profile.editor(profile)

创建子组件并获取子组件的构造型。

childComponent = addComponent(newComponent.Architecture,"Child");
stereotypes = getStereotypes(childComponent)
stereotypes =

  1×1 cell array

    {'LatencyProfile.NodeLatency'}

创建延迟特性配置文件并保存。

profile = systemcomposer.profile.Profile.createProfile("LatencyProfile");

latencybase = profile.addStereotype("LatencyBase");
latencybase.addProperty("latency",Type="double");
latencybase.addProperty("dataRate",Type="double",DefaultValue="10");

connLatency = profile.addStereotype("ConnectorLatency",...
Parent="LatencyProfile.LatencyBase");
connLatency.addProperty("secure",Type="boolean");
connLatency.addProperty("linkDistance",Type="double");

nodeLatency = profile.addStereotype("NodeLatency",...
Parent="LatencyProfile.LatencyBase");
nodeLatency.addProperty("resources",Type="double",DefaultValue="1");

portLatency = profile.addStereotype("PortLatency",...
Parent="LatencyProfile.LatencyBase");
portLatency.addProperty("queueDepth",Type="double");
portLatency.addProperty("dummy",Type="int32");

profile.save

LatencyProfile.NodeLatency 构造型指定为组件构造型。设置默认端口构造型。

nodeLatency.AppliesTo = "Component";
nodeLatency.setDefaultElementStereotype("Port","LatencyProfile.PortLatency");

创建模型,将配置文件应用于模型,然后添加一个组件。在组件上应用构造型。然后,打开配置文件编辑器

modelName = "archModel";
arch = systemcomposer.createModel(modelName);
systemcomposer.openModel(modelName);
arch.applyProfile("LatencyProfile");
newComponent = addComponent(arch.Architecture,"Component");
newComponent.applyStereotype("LatencyProfile.NodeLatency");
systemcomposer.profile.editor(profile)

在组件上创建架构端口,并获取端口上的构造型。

port = addPort(newComponent.Architecture,"testSig","out"); 
stereotypes = getStereotypes(port)
stereotypes =

  1×1 cell array

    {'LatencyProfile.PortLatency'}

创建延迟特性配置文件并保存。

profile = systemcomposer.profile.Profile.createProfile("LatencyProfile");

latencybase = profile.addStereotype("LatencyBase");
latencybase.addProperty("latency",Type="double");
latencybase.addProperty("dataRate",Type="double",DefaultValue="10");

connLatency = profile.addStereotype("ConnectorLatency",...
Parent="LatencyProfile.LatencyBase");
connLatency.addProperty("secure",Type="boolean");
connLatency.addProperty("linkDistance",Type="double");

nodeLatency = profile.addStereotype("NodeLatency",...
Parent="LatencyProfile.LatencyBase");
nodeLatency.addProperty("resources",Type="double",DefaultValue="1");

portLatency = profile.addStereotype("PortLatency",...
Parent="LatencyProfile.LatencyBase");
portLatency.addProperty("queueDepth",Type="double");
portLatency.addProperty("dummy",Type="int32");

profile.save

LatencyProfile.NodeLatency 构造型指定为组件构造型。设置默认连接器构造型。

nodeLatency.AppliesTo = "Component";
nodeLatency.setDefaultElementStereotype("Connector","LatencyProfile.ConnectorLatency");

创建模型,将配置文件应用于模型,然后添加一个组件。在组件上应用构造型。然后,打开配置文件编辑器

modelName = "archModel";
arch = systemcomposer.createModel(modelName);
systemcomposer.openModel(modelName);
arch.applyProfile("LatencyProfile");
newComponent = addComponent(arch.Architecture,"Component");
newComponent.applyStereotype("LatencyProfile.NodeLatency");
systemcomposer.profile.editor(profile)

创建两个子组件。添加端口。然后,在端口之间创建一个连接,并在连接器上获取构造型。

childComponent1 = addComponent(newComponent.Architecture,"Child1");
childComponent2 = addComponent(newComponent.Architecture,"Child2");

outPort1 = addPort(childComponent1.Architecture,"testSig","out"); 
inPort1 = addPort(childComponent2.Architecture,"testSig","in");
srcPort = getPort(childComponent1,"testSig");
destPort = getPort(childComponent2,"testSig");

connector = connect(srcPort,destPort);
stereotypes = getStereotypes(connector)
stereotypes =

  1×1 cell array

    {'LatencyProfile.ConnectorLatency'}

输入参数

全部折叠

构造型,指定为 systemcomposer.profile.Stereotype 对象。

元素类型,指定为:

数据类型: char | string

子元素的默认构造型名称,指定为 "<profile>.<stereotype>" 形式的字符向量或字符串。

数据类型: char | string

详细信息

全部折叠

版本历史记录

在 R2021b 中推出