主要内容

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

使用 System Composer 报告 API 生成系统架构报告

自 R2022b 起

此示例展示了如何为 System Composer™ 架构模型及其工件生成基于报告 API 的架构报告。

此示例中包含的 generateArchitectureReport 函数生成包含以下节的报告:

  • 标题页面

  • 目录

  • 包含模型元素的“架构元素”章节

  • 包含系统需求的“需求分析”章节

  • 包含与模型相关的自定义视图和图的“视图和图”章节

您可以修改 generateArchitectureReport.m 文件以创建自定义系统架构设计报告。

generateArchitectureReport 函数使用这些报告 API 类中的对象来查找架构设计元素并报告设计情况:

完整的 generateArchitectureReport 函数列在本示例末尾。

生成 InsulinInfusionPumpSystem 架构的 PDF 系统架构报告

打开 scExampleInsulinPumpSystem 工程。

prj = openProject("scExampleInsulinPumpSystem");
model_name = "InsulinInfusionPumpSystem";

InsulinInfusionPumpSystem 架构模型生成系统架构报告。指定该文件为 PDF 格式。

generateArchitectureReport(model_name, "pdf");

此函数在工程根文件夹中创建一个名为 InsulinInfusionPumpSystem Architecture Report.pdf 的新文件。

generateArchitectureReport 函数

您可以使用 systemcomposer.rptgen 命名空间中的报告器、查找器和结果类来自定义系统架构报告的内容。您可以使用这些对象的属性来过滤和格式化报告的信息。

以下是本示例中包含的 generateArchitectureReport 函数。

type generateArchitectureReport.m
function generateArchitectureReport(mdl, doctype)
%GENERATEARCHITECTUREREPORT Generates a system architecture report from the
%architecture model.
% 
% generateArchitectureReport() generates a PDF system architecture report
% for the InsulinInfusionPumpSystem architecture model.
%
% generateArchitectureReport(mdl) generates a PDF system architecture
% report for the specified model.
%
% generateArchitectureReport(mdl, doctype) generates a system
% architecture report from the specified model and document type: 'html',
% 'docx', or 'pdf'.
%
% The generated document is a description of an architecture's
% design generated from its System Composer architecture model. The
% description contains the following sections:
% 
% * Title Page
% * Table of Contents
% * Architecture Elements Chapter -- Contains each component in the
%   architecture model along with their connectors and each profile in the
%   architecture model along with their stereotypes and properties.
% * Requirements Analysis Chapter -- Contains each requirement set linked
%   in the architecture model along with their implementations.
% * Views and Diagrams Chapter -- Contains each view and sequence diagram
%   in the architecture model.


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

if nargin < 1
    mdl = "InsulinInfusionPumpSystem";
    doctype = "pdf";
end

if nargin < 2
    doctype = "pdf";
end

mdlHandle = systemcomposer.loadModel(mdl);

% Find all file dependencies and create a cell array of file names
files = (dependencies.fileDependencyAnalysis(mdl)');
files = convertCharsToStrings(files);
[path, name, ext] = fileparts(files);
files = name + ext;

% Create a cell array of requirement set file names
boolReqSet = contains(files, ".slreqx");
reqSetFiles = files(boolReqSet);

rptFileName = mdl + " Architecture Report";

rpt = slreportgen.report.Report(OutputPath=rptFileName, ...
    Type=doctype, CompileModelBeforeReporting=false);
open(rpt);

makeTitlePage(rpt, mdlHandle);
append(rpt, TableOfContents);
makeIntroduction(rpt);
makeArchitectureElements(rpt, mdlHandle);
makeRequirementsAnalysis(rpt, reqSetFiles);
makeViewsDiagrams(rpt, mdlHandle);

close(rpt);
close_system(mdl);
rptview(rpt);

end

另请参阅

工具

主题