Main Content

systemcomposer.rptgen.finder.ComponentFinder Class

Namespace: systemcomposer.rptgen.finder
Superclasses: mlreportgen.finder.Finder (MATLAB Report Generator)

Find components

Since R2022b

Description

The systemcomposer.rptgen.finder.ComponentFinder class searches for information about all the components in a System Composer™ architecture model.

Creation

finder = ComponentFinder(Container) creates a finder that finds all components in a model that meet the Query property.

Note

This finder provides these options to get search results:

  • To return the search results as an array, use the find method. Add the results directly to a report or process the results in a for-loop.

  • To iterate through the results one at a time, use the hasNext and next methods in a while-loop.

Neither option has a performance advantage.

Properties

expand all

Architecture model filename without the .slx extension, specified as a string.

Example: f = ComponentFinder("ArchModel")

Data Types: string

Query to find components, specified as a systemcomposer.query.Constraint object.

Attributes:

GetAccess
public
SetAccess
public

Option to recursively search model or to only search a specific layer, specified as 1 (true) to recursively search or 0 (false). to only search the specific layer.

Attributes:

GetAccess
public
SetAccess
public

Data Types: logical

Option to search for reference architectures, specified as 1 (true) or 0 (false).

Attributes:

GetAccess
public
SetAccess
public

Data Types: logical

Properties of objects to find, specified as a cell array of name-value arguments. The finder returns only objects that have the specified properties with the specified values.

Example: f.Properties = {'Gain','5'}

Data Types: char

Methods

expand all

Examples

collapse all

Use the ComponentFinder, ComponentResult, ConnectorFinder, and ConnectorResult classes to create a report that finds all components and connections in a given architecture model.

import systemcomposer.rptgen.finder.*
import mlreportgen.report.*
import slreportgen.report.*
import systemcomposer.query.*

Open the scKeylessEntrySystem project.

prj_name = "scKeylessEntrySystem";
prj = openProject(prj_name);

Load the KeylessEntryArchitecture architecture model.

model_name = "KeylessEntryArchitecture";
mdl = systemcomposer.loadModel(model_name);

Create a report and append a title page and table of contents.

compReport = slreportgen.report.Report(OutputPath=model_name + "_SystemArchitectureReport.pdf", ...
    CompileModelBeforeReporting=false);
append(compReport,TitlePage(Title="Components and Connectors in " + model_name));
append(compReport,TableOfContents);

Create a chapter to contain all sections related to the components of the architecture model.

componentsChapter = Chapter("Components in " + model_name);

Find all components in the architecture model.

componentFinder = ComponentFinder(model_name);
componentFinder.Query = AnyComponent;

while hasNext(componentFinder)
    componentResult = next(componentFinder);  

Create a section for each component.

    compSection = Section(Title=componentResult.Name);    
    append(compSection,componentResult);

Find all connectors on the component.

    connectorFinder = ConnectorFinder(model_name);
    connectorFinder.ComponentName = componentResult.Name;
    connectorResult = find(connectorFinder);
    for connector = connectorResult
        connectorReporter = getReporter(connector);
        append(compSection,connectorReporter.Source);
    end

    append(componentsChapter,compSection);
end

Append the chapter to the report and view the generated report.

append(compReport,componentsChapter);
close(compReport);
rptview(compReport);

Version History

Introduced in R2022b