Main Content

systemcomposer.query.Constraint

R2026b

Query constraint

    Description

    The Constraint object represents all System Composer™ query constraints.

    Object Functions

    AnyComponentCreate query to select all components in model
    IsStereotypeDerivedFromCreate query to select stereotype derived from qualified name
    HasStereotypeCreate query to select architectural elements with stereotype based on specified subconstraint
    HasPortCreate query to select architectural elements with port based on specified subconstraint
    HasConnectorCreate query to select architectural elements with connector based on specified subconstraint
    HasInterfaceCreate query to select architectural elements with interface on port based on specified subconstraint
    HasInterfaceElementCreate query to select architectural elements with interface element on interface based on specified subconstraint
    IsInRangeCreate query to select range of property values
    PropertyCreate query to select non-evaluated values for object properties or stereotype properties for elements
    PropertyValueCreate query to select property from object or stereotype property and then evaluate property value

    Examples

    collapse all

    Find components in a System Composer model using queries.

    Import the namespace that contains all of the System Composer queries.

    import systemcomposer.query.*

    Open the model.

    openProject("scKeylessEntrySystem");
    model = systemcomposer.loadModel("KeylessEntryArchitecture");

    Find all the software components in the system.

    con1 = HasStereotype(Property("Name") == "SoftwareComponent");
    [compPaths,compObjs] = model.find(con1)
    compPaths = 5×1 cell
        {'KeylessEntryArchitecture/Engine Control System/Keyless Start Controller'}
        {'KeylessEntryArchitecture/Sound System/Sound Controller'                 }
        {'KeylessEntryArchitecture/FOB Locater System/FOB Locater Module'         }
        {'KeylessEntryArchitecture/Door Lock//Unlock System/Door Lock Controller' }
        {'KeylessEntryArchitecture/Lighting System/Lighting Controller'           }
    
    
    compObjs = 1×5 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 = 9×1 cell
        {'KeylessEntryArchitecture/Engine Control System/Keyless Start Controller'                                }
        {'KeylessEntryArchitecture/Sound System/Sound Controller'                                                 }
        {'KeylessEntryArchitecture/FOB Locater System/FOB Locater Module'                                         }
        {'KeylessEntryArchitecture/Door Lock//Unlock System/Door Lock Controller'                                 }
        {'KeylessEntryArchitecture/Lighting System/Lighting Controller'                                           }
        {'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' }
        {'KeylessEntryArchitecture/Door Lock//Unlock System/Front Pass Door Lock Sensor/Detect Door Lock Status'  }
        {'KeylessEntryArchitecture/Door Lock//Unlock System/Front 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 = 18×1 cell
        {'KeylessEntryArchitecture/Engine Control System/Keyless Start Controller'          }
        {'KeylessEntryArchitecture/Sound System/Sound Controller'                           }
        {'KeylessEntryArchitecture/FOB Locater System/FOB Locater Module'                   }
        {'KeylessEntryArchitecture/Door Lock//Unlock System/Door Lock Controller'           }
        {'KeylessEntryArchitecture/Lighting System/Lighting Controller'                     }
        {'KeylessEntryArchitecture/FOB Locater System/Center Receiver'                      }
        {'KeylessEntryArchitecture/Door Lock//Unlock System/Front Pass Door Lock Sensor'    }
        {'KeylessEntryArchitecture/Sound System/Dashboard Speaker'                          }
        {'KeylessEntryArchitecture/Door Lock//Unlock System/Front Driver Door Lock Actuator'}
        {'KeylessEntryArchitecture/Engine Control System/Start//Stop Button'                }
        {'KeylessEntryArchitecture/FOB Locater System/Front Receiver'                       }
        {'KeylessEntryArchitecture/FOB Locater System/Rear Receiver'                        }
        {'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/Rear Pass Door Lock Sensor'     }
        {'KeylessEntryArchitecture/Door Lock//Unlock System/Rear Driver Door Lock Actuator' }
        {'KeylessEntryArchitecture/Door Lock//Unlock System/Rear Pass Door Lock Actuator'   }
    
    

    Find all components using the interface KeyFOBPosition.

    con3 = HasPort(HasInterface(Property("Name") == "KeyFOBPosition"));
    con3_a = HasPort(Property("InterfaceName") == "KeyFOBPosition");
    keyFOBPosComps = model.find(con3)
    keyFOBPosComps = 10×1 cell
        {'KeylessEntryArchitecture/Engine Control System/Keyless Start Controller'}
        {'KeylessEntryArchitecture/Sound System/Sound Controller'                 }
        {'KeylessEntryArchitecture/FOB Locater System/FOB Locater Module'         }
        {'KeylessEntryArchitecture/Door Lock//Unlock System/Door Lock Controller' }
        {'KeylessEntryArchitecture/Lighting System/Lighting Controller'           }
        {'KeylessEntryArchitecture/Engine Control System'                         }
        {'KeylessEntryArchitecture/Lighting System'                               }
        {'KeylessEntryArchitecture/Door Lock//Unlock System'                      }
        {'KeylessEntryArchitecture/Sound System'                                  }
        {'KeylessEntryArchitecture/FOB Locater System'                            }
    
    

    Find all components whose WCET is less than or equal to 5 ms.

    con4 = PropertyValue("AutoProfile.SoftwareComponent.WCET") <= 5;
    model.find(con4)
    ans = 1×1 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 = 3×1 cell
        {'KeylessEntryArchitecture/Sound System/Sound Controller'        }
        {'KeylessEntryArchitecture/FOB Locater System/FOB Locater Module'}
        {'KeylessEntryArchitecture/Lighting System/Lighting Controller'  }
    
    

    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 = 2×1 cell
        {'KeylessEntryArchitecture/Engine Control System/Keyless Start Controller'}
        {'KeylessEntryArchitecture/Door Lock//Unlock System/Door Lock Controller' }
    
    

    More About

    expand all

    Version History

    Introduced in R2019b