findElementsOfType
语法
说明
查找 elements
= findElementsOfType(containerObj
,kind
)kind
类型的所有元素 elements
。
查找一个类型的所有元素,并带有由一个或多个名称-值参量指定的附加选项。elements
= findElementsOfType(containerObj
,kind
,Name=Value
)
示例
使用 System Composer™ 查询命名空间中的函数过滤模型中的元素。
导入包含所有 System Composer 查询的命名空间。
import systemcomposer.query.*
加载模型和配置文件。
sysModel = systemcomposer.loadModel("mBasicModel"); basicProfile = systemcomposer.loadProfile("mProfile");
查找模型中的所有组件。
allComps = findElementsOfType(sysModel,"Component")
allComps=1×10 Component array with properties:
IsAdapterComponent
Architecture
ReferenceName
Name
Parent
Ports
OwnedPorts
OwnedArchitecture
Parameters
Position
Model
SimulinkHandle
SimulinkModelHandle
UUID
ExternalUID
查找模型中的所有端口。
allPorts = findElementsOfType(sysModel,"Port")
allPorts=1×19 ComponentPort array with properties:
Parent
ArchitecturePort
Name
Direction
InterfaceName
Interface
InheritsInterface
Connectors
Connected
Model
SimulinkHandle
SimulinkModelHandle
UUID
ExternalUID
查找模型中的所有构造型。
allStereotypes = findElementsOfType(basicProfile,"Stereotype")
allStereotypes=1×10 Stereotype array with properties:
Name
Description
Parent
AppliesTo
Abstract
Icon
ComponentHeaderColor
ConnectorLineColor
ConnectorLineStyle
FullyQualifiedName
Profile
OwnedProperties
Properties
查找模型中的所有接口。
allInterfaces = findElementsOfType(sysModel,"Interface")
allInterfaces=1×7 heterogeneous Interface (ValueType, PhysicalInterface, DataInterface) array with properties:
UUID
ExternalUID
查找模型中名称包含 "c1"
的组件。
nameComponents = findElementsWithProperty(sysModel,"Component","Name","c1","contains")
nameComponents=1×2 Component array with properties:
IsAdapterComponent
Architecture
ReferenceName
Name
Parent
Ports
OwnedPorts
OwnedArchitecture
Parameters
Position
Model
SimulinkHandle
SimulinkModelHandle
UUID
ExternalUID
查找配置文件中名称包含 "BasePort"
的所有构造型。
basePortStereotype = findElementsWithProperty(basicProfile,"Stereotype","Name","BasePort","eq")
basePortStereotype = Stereotype with properties: Name: 'BasePort' Description: '' Parent: [0×0 systemcomposer.profile.Stereotype] AppliesTo: 'Port' Abstract: 1 Icon: '' ComponentHeaderColor: [210 210 210] ConnectorLineColor: [168 168 168] ConnectorLineStyle: 'Default' FullyQualifiedName: 'mProfile.BasePort' Profile: [1×1 systemcomposer.profile.Profile] OwnedProperties: [0×0 systemcomposer.profile.Property] Properties: [0×0 systemcomposer.profile.Property]
使用 "BasePort"
构造型查找模型中的所有组件。
basePorts = findElementsWithStereotype(sysModel,"Port",basePortStereotype)
basePorts=1×18 ComponentPort array with properties:
Parent
ArchitecturePort
Name
Direction
InterfaceName
Interface
InheritsInterface
Connectors
Connected
Model
SimulinkHandle
SimulinkModelHandle
UUID
ExternalUID
使用前两个找到的接口查找所有元素。
portsUsingInterfaces = findElementsWithInterface(sysModel,"Port",[allInterfaces(1) allInterfaces(2)])
portsUsingInterfaces=1×2 ComponentPort array with properties:
Parent
ArchitecturePort
Name
Direction
InterfaceName
Interface
InheritsInterface
Connectors
Connected
Model
SimulinkHandle
SimulinkModelHandle
UUID
ExternalUID
输入参数
元素类型,指定为这些选项之一:
"Component"
"Port"
"Connector"
"Interface"
"InterfaceElement"
"Stereotype"
数据类型: string
名称-值参数
以 Name1=Value1,...,NameN=ValueN
的形式指定可选参量对组,其中 Name
是参量名称,Value
是对应的值。名称-值参量必须出现在其他参量之后,但对各个参量对组的顺序没有要求。
在 R2021a 之前,使用逗号分隔每个名称和值,并用引号将 Name
引起来。
示例: allComps = systemcomposer.query.findElementsOfType(sysModel,"Component",NegateResult=true,IncludeReferences=false)
是否否定查询结果,指定为 1
(true
) 或 0
(false
)。
数据类型: logical
搜索引用架构的选项,指定为 1
(true
) 或 0
(false
)。
数据类型: logical
输出参量
找到的元素,以数组形式返回:
详细信息
术语 | 定义 | 应用 | 更多信息 |
---|---|---|---|
架构 | System Composer™ 架构代表由组件组成的系统,以及这些组件在结构上和行为上如何相互关联。 | 不同类型的架构描述系统的不同方面。您可以使用视图来可视化架构中的组件子集。您可以使用参数编辑器在架构层级上定义参数。 | |
根 | 根位于架构层次结构的顶层。根架构的边界由围绕相关系统的架构端口定义。 | 根架构的系统边界包围着您的架构模型。您可以添加架构端口来定义跨边界接口。 | |
模型 | System Composer 模型是包含架构信息的文件,涵盖组件、端口、连接器、接口和行为等信息。 | 对模型执行操作,包括提取根级架构、应用配置文件、链接接口数据字典或从模型架构生成实例。System Composer 模型存储为 SLX 文件。 | 创建带接口和需求链接的架构模型 |
组件 | 组件是系统中可替换的部分,用于在架构环境中实现明确的函数。组件定义架构元素,例如函数、另一个系统、硬件、软件或其他概念实体。组件也可以是子系统或子函数。 | 组件以模块的形式表示,是架构模型的一部分,并且可以分离成可重用的工件。使用接口编辑器通过端口接口在组件之间传输信息,使用参数编辑器传输参数。 | |
端口 | 端口是组件或架构上的节点,表示与其环境的交互点。通过端口,信息可以流向其他组件或系统,或者从其他组件或系统流入。 | 组件端口是组件上与其他组件之间的交互点。架构端口是系统边界上的端口,无论该边界是在组件内还是在整体架构模型内。根架构具有由其端口定义的边界。 | |
连接器 | 连接器是提供端口之间连接的线路。连接器描述信息如何在组件或架构之间流动。 | 通过连接器,两个组件可以进行交互,而无需定义交互的性质。在端口上设置接口来定义组件之间的交互方式。 |
术语 | 定义 | 应用 | 更多信息 |
---|---|---|---|
视图 | 视图显示模型中可自定义的元素子集。视图可根据组件、端口和接口的构造型或名称,以及接口元素的名称、类型或单位进行过滤。通过手动添加元素来创建视图。视图通过聚焦于架构设计的某些部分,为处理复杂架构提供了一种简化工作方式。 | 您可以使用不同类型的视图来表示系统。在组件图、组件层次结构或架构层次结构之间切换。软件架构可以切换到类图视图。视点代表利益相关者透视,用于指定视图的内容。 | |
元素组 | 元素组是视图中组件的组合。 | 使用元素组以编程方式填充视图。 | |
查询 | 查询是用来描述模型元素需满足的某些约束或准则的一种规范。 | 使用查询以通过约束准则来搜索元素并过滤视图。 | 使用查询查找模型中的元素 |
组件图 | 组件图根据模型的结构,用组件、端口和连接器来表示视图。 | 组件图允许您以编程方式或手动方式添加和删除视图中的组件。 | 在自定义架构视图中检查组件 |
层次结构图 | 您可以将层次结构图可视化为包含组件、端口、引用类型、组件构造型和构造型属性的视图。 | 组件层次图以树形显示组件,父组件位于子组件之上。在组件层次结构视图中,每个引用模型的使用次数都是一样的。架构层次图使用组合连接显示唯一组件架构类型及其关系。在架构层次视图中,每个引用的模型只表示一次。 | 使用视图显示组件层次结构和架构层次结构 |
版本历史记录
在 R2023a 中推出
另请参阅
工具
对象
函数
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)