Main Content

batchApplyStereotype

Apply stereotype to all elements in architecture

Description

batchApplyStereotype(arch,elementType,stereotype) applies the stereotype stereotype to all elements that match the element type elementType within the architecture arch.

example

batchApplyStereotype(___,Recurse=flag) applies the stereotype stereotype to all elements that match the element type elementType within the architecture arch and recursively to its sub-architectures according to the value of flag.

Examples

collapse all

Create a profile, add a connector stereotype, and add a property with a default value. Open the Profile Editor to inspect the profile.

profile = systemcomposer.profile.Profile.createProfile("LatencyProfile");
stereotype = addStereotype(profile,"standardConn",AppliesTo="Connector");
stereotype.addProperty("latency",Type="double",DefaultValue="10");
systemcomposer.profile.editor(profile)

Create a model with three components, ports, and connectors between them. Improve the model layout.

modelName = "archModel";
arch = systemcomposer.createModel(modelName);
systemcomposer.openModel(modelName);
rootArch = get(arch,"Architecture");
names = ["Component1","Component2","Component3"];
newComponents = addComponent(rootArch,names);
outPort1 = addPort(newComponents(1).Architecture,"testSig1","out"); 
inPort1 = addPort(newComponents(2).Architecture,"testSig1","in");
outPort2 = addPort(newComponents(2).Architecture,"testSig2","out"); 
inPort2 = addPort(newComponents(3).Architecture,"testSig2","in");
conn1 = connect(newComponents(1),newComponents(2));
conn2 = connect(newComponents(2),newComponents(3));
Simulink.BlockDiagram.arrangeSystem(modelName)

Apply the profile to the model.

arch.applyProfile("LatencyProfile");

Apply the connector stereotype to all the connectors in the architecture rootArch. Inspect the connectors in the Property Inspector to confirm the applied stereotypes.

batchApplyStereotype(rootArch,"Connector","LatencyProfile.standardConn")

Input Arguments

collapse all

Architecture, specified as a systemcomposer.arch.Architecture object.

Element type, specified as:

Data Types: char | string

Stereotype to apply, specified as a character vector or string in the form "<profile>.<stereotype>". This stereotype must be applicable for the element type.

Data Types: char | string

Whether to apply stereotype recursively, specified as 1 (true) or 0 (false). If flag is 1 (true), the stereotype is applied to the elements in the architecture and its sub-architectures.

Data Types: logical

More About

collapse all

Version History

Introduced in R2019a