主要内容

本页采用了机器翻译。点击此处可查看英文原文。

getReporter

类: systemcomposer.rptgen.finder.AllocationSetResult
命名空间: systemcomposer.rptgen.finder

获取分配集报告器

自 R2022b 起

语法

reporter = getReporter(result)

说明

reporter = getReporter(result) 返回一个报告器,您可以用它在模型中包含有关分配集的信息。您可以使用该报告器自定义包含哪些信息以及信息格式。有关如何自定义报告器的更多信息,请参阅 systemcomposer.rptgen.report.AllocationSet

输入参数

全部展开

分配集结果,指定为 systemcomposer.rptgen.finder.AllocationSetResult 对象。

输出参量

全部展开

分配集报告器,以 systemcomposer.rptgen.report.AllocationSet 对象的形式返回。

示例

全部展开

使用 AllocationSetFinderAllocationSetResultAllocationListFinderAllocationListResult 类创建报告,查找给定分配集中的所有分配。

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

打开 scExampleTirePressureMonitorSystem 工程。

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

创建一个报告,并追加标题页和目录。

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

创建名为 Allocation Sets 的章节,并为每个分配集创建一个部分。

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;

创建名为 Allocation Lists 的章节,找到 TPMS_FunctionalArchitecture 模型中的所有组件,并为每个组件创建一个分配列表部分。

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;

查看生成的报告。

close(allocReport);
rptview(allocReport);

版本历史记录

在 R2022b 中推出