使用 System Composer 报告 API 为软件架构生成系统架构报告
此示例展示了如何为 System Composer™ 软件架构模型及其工件生成基于报告 API 的架构报告。
此示例中包含的 generateSoftwareArchitectureReport 函数生成包含以下节的报告:
标题页面
目录
包含模型元素的“架构元素”章节
包含接口和元素的“服务接口”章节
包含与模型相关的自定义视图和图的“视图和图”章节
您可以修改 generateSoftwareArchitectureReport.m 文件以创建自定义系统架构设计报告。
generateSoftwareArchitectureReport 函数使用这些报告 API 类中的对象来查找架构设计元素并报告设计情况:
完整的 generateSoftwareArchitectureReport 函数列在本示例末尾。
生成 ACCSoftwareComposition 软件架构的 PDF 系统架构报告
打开 ACCSoftwareComposition 架构模型。
modelName = "ACCSoftwareComposition";
systemcomposer.loadModel(modelName);为 ACCSoftwareComposition 架构模型生成系统架构报告。指定该文件为 PDF 格式。
generateSoftwareArchitectureReport(modelName, "pdf");此函数在工程根文件夹中创建一个名为 ACCSoftwareComposition Architecture Report.pdf 的新文件。
generateSoftwareArchitectureReport 函数
您可以使用 systemcomposer.rptgen 命名空间中的报告器、查找器和结果类来自定义系统架构报告的内容。您可以使用这些对象的属性来过滤和格式化报告的信息。
以下是本示例中包含的 generateSoftwareArchitectureReport 函数。
type generateSoftwareArchitectureReport.mfunction generateArchitectureReport(mdl, doctype)
%GENERATEARCHITECTUREREPORT Generates a system architecture report from the
%architecture model.
%
% generateArchitectureReport() generates a PDF system architecture report
% for the ACCSoftwareComposition software 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 software 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.
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 = "ACCSoftwareComposition";
doctype = "pdf";
end
if nargin < 2
doctype = "pdf";
end
mdlHandle = systemcomposer.loadModel(mdl);
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);
close(rpt);
close_system(mdl);
rptview(rpt);
end
生成 AUTOSAR 软件架构报告
您可以使用此示例中的脚本为 AUTOSAR 架构模型及其工件生成报告。要加载 AUTOSAR 模型,请使用 autosar.arch.loadModel (AUTOSAR Blockset)。检查模型、配置文件、需求和字典文件名是否已根据您的 AUTOSAR 模型更新。有关 AUTOSAR 架构的更多信息,请参阅软件架构建模 (AUTOSAR Blockset)。
另请参阅
工具
类
systemcomposer.rptgen.report.AllocationList|systemcomposer.rptgen.report.AllocationSet|systemcomposer.rptgen.report.Component|systemcomposer.rptgen.report.Connector|systemcomposer.rptgen.report.DependencyGraph|systemcomposer.rptgen.report.Function|systemcomposer.rptgen.report.Interface|systemcomposer.rptgen.report.Profile|systemcomposer.rptgen.report.RequirementLink|systemcomposer.rptgen.report.RequirementSet|systemcomposer.rptgen.report.SequenceDiagram|systemcomposer.rptgen.report.Stereotype|systemcomposer.rptgen.report.View