主要内容

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

systemcomposer.rptgen.finder.DictionaryFinder 类

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

查找字典

自 R2022b 起

描述

systemcomposer.rptgen.finder.DictionaryFinder 类可搜索给定 System Composer™ 架构模型中所有字典的信息。

创建对象

finder = DictionaryFinder(Container) 创建一个查找器,在 Type 属性指定的架构模型中查找所有字典,以搜索模型字典或引用字典。

注意

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

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

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

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

属性

全部展开

不带 .slx 扩展名的架构模型文件名,指定为字符串形式。

示例: f = DictionaryFinder("ArchModel")

数据类型: string

用于查找数据字典的过滤器,指定为这些选项之一:

  • "Model" - 在模型中查找字典。

  • "Dictionary" - 查找引用字典。

  • "All" - 查找所有词典,包括模型字典和引用字典。

属性:

GetAccess
public
SetAccess
public

数据类型: string

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

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

数据类型: char

方法

全部展开

示例

全部折叠

使用 DictionaryFinderDictionaryResultInterfaceFinderInterfaceResult 类创建报告,查找给定架构模型中的所有字典和接口。

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

打开 scKeylessEntrySystem 工程。

prj = openProject("scKeylessEntrySystem");
model_name = "KeylessEntryArchitecture";
mdl = systemcomposer.loadModel(model_name);

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

dataReport = slreportgen.report.Report(OutputPath=model_name + "_ArchitectureDataReport", ...
    CompileModelBeforeReporting=false);
append(dataReport,TitlePage(Title="Architectural Data in " + model_name));
append(dataReport,TableOfContents);

创建一个章节,包含与字典有关的所有部分。

dictionaryChapter = Chapter(Title="Dictionaries");

查找与架构模型相关联的所有字典。

dictionaryFinder = DictionaryFinder(model_name);

while hasNext(dictionaryFinder)
    dictionary = next(dictionaryFinder);
    dictionarySection = Section(Title="Dictionary: " + dictionary.Name);
    append(dictionarySection, dictionary);    

在字典中查找所有接口。

    interfaces = dictionary.Interfaces;
    for i=1:length(interfaces)
        interfaceFinder = InterfaceFinder(model_name);
        interfaceFinder.Filter = interfaces(i);
        interface = find(interfaceFinder);

为字典中的每个接口创建一个章节。

        interfaceSection = Section(Title="Interface: " + interface.InterfaceName);
        append(interfaceSection, interface);
        append(dictionarySection, interfaceSection);
    end

    append(dictionaryChapter,dictionarySection);
end

将章节附加到报告中,并查看生成的报告。

append(dataReport,dictionaryChapter);
close(dataReport);
rptview(dataReport);

版本历史记录

在 R2022b 中推出