Main Content

hasNext

Class: systemcomposer.rptgen.finder.ComponentFinder
Namespace: systemcomposer.rptgen.finder

Determine if component search result queue is nonempty

Since R2022b

Syntax

nonempty = hasNext(finder)

Description

nonempty = hasNext(finder) determines whether the Component search result queue is nonempty.

Input Arguments

expand all

Component finder, specified as a systemcomposer.rptgen.finder.ComponentFinder object.

Output Arguments

expand all

Whether queue is nonempty, returned as 1 (true) or 0 (false).

Data Types: logical

Examples

expand 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