主要内容

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

systemcomposer.rptgen.finder.FunctionFinder 类

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

查找函数对象

自 R2022b 起

描述

systemcomposer.rptgen.finder.FunctionFinder 类可搜索给定 System Composer™ 软件架构模型中的所有函数信息。

创建对象

finder = FunctionFinder(Container) 创建了一个查找器,用于查找软件架构模型中的所有函数。您可以使用 Properties 属性指定要查找的函数。

注意

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

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

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

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

属性

全部展开

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

示例: f = FunctionFinder("ArchModel")

数据类型: string

要在其中查找函数的组件,指定为完整路径字符串。

示例: f.ComponentName = "mTestModel/Component1"

属性:

GetAccess
public
SetAccess
public

数据类型: string

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

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

数据类型: char

方法

全部展开

示例

全部折叠

使用 ComponentFinderComponentResultFunctionFinderFunctionResult 类生成报告,查找给定软件架构模型中的所有组件及其函数。

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

打开 ACCSoftwareComposition 模型。

model_name = "ACCSoftwareComposition";
mdl = systemcomposer.loadModel(model_name);

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

functionsReport = slreportgen.report.Report(OutputPath=model_name + "_FunctionsReport", ...
    CompileModelBeforeReporting=false);
append(functionsReport,TitlePage(Title="Components and their Functions in " + model_name));
append(functionsReport,TableOfContents);

创建一个章节,包含与组件及其函数相关的所有节。

compChapter = Chapter("Components and their Functions");

查找架构模型中的所有组件。

componentFinder = ComponentFinder(model_name);
componentFinder.Query = AnyComponent;

为每个组件创建一个章节。

while hasNext(componentFinder)
    comp = next(componentFinder);
    compSection = Section(Title=comp.Name);
    compReporter = getReporter(comp);
    compReporter.IncludeSnapshot = 1;
    compReporter.IncludeProperties = 0;
    compReporter.IncludeFunctions = 0;
    append(compSection,compReporter);

查找与组件相关的所有函数。

    functionFinder = FunctionFinder(model_name);
    functionFinder.ComponentName = comp.Name;
    functionResult = find(functionFinder);
    append(compSection,functionResult);

    append(compChapter,compSection);
end

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

append(functionsReport,compChapter);
close(functionsReport);
rptview(functionsReport);

版本历史记录

在 R2022b 中推出