主要内容

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

slreportgen.report.Annotation 类

命名空间: slreportgen.report
超类: slreportgen.report.Reporter

报告 Simulink 注解

自 R2022b 起

描述

使用 slreportgen.report.Annotation 类的对象来报告 Simulink.Annotation 对象。

slreportgen.report.Annotation 类是 handle 类。

类属性

HandleCompatible
true

有关类属性的信息,请参阅类属性

创建对象

描述

rptr = slreportgen.report.Annotation 根据默认模板创建一个空的 Annotation 报告器。在将报告器添加到报告之前,请设置 Object 属性。

rptr = slreportgen.report.Annotation(annotationObj) 创建一个 Annotation 报告器并将 Object 属性设置为 annotationObj

示例

rptr = slreportgen.report.Annotation(Name1=Value1,...,NameN=ValueN) 创建一个 Annotation 报告器并使用名称-值参量设置属性。您可以按任意顺序指定多个名称-值参量。

示例

注意

slreportgen.report.Annotation 报告器无法报告单个图像注解和注解内的方程式。

属性

全部展开

要报告的注解,指定为 Simulink.Annotation 句柄或由 slreportgen.finder.AnnotationFinderslreportgen.finder.DiagramElementFinder 查找器找到的搜索结果对象。

要获取 Simulink.Annotation 对象的句柄,请使用 find_system 函数。例如:

load_system(model_name);
handleArray = find_system(model_name,findall=true,type="annotation");

属性:

GetAccess
公共
SetAccess
公共

此报告器的模板来源,以下列方式之一指定:

  • 字符向量或字符串标量,指定包含此报告器模板的文件的路径

  • 此报告器使用的模板或其模板库中包含此报告器模板的报告器或报告

  • 文档对象模型 (DOM) 文档或文档部分,该报告器使用其模板或其模板库包含该报告器的模板

指定的模板必须与您附加此报告器的报告类型相同。例如,对于 Microsoft® Word 报告,TemplateSrc 必须是 Word 报告模板。如果 TemplateSrc 属性为空,则此报告器将使用默认报告器模板作为报告的输出类型。

属性:

GetAccess
公共
SetAccess
公共
NonCopyable
true

此报告器的模板名称,指定为字符向量或字符串标量。此报告器的模板必须位于此报告器 TemplateSrc 属性所指定模板的模板库中。

属性:

GetAccess
公共
SetAccess
公共

数据类型: char | string

此报告器的超链接目标,指定为指定链接目标 ID 的字符向量或字符串标量,或 mlreportgen.dom.LinkTarget 对象。字符向量或字符串标量值转换为 LinkTarget 对象。链接目标紧接在输出报告中此报告器的内容之前。

属性:

GetAccess
公共
SetAccess
公共

方法

全部展开

示例

全部折叠

此示例显示如何报告 Simulink 注解。

导入这些包,这样您就不必使用长而完全限定的类名。

import slreportgen.finder.*
import slreportgen.report.*
import mlreportgen.report.*

创建 PDF 类型的报告。

rpt = Report("AnnotationReport","pdf");

打开模型。然后创建一个 slreportgen.finder.AnnotationFinder 对象来在模型中搜索 Simulink.Annotation 元素。

model_name = "annotationReporterExampleModel";
open_system(model_name);
annotationFinder = AnnotationFinder(model_name);

使用查找器查找模型中的注解元素。然后创建一个 mlreportgen.report.Chapter 对象,用于在模型中找到的注解。

annotationResults = find(annotationFinder);
annotationChapter = Chapter("Annotations");

遍历结果并为每个结果创建一个 Annotation 报告器,并将该报告器附加到章节中。

for idx = 1:length(annotationResults)
  annotationReporter = Annotation(annotationResults(idx));
  append(annotationChapter,annotationReporter);
end

将该章节附加到报告中。

append(rpt,annotationChapter);

关闭报告和模型,然后查看报告。

close(rpt);
close_system(model_name);
rptview(rpt);

版本历史记录

在 R2022b 中推出