Generate System Architecture Reports with System Composer Report API
This example shows how to generate a Report API-based architecture report for a System Composer™ architecture model and its artifacts.
The generateArchitectureReport
function, which is included with this example, generates a report that includes these sections:
Title Page
Table of Contents
Architecture Elements chapter that contains the model elements
Requirements Analysis chapter that contains the system requirements
Views and Diagrams chapter that contains custom views and diagrams associated with the model
You can modify the generateArchitectureReport.m
file to create a custom system architecture design report.
The generateArchitectureReport
function uses objects of these Report API classes to find architecture design elements and report on the design:
slreportgen.report.Report
(Simulink Report Generator)
The complete generateArchitectureReport
function is listed at the end of this example.
Generate PDF System Architecture Report for InsulinInfusionPumpSystem
Architecture
Open the scExampleInsulinPumpSystem
project.
prj = openProject("scExampleInsulinPumpSystem"); model_name = "InsulinInfusionPumpSystem";
Generate a system architecture report for the InsulinInfusionPumpSystem
architecture model. Specify that the document is a PDF.
generateArchitectureReport(model_name, "pdf");
This function creates a new file named InsulinInfusionPumpSystem Architecture Report.pdf
in the project root folder.
The generateArchitectureReport
Function
You can use reporter, finder, and result classes from the systemcomposer.rptgen
namespace to customize the contents of your system architecture report. You can use the properties of these objects to filter and format the information that is reported.
Here is the generateArchitectureReport
function included in this example.
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
See Also
Tools
Classes
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