主要内容

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

find

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

查找有关分配集的信息

自 R2022b 起

语法

result = find(finder)

说明

result = find(finder) 查找 AllocationSet 搜索结果的分配集信息。

输入参数

全部展开

分配集查找器,指定为 systemcomposer.rptgen.finder.AllocationSetFinder 对象。

输出参量

全部展开

分配集结果,以 systemcomposer.rptgen.finder.AllocationSetResult 对象形式返回。

示例

全部展开

使用 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 中推出