Main Content

systemcomposer.rptgen.finder.FunctionFinder Class

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

Find function objects

Since R2022b

Description

The systemcomposer.rptgen.finder.FunctionFinder class searches for information about all the functions in a given System Composer™ software architecture model.

Creation

finder = FunctionFinder(Container) creates a finder that finds all functions in a software architecture model. You can specify the functions to find using the Properties 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 = FunctionFinder("ArchModel")

Data Types: string

Component to find functions in, specified as a string of the full path.

Example: f.ComponentName = "mTestModel/Component1"

Attributes:

GetAccess
public
SetAccess
public

Data Types: string

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, FunctionFinder, and FunctionResult classes to generate a report that finds all components and their functions in a given software architecture model..

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

Open the ACCSoftwareComposition model.

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

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

functionsReport = slreportgen.report.Report(OutputPath=model_name + "_FunctionsReport", ...
    CompileModelBeforeReporting=false);
append(functionsReport,TitlePage(Title="Components and their Functions in " + model_name));
append(functionsReport,TableOfContents);

Create a chapter to contain all sections related to components and their functions.

compChapter = Chapter("Components and their Functions");

Find all components in the architecture model.

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

Create a section for each component.

while hasNext(componentFinder)
    comp = next(componentFinder);
    compSection = Section(Title=comp.Name);
    compReporter = getReporter(comp);
    compReporter.IncludeSnapshot = 1;
    compReporter.IncludeProperties = 0;
    compReporter.IncludeFunctions = 0;
    append(compSection,compReporter);

Find all functions associated with the component.

    functionFinder = FunctionFinder(model_name);
    functionFinder.ComponentName = comp.Name;
    functionResult = find(functionFinder);
    append(compSection,functionResult);

    append(compChapter,compSection);
end

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

append(functionsReport,compChapter);
close(functionsReport);
rptview(functionsReport);

Version History

Introduced in R2022b