systemcomposer.query.Constraint
查询约束
说明
Constraint
对象表示所有 System Composer™ 查询约束。
对象函数
AnyComponent | 创建查询以选择模型中的所有组件 |
IsStereotypeDerivedFrom | 创建查询,从限定名称中选择构造型 |
HasStereotype | 创建查询,根据指定的子约束条件选择具有构造型的架构元素 |
HasPort | 创建查询,根据指定的子约束条件选择带端口的架构元素 |
HasConnector | 创建查询,根据指定的子约束条件选择带有连接器的架构元素 |
HasInterface | 创建查询,根据指定的子约束条件选择端口上有接口的架构元素 |
HasInterfaceElement | 创建查询,以便根据指定的子约束条件,在接口上选择带有接口元素的架构元素 |
IsInRange | 创建查询以选择属性值范围 |
Property | 创建查询,为对象属性或元素构造型属性选择未计算值 |
PropertyValue | 创建查询,从对象或构造型属性中选择属性,然后计算属性值 |
示例
使用查询在 System Composer 模型中查找组件。
导入包含所有 System Composer 查询的命名空间。
import systemcomposer.query.*
打开模型。
openProject("scKeylessEntrySystem"); model = systemcomposer.loadModel("KeylessEntryArchitecture");
查找系统中的所有软件组件。
con1 = HasStereotype(Property("Name") == "SoftwareComponent"); [compPaths,compObjs] = model.find(con1)
compPaths = 5×1 cell
{'KeylessEntryArchitecture/Door Lock//Unlock System/Door Lock Controller' }
{'KeylessEntryArchitecture/Sound System/Sound Controller' }
{'KeylessEntryArchitecture/Engine Control System/Keyless Start Controller'}
{'KeylessEntryArchitecture/Lighting System/Lighting Controller' }
{'KeylessEntryArchitecture/FOB Locater System/FOB Locater Module' }
compObjs=1×5 Component array with properties:
IsAdapterComponent
Architecture
ReferenceName
Name
Parent
Ports
OwnedPorts
OwnedArchitecture
Parameters
Position
Model
SimulinkHandle
SimulinkModelHandle
UUID
ExternalUID
在搜索中包括引用模型。
softwareComps = model.find(con1,IncludeReferenceModels=true)
softwareComps = 9×1 cell
{'KeylessEntryArchitecture/Door Lock//Unlock System/Door Lock Controller' }
{'KeylessEntryArchitecture/Sound System/Sound Controller' }
{'KeylessEntryArchitecture/Engine Control System/Keyless Start Controller' }
{'KeylessEntryArchitecture/Lighting System/Lighting Controller' }
{'KeylessEntryArchitecture/FOB Locater System/FOB Locater Module' }
{'KeylessEntryArchitecture/Door Lock//Unlock System/Front Driver Door Lock Sensor/Detect Door Lock Status'}
{'KeylessEntryArchitecture/Door Lock//Unlock System/Rear Driver Door Lock Sensor/Detect Door Lock Status' }
{'KeylessEntryArchitecture/Door Lock//Unlock System/Front Pass Door Lock Sensor/Detect Door Lock Status' }
{'KeylessEntryArchitecture/Door Lock//Unlock System/Rear Pass Door Lock Sensor/Detect Door Lock Status' }
查找系统中的所有基本组件。
con2 = HasStereotype(IsStereotypeDerivedFrom("AutoProfile.BaseComponent"));
baseComps = model.find(con2)
baseComps = 18×1 cell
{'KeylessEntryArchitecture/Door Lock//Unlock System/Door Lock Controller' }
{'KeylessEntryArchitecture/Sound System/Sound Controller' }
{'KeylessEntryArchitecture/Engine Control System/Keyless Start Controller' }
{'KeylessEntryArchitecture/Lighting System/Lighting Controller' }
{'KeylessEntryArchitecture/FOB Locater System/FOB Locater Module' }
{'KeylessEntryArchitecture/Door Lock//Unlock System/Front Pass Door Lock Sensor' }
{'KeylessEntryArchitecture/FOB Locater System/Front Receiver' }
{'KeylessEntryArchitecture/Sound System/Dashboard Speaker' }
{'KeylessEntryArchitecture/Door Lock//Unlock System/Rear Pass Door Lock Sensor' }
{'KeylessEntryArchitecture/Door Lock//Unlock System/Front Driver Door Lock Actuator'}
{'KeylessEntryArchitecture/Door Lock//Unlock System/Front Pass Door Lock Actuator' }
{'KeylessEntryArchitecture/Door Lock//Unlock System/Rear Driver Door Lock Sensor' }
{'KeylessEntryArchitecture/Door Lock//Unlock System/Rear Driver Door Lock Actuator' }
{'KeylessEntryArchitecture/FOB Locater System/Rear Receiver' }
{'KeylessEntryArchitecture/FOB Locater System/Center Receiver' }
{'KeylessEntryArchitecture/Door Lock//Unlock System/Front Driver Door Lock Sensor' }
{'KeylessEntryArchitecture/Door Lock//Unlock System/Rear Pass Door Lock Actuator' }
{'KeylessEntryArchitecture/Engine Control System/Start//Stop Button' }
查找使用接口 KeyFOBPosition
的所有组件。
con3 = HasPort(HasInterface(Property("Name") == "KeyFOBPosition")); con3_a = HasPort(Property("InterfaceName") == "KeyFOBPosition"); keyFOBPosComps = model.find(con3)
keyFOBPosComps = 10×1 cell
{'KeylessEntryArchitecture/Door Lock//Unlock System/Door Lock Controller' }
{'KeylessEntryArchitecture/Sound System/Sound Controller' }
{'KeylessEntryArchitecture/Engine Control System/Keyless Start Controller'}
{'KeylessEntryArchitecture/Lighting System/Lighting Controller' }
{'KeylessEntryArchitecture/FOB Locater System/FOB Locater Module' }
{'KeylessEntryArchitecture/FOB Locater System' }
{'KeylessEntryArchitecture/Door Lock//Unlock System' }
{'KeylessEntryArchitecture/Lighting System' }
{'KeylessEntryArchitecture/Engine Control System' }
{'KeylessEntryArchitecture/Sound System' }
查找 WCET
小于或等于 5 ms
的所有组件。
con4 = PropertyValue("AutoProfile.SoftwareComponent.WCET") <= 5;
model.find(con4)
ans = 1×1 cell array
{'KeylessEntryArchitecture/Sound System/Sound Controller'}
您可以为自动单位转换指定单位。
con5 = PropertyValue("AutoProfile.SoftwareComponent.WCET") <= Value(5,'ms'); query1Comps = model.find(con5)
query1Comps = 3×1 cell
{'KeylessEntryArchitecture/Sound System/Sound Controller' }
{'KeylessEntryArchitecture/Lighting System/Lighting Controller' }
{'KeylessEntryArchitecture/FOB Locater System/FOB Locater Module'}
查找所有 WCET
大于 1 ms
或成本大于 10 USD
的组件。
con6 = PropertyValue("AutoProfile.SoftwareComponent.WCET") > Value(1,'ms') | PropertyValue("AutoProfile.Base.Cost") > Value(10,'USD'); query2Comps = model.find(con6)
query2Comps = 2×1 cell
{'KeylessEntryArchitecture/Door Lock//Unlock System/Door Lock Controller' }
{'KeylessEntryArchitecture/Engine Control System/Keyless Start Controller'}
详细信息
术语 | 定义 | 应用 | 更多信息 |
---|---|---|---|
视图 | 视图显示模型中可自定义的元素子集。视图可根据组件、端口和接口的构造型或名称,以及接口元素的名称、类型或单位进行过滤。通过手动添加元素来创建视图。视图通过聚焦于架构设计的某些部分,为处理复杂架构提供了一种简化工作方式。 | 您可以使用不同类型的视图来表示系统。在组件图、组件层次结构或架构层次结构之间切换。软件架构可以切换到类图视图。视点代表利益相关者透视,用于指定视图的内容。 | |
元素组 | 元素组是视图中组件的组合。 | 使用元素组以编程方式填充视图。 | |
查询 | 查询是用来描述模型元素需满足的某些约束或准则的一种规范。 | 使用查询以通过约束准则来搜索元素并过滤视图。 | 使用查询查找模型中的元素 |
组件图 | 组件图根据模型的结构,用组件、端口和连接器来表示视图。 | 组件图允许您以编程方式或手动方式添加和删除视图中的组件。 | 在自定义架构视图中检查组件 |
层次结构图 | 您可以将层次结构图可视化为包含组件、端口、引用类型、组件构造型和构造型属性的视图。 | 组件层次图以树形显示组件,父组件位于子组件之上。在组件层次结构视图中,每个引用模型的使用次数都是一样的。架构层次图使用组合连接显示唯一组件架构类型及其关系。在架构层次视图中,每个引用的模型只表示一次。 | 使用视图显示组件层次结构和架构层次结构 |
版本历史记录
在 R2019b 中推出
另请参阅
工具
对象
函数
find
|findElementsOfType
|findElementsWithStereotype
|findElementsWithProperty
|findElementsWithInterface
|AnyComponent
|Property
|PropertyValue
|HasStereotype
|IsStereotypeDerivedFrom
|HasPort
|HasConnector
|HasInterface
|HasInterfaceElement
|IsInRange
|createView
|getQualifiedName
|lookup
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)