systemcomposer.query.Constraint
Description
The Constraint
object represents all System Composer™ query constraints.
Object Functions
AnyComponent | Create query to select all components in model |
IsStereotypeDerivedFrom | Create query to select stereotype derived from qualified name |
HasStereotype | Create query to select architectural elements with stereotype based on specified subconstraint |
HasPort | Create query to select architectural elements with port based on specified subconstraint |
HasConnector | Create query to select architectural elements with connector based on specified subconstraint |
HasInterface | Create query to select architectural elements with interface on port based on specified subconstraint |
HasInterfaceElement | Create query to select architectural elements with interface element on interface based on specified subconstraint |
IsInRange | Create query to select range of property values |
Property | Create query to select non-evaluated values for object properties or stereotype properties for elements |
PropertyValue | Create query to select property from object or stereotype property and then evaluate property value |
Examples
Find Elements in Model Using Queries
Find components in a System Composer model using queries.
Import the package that contains all of the System Composer queries.
import systemcomposer.query.*
Open the model.
scKeylessEntrySystem
model = systemcomposer.loadModel("KeylessEntryArchitecture");
Find all the software components in the system.
con1 = HasStereotype(Property("Name") == "SoftwareComponent"); [compPaths,compObjs] = model.find(con1)
compPaths = 5x1 cell
{'KeylessEntryArchitecture/Lighting System/Lighting Controller' }
{'KeylessEntryArchitecture/Sound System/Sound Controller' }
{'KeylessEntryArchitecture/Door Lock//Unlock System/Door Lock Controller' }
{'KeylessEntryArchitecture/Engine Control System/Keyless Start Controller'}
{'KeylessEntryArchitecture/FOB Locator System/FOB Locator Module' }
compObjs=1×5 object
1x5 Component array with properties:
IsAdapterComponent
Architecture
ReferenceName
Name
Parent
Ports
OwnedPorts
OwnedArchitecture
Parameters
Position
Model
SimulinkHandle
SimulinkModelHandle
UUID
ExternalUID
Include reference models in the search.
softwareComps = model.find(con1,IncludeReferenceModels=true)
softwareComps = 9x1 cell
{'KeylessEntryArchitecture/Door Lock//Unlock System/Front Pass Door Lock Sensor/Detect Door Lock Status' }
{'KeylessEntryArchitecture/Lighting System/Lighting Controller' }
{'KeylessEntryArchitecture/Sound System/Sound Controller' }
{'KeylessEntryArchitecture/Door Lock//Unlock System/Door Lock Controller' }
{'KeylessEntryArchitecture/Engine Control System/Keyless Start Controller' }
{'KeylessEntryArchitecture/FOB Locator System/FOB Locator Module' }
{'KeylessEntryArchitecture/Door Lock//Unlock System/Front Driver Door Lock Sensor/Detect Door Lock Status'}
{'KeylessEntryArchitecture/Door Lock//Unlock System/Rear Pass Door Lock Sensor/Detect Door Lock Status' }
{'KeylessEntryArchitecture/Door Lock//Unlock System/Rear Driver Door Lock Sensor/Detect Door Lock Status' }
Find all the base components in the system.
con2 = HasStereotype(IsStereotypeDerivedFrom("AutoProfile.BaseComponent"));
baseComps = model.find(con2)
baseComps = 18x1 cell
{'KeylessEntryArchitecture/Lighting System/Lighting Controller' }
{'KeylessEntryArchitecture/Sound System/Sound Controller' }
{'KeylessEntryArchitecture/Door Lock//Unlock System/Door Lock Controller' }
{'KeylessEntryArchitecture/Engine Control System/Keyless Start Controller' }
{'KeylessEntryArchitecture/FOB Locator System/FOB Locator Module' }
{'KeylessEntryArchitecture/Door Lock//Unlock System/Front Driver Door Lock Actuator'}
{'KeylessEntryArchitecture/Sound System/Dashboard Speaker' }
{'KeylessEntryArchitecture/FOB Locator System/Rear Receiver' }
{'KeylessEntryArchitecture/Door Lock//Unlock System/Rear Driver Door Lock Actuator' }
{'KeylessEntryArchitecture/FOB Locator System/Center Receiver' }
{'KeylessEntryArchitecture/Door Lock//Unlock System/Rear Pass Door Lock Actuator' }
{'KeylessEntryArchitecture/Door Lock//Unlock System/Front Driver Door Lock Sensor' }
{'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/Front Pass Door Lock Sensor' }
{'KeylessEntryArchitecture/Door Lock//Unlock System/Rear Pass Door Lock Sensor' }
{'KeylessEntryArchitecture/Engine Control System/Start//Stop Button' }
{'KeylessEntryArchitecture/FOB Locator System/Front Receiver' }
Find all components using the interface KeyFOBPosition
.
con3 = HasPort(HasInterface(Property("Name") == "KeyFOBPosition")); con3_a = HasPort(Property("InterfaceName") == "KeyFOBPosition"); keyFOBPosComps = model.find(con3)
keyFOBPosComps = 10x1 cell
{'KeylessEntryArchitecture/Door Lock//Unlock System' }
{'KeylessEntryArchitecture/Sound System' }
{'KeylessEntryArchitecture/Lighting System' }
{'KeylessEntryArchitecture/Engine Control System' }
{'KeylessEntryArchitecture/FOB Locator System' }
{'KeylessEntryArchitecture/Lighting System/Lighting Controller' }
{'KeylessEntryArchitecture/Sound System/Sound Controller' }
{'KeylessEntryArchitecture/Door Lock//Unlock System/Door Lock Controller' }
{'KeylessEntryArchitecture/Engine Control System/Keyless Start Controller'}
{'KeylessEntryArchitecture/FOB Locator System/FOB Locator Module' }
Find all components whose WCET
is less than or equal to 5 ms
.
con4 = PropertyValue("AutoProfile.SoftwareComponent.WCET") <= 5;
model.find(con4)
ans = 1x1 cell array
{'KeylessEntryArchitecture/Sound System/Sound Controller'}
You can specify units for automatic unit conversion.
con5 = PropertyValue("AutoProfile.SoftwareComponent.WCET") <= Value(5,'ms'); query1Comps = model.find(con5)
query1Comps = 3x1 cell
{'KeylessEntryArchitecture/Sound System/Sound Controller' }
{'KeylessEntryArchitecture/Lighting System/Lighting Controller' }
{'KeylessEntryArchitecture/FOB Locator System/FOB Locator Module'}
Find all components whose WCET
is greater than 1 ms
or that have a cost greater than 10 USD
.
con6 = PropertyValue("AutoProfile.SoftwareComponent.WCET") > Value(1,'ms') | PropertyValue("AutoProfile.Base.Cost") > Value(10,'USD'); query2Comps = model.find(con6)
query2Comps = 2x1 cell
{'KeylessEntryArchitecture/Door Lock//Unlock System/Door Lock Controller' }
{'KeylessEntryArchitecture/Engine Control System/Keyless Start Controller'}
Close the model.
model.close
More About
Definitions
Term | Definition | Application | More Information |
---|---|---|---|
view | A view shows a customizable subset of elements in a model. Views can be filtered based on stereotypes or names of components, ports, and interfaces, along with the name, type, or units of an interface element. Create views by adding elements manually. Views create a simplified way to work with complex architectures by focusing on certain parts of the architectural design. |
You can use different types of views to represent the system. Switch between a component diagram, component hierarchy, or architecture hierarchy. For software architectures, you can switch to a class diagram view. A viewpoint represents a stakeholder perspective that specifies the contents of the view. | Modeling System Architecture of Keyless Entry System |
element group | An element group is a grouping of components in a view. | Use element groups to programmatically populate a view. | |
query | A query is a specification that describes certain constraints or criteria to be satisfied by model elements. | Use queries to search elements with constraint criteria and to filter views. | Find Elements in Model Using Queries |
component diagram | A component diagram represents a view with components, ports, and connectors based on how the model is structured. | Component diagrams allow you to programmatically or manually add and remove components from the view. | Inspect Components in Custom Architecture Views |
hierarchy diagram | You can visualize a hierarchy diagram as a view with components, ports, reference types, component stereotypes, and stereotype properties. |
There are two types of hierarchy diagrams:
| Display Component Hierarchy and Architecture Hierarchy Using Views |
Version History
Introduced in R2019b
See Also
find
| createView
| modifyQuery
| runQuery
| removeQuery
| getQualifiedName
Open Example
You have a modified version of this example. Do you want to open this example with your edits?
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.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)