Main Content

System Composer Report Generation for Software Architectures

This example shows the different parts of a report generation script for a System Composer™ software architecture model and its artifacts.

Import the relevant namespaces.

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

Initialize the report.

rpt = slreportgen.report.Report(OutputPath="SoftwareModel", Type="pdf", ...
    CompileModelBeforeReporting=false);

Load the model and reference model.

systemcomposer.loadModel("mTest.slx");
model = systemcomposer.loadModel("SoftwareModel.slx");

Append the title page and the table of contents.

append(rpt,TitlePage(Title=model.Name));
append(rpt,TableOfContents);

Introduction

Add sections and paragraphs to add textual information to the report.

IntroChapter = Chapter(Title="Introduction");
section1_1 = Section(Title="Purpose");
para1 = Paragraph(['This document provides a comprehensive architectural ...' ...
    'overview of the system using a number of different architecture views...' ...
    ' to depict different aspects of the system. It is intended to capture...' ...
    ' and convey the significant architectural decisions which have been...' ...
    ' made for the system.']);
append(section1_1,para1);

section1_2 = Section("Scope");
para2 = Paragraph(['This System Architecture Description provides an architectural...' ...
    ' overview of the Mobile Robot System being designed and developed by the...' ...
    ' Acme Corporation. The document was generated directly from the Mobile...' ...
    ' Robot models implemented in MATLAB, Simulink and System Composer.']);
append(section1_2, para2);
append(IntroChapter,section1_1);
append(IntroChapter,section1_2);

Architectural Elements

Create a new chapter to represent architectural elements.

ArchitecturalElements = Chapter("Architecture Description");

Use the Simulink® slreportgen.finder.SystemDiagramFinder (Simulink Report Generator) finder to add a snapshot of the model to the report.

systemContext = Section(model.Name);
finder = SystemDiagramFinder(model.Name);
finder.SearchDepth = 0;
results = find(finder);
append(systemContext,results);

append(ArchitecturalElements,systemContext);

Use the systemcomposer.rptgen.finder.ComponentFinder finder to report on components in the model.

compFinder = ComponentFinder(model.Name);
compFinder.Query = AnyComponent();
compResult = find(compFinder);

for comp = compResult
    componentSection = Section(Title=comp.Name);

Create a list of components allocated from or to a particular component using the systemcomposer.rptgen.finder.AllocationListFinder finder.

    allocListFinder = AllocationListFinder("SWArchAllocationSet.mldatx");
    compObject = lookup(model,'UUID',comp.Object);
    allocListFinder.ComponentName = getfullname(compObject.SimulinkHandle);
    result = find(allocListFinder);
    append(componentSection,comp);

Append the component information to the report.

    append(systemContext,componentSection);

Append the allocation information to the report.

    append(systemContext,result);
end

Allocation Sets

Create a chapter to report on the allocation sets associated with the model.

Find all allocation sets using the systemcomposer.rptgen.finder.AllocationSetFinder finder.

allocationFinder = AllocationSetFinder("SWArchAllocationSet.mldatx");
AllocationChapter = Chapter("Allocations");
while hasNext(allocationFinder)
    alloc = next(allocationFinder);
    allocationName = Section(alloc.Name);
    append(allocationName,alloc);
    append(AllocationChapter,allocationName);
end

Architecture Views

Create a chapter to display information about the architecture views in the model.

Find all the views using the systemcomposer.rptgen.finder.ViewFinder finder.

ViewChapter = Chapter("Architecture Views");
viewFinder = ViewFinder(model.Name);
while(hasNext(viewFinder))
    view = next(viewFinder);
    viewName = Section(Title=view.Name);
    append(viewName,view);
    append(ViewChapter,viewName);
end

Profiles

Create a chapter to report on all the profiles in the model.

Find all the profiles using the systemcomposer.rptgen.finder.ProfileFinder finder.

ProfileChapter = Chapter("Profiles Appendix");
profileFinder = ProfileFinder("SWArchProfile.xml");

while hasNext(profileFinder)
    profile = next(profileFinder);
    profileName = Section(profile.Name);
    append(profileName,profile);
    append(ProfileChapter,profileName);
end

Stereotypes

Create a section to report on all the stereotypes in the profiles in the model.

Find all the stereotypes using the systemcomposer.rptgen.finder.StereotypeFinder finder.

StereotypeSection = Section("Stereotypes");
stereotypeFinder = StereotypeFinder('SWArchProfile.xml');
while hasNext(stereotypeFinder)
    stereotype = next(stereotypeFinder);
    stereotypeName = Section(stereotype.Name);
    append(stereotypeName,stereotype);
    append(StereotypeSection, stereotypeName);
end

append(ProfileChapter,StereotypeSection);

Final Report

Add all the chapters to the report in the desired order.

append(rpt,IntroChapter);
append(rpt,ArchitecturalElements);
append(rpt,ViewChapter);
append(rpt,AllocationChapter);
append(rpt,ProfileChapter);

close_system(model.Name);
close(rpt);
rptview(rpt);

Generate Report for AUTOSAR Software Architectures

You can generate a report for an AUTOSAR architecture model and its artifacts using the script in this example. To load an AUTOSAR model, use autosar.arch.loadModel (AUTOSAR Blockset). Check that the model, profile, requirements, and dictionary file names are updated in accordance with your AUTOSAR model. For more information on AUTOSAR architectures, see Software Architecture Modeling (AUTOSAR Blockset).

See Also

Classes

Related Topics