Main Content

systemcomposer.rptgen.finder.AllocationSetFinder Class

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

Find allocation sets

Since R2022b

Description

The systemcomposer.rptgen.finder.AllocationSetFinder class searches for information about a given allocation set in a System Composer™ architecture model.

Creation

finder = AllocationSetFinder(Container) creates a finder that finds information about an allocation set.

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

Allocation set filename with the .mldatx extension, specified as a string.

Example: f = AllocationSetFinder("AllocationSet.mldatx")

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 AllocationSetFinder, AllocationSetResult, AllocationListFinder, and AllocationListResult classes to create a report that finds all allocations in a given allocation set.

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

Open the scExampleTirePressureMonitorSystem project.

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

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

allocReport = slreportgen.report.Report(output="AllocationAnalysisReport", ...
    CompileModelBeforeReporting=false);
append(allocReport,TitlePage(Title="Allocation Sets and Lists in " + prj_name + " Project"));
append(allocReport,TableOfContents);

Create a chapter called Allocation Sets and create a section for each allocation set.

allocSetsChapter = Chapter("Allocation Sets");

allocSetFinder = AllocationSetFinder("FunctionalAllocation.mldatx");

while hasNext(allocSetFinder)
    allocationSets = next(allocSetFinder);
    allocSetSection = Section("Allocations in "+ allocationSets.Name);
    append(allocSetSection,allocationSets);
    append(allocSetsChapter,allocSetSection);
end

append(allocReport,allocSetsChapter);
systemcomposer.allocation.AllocationSet.closeAll;

Create a chapter called Allocation Lists, find all components in the TPMS_FunctionalArchitecture model, and create an allocation list section for each component.

allocListChapter = Chapter("Allocation Lists");

arch = "TPMS_FunctionalArchitecture";
mdl = systemcomposer.loadModel(arch);
constraint = systemcomposer.query.AnyComponent;
componentPaths = find(mdl,constraint);

% for each component in the TPMS_FunctionalArchitecture model
for i=1:length(componentPaths)
    % find all components allocated to and from this component
    allocListFinder = AllocationListFinder("FunctionalAllocation.mldatx");
    allocListFinder.ComponentName = string(componentPaths(i));
    allocListSection = Section(allocListFinder.ComponentName);
    
    allocListResult = find(allocListFinder);
    append(allocListSection,allocListResult);
    append(allocListChapter,allocListSection);
end

append(allocReport,allocListChapter);
systemcomposer.allocation.AllocationSet.closeAll;

View the generated report.

close(allocReport);
rptview(allocReport);

Version History

Introduced in R2022b