System Composer Report Generation for System Architectures
This example shows the different parts of a report generation script for a System Composer™ 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="SystemModel", Type="pdf", ... CompileModelBeforeReporting=false); open(rpt);
Load the model and reference model.
systemcomposer.loadModel("mTest.slx"); model = systemcomposer.loadModel("mTestModel.slx");
Append the title page and the table of contents.
append(rpt,TitlePage(Title=model.Name)); append(rpt,TableOfContents);
Introduction
Append sections and paragraphs to append 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(Title="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 append 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.
cf = ComponentFinder(model.Name);
cf.Query = AnyComponent();
compFinder = find(cf);
for comp = compFinder
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("AllocationSet.mldatx"); compObject = lookup(model,'UUID',comp.Object); allocListFinder.ComponentName = getfullname(compObject.SimulinkHandle); reqSetResult = find(allocListFinder); append(componentSection,comp);
Append the component information to the report.
append(systemContext,componentSection);
Append the allocation information to the report.
append(systemContext, reqSetResult);
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("AllocationSet.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
Requirements Analysis
Report on all the requirement sets and requirement link sets associated with the model.
ReqChapter = Chapter("Requirements Analysis");
Requirement Sets
Collect the requirement sets using the systemcomposer.rptgen.finder.RequirementSetFinder
finder.
RequirementSetSection = Section("Requirement Sets"); reqSetFinder = RequirementSetFinder("TestRequirement.slreqx"); reqSetResult = find(reqSetFinder); reqPara = Paragraph(['This requirement set describes the system requirements for the' ... ' mobile robot that are derived from the stakeholder needs to be documented.']); append(RequirementSetSection,reqPara); append(RequirementSetSection,reqSetResult.getReporter);
Requirement Link Sets
Collect the requirement link sets using the systemcomposer.rptgen.finder.RequirementLinkFinder
finder.
RequirementLinkSection = Section("Requirement Link Sets"); reqLinkFinder = RequirementLinkFinder("TestRequirement.slmx"); reqLinkResult = find(reqLinkFinder); reqLinkReporter = systemcomposer.rptgen.report.RequirementLink(Source=reqLinkResult); append(RequirementLinkSection,reqLinkReporter); append(ReqChapter,RequirementSetSection); append(ReqChapter,RequirementLinkSection);
Interfaces
Create a chapter to report on all the interfaces in the model.
Check if any dictionaries are linked within the model using the systemcomposer.rptgen.finder.DictionaryFinder
finder.
dictionaryFinder = DictionaryFinder(model.Name); dictionary = find(dictionaryFinder); boolHasNoDictionary = isempty(dictionary)
boolHasNoDictionary = logical
1
Since boolHasNoDictionary
is true
, create a separate chapter for interfaces to report on all the interfaces associated with the model using the systemcomposer.rptgen.finder.InterfaceFinder
finder.
if boolHasNoDictionary InterfaceChapter = Chapter("Interfaces Appendix"); interfaceFinder = InterfaceFinder(model.Name); interfaceFinder.SearchIn = "Model"; while hasNext(interfaceFinder) interface = next(interfaceFinder); interfaceName = Section(interface.InterfaceName); append(interfaceName,interface); append(InterfaceChapter,interfaceName); end 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("TestProfile.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("TestProfile.xml"); while hasNext(stereotypeFinder) stereotype = next(stereotypeFinder); stereotypeName = Section(stereotype.Name); append(stereotypeName,stereotype); append(StereotypeSection,stereotypeName); end append(ProfileChapter, StereotypeSection);
Final Report
Append all the chapters to the report in the desired order.
append(rpt,IntroChapter); append(rpt,ArchitecturalElements); append(rpt,ViewChapter); append(rpt,AllocationChapter); append(rpt,ReqChapter); append(rpt,InterfaceChapter); append(rpt,ProfileChapter); close_system(model.Name); close(rpt); rptview(rpt);
See Also
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