主要内容

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

systemcomposer.rptgen.finder.AllocationSetFinder 类

命名空间: systemcomposer.rptgen.finder
超类: mlreportgen.finder.Finder (MATLAB Report Generator)

查找分配集

自 R2022b 起

描述

systemcomposer.rptgen.finder.AllocationSetFinder 类可在 System Composer™ 架构模型中搜索指定分配集的信息。

创建对象

finder = AllocationSetFinder(Container) 创建了一个查找器,用于查找有关分配集的信息。

注意

此查找器提供了以下选项来获取搜索结果:

  • 要将搜索结果作为数组返回,请使用 find 方法。将结果直接添加到报告中或在 for 循环中处理结果。

  • 要逐个迭代结果,请在 while 循环中使用 hasNextnext 方法。

这两个选项在性能上都没有优势。

属性

全部展开

分配指定为字符串的扩展名为 .mldatx 的文件名。

示例: f = AllocationSetFinder("AllocationSet.mldatx")

数据类型: string

要查找对象的属性,指定为此名称-值参量元胞数组。查找器仅返回具有指定属性和指定值的对象。

示例: f.Properties = {'Gain','5'}

数据类型: char

方法

全部展开

示例

全部折叠

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