Main Content

getReporter

Class: systemcomposer.rptgen.finder.AllocationSetResult
Namespace: systemcomposer.rptgen.finder

Get allocation set reporter

Since R2022b

Syntax

reporter = getReporter(result)

Description

reporter = getReporter(result) returns a reporter that you can use to include information about allocation sets in a model. You can use this reporter to customize what information to include and how to format the information. See systemcomposer.rptgen.report.AllocationSet for more information on how to customize the reporter.

Input Arguments

expand all

Allocation set result, specified as a systemcomposer.rptgen.finder.AllocationSetResult object.

Output Arguments

expand all

Allocation set reporter, returned as a systemcomposer.rptgen.report.AllocationSet object.

Examples

expand 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