main content

system composer report generation for system architectures -凯发k8网页登录

this example shows the different parts of a report generation script for a system composer™ architecture model and its artifacts.

import the relevant packages.

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.

% for pdf: rpt = slreportgen.report.report('outputpath','systemmodel' ".pdf",'compilemodelbeforereporting',false);
% for html: rpt = slreportgen.report.report('type','html-file','outputpath','systemmodel','compilemodelbeforereporting',false);
rpt = slreportgen.report.report('outputpath','systemmodel' ".pdf",'compilemodelbeforereporting',false);

load the model and reference model.

systemcomposer.loadmodel('mtest');
model = systemcomposer.loadmodel("mtestmodel");

append the title page and the table of contents.

add(rpt,titlepage("title",sprintf('%s',model.name)));
add(rpt,tableofcontents);

introduction

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

introduction = chapter("title","introduction");
sec1_1 = section('title',"purpose");
p1 = 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(sec1_1, p1);
sec1_2 = section("scope");
p2 = 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(sec1_2, p2);
append(introduction, sec1_1);
append(introduction, sec1_2);

architectural elements

create a new chapter to represent architectural elements.

architecturalelements = chapter("architecture description");

use the simulink® (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 finder to report on components in the model.

cf = componentfinder(model.name);
cf.query = anycomponent();
comp_finder = find(cf);
for comp = comp_finder
    componentsection = section("title",comp.name);

create a list of components allocated from or to a particular component using the finder.

    d = allocationlistfinder("allocationset.mldatx");
    compobject = lookup(model,'uuid',comp.object);
    d.componentname = getfullname(compobject.simulinkhandle);
    result = find(d);
    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 finder.

allocation_finder = allocationsetfinder("allocationset.mldatx");
allocationchapter = chapter("allocations");
while hasnext(allocation_finder)
    alloc = next(allocation_finder);
    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 finder.

viewchapter = chapter("architecture views");
view_finder = viewfinder(model.name);
while(hasnext(view_finder))
    v = next(view_finder);
    viewname = section('title',v.name);
    append(viewname, v);
    append(viewchapter, viewname);
end

dependency graph

create a chapter to display the dependency graph image using the reporter.

packaging = chapter("packaging");
packaging = section('title','packaging');
graph = systemcomposer.rptgen.report.dependencygraph("source",[model.name '.slx']);
append(packaging, graph);
append(packaging, packaging);

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 finder.

requirementsetsection = section("requirement sets");
reqfinder1 = requirementsetfinder("testrequirement.slreqx");
result = find(reqfinder1);
pp = paragraph("this requirement set describes the system requirements for the mobile robot that are derived from the stakeholder needs to be documented.");
append(requirementsetsection,pp);
append(requirementsetsection,result.getreporter);

requirement link sets

collect the requirement link sets using the finder.

requirementlinksection = section("requirement link sets");
reqlinkfinder = requirementlinkfinder("testrequirement.slmx");
resultl = find(reqlinkfinder);
rptr = systemcomposer.rptgen.report.requirementlink("source",resultl);
append(requirementlinksection,rptr);
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 finder.

df = dictionaryfinder(model.name);
dictionary = find(df);
no dictionaries present in the model
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 finder.

if boolhasnodictionary
    interfacechapter = chapter("interfaces appendix");
    interfacefinder = interfacefinder(model.name);
    interfacefinder.searchin = "model";
    while hasnext(interfacefinder)
        intf = next(interfacefinder);
        interfacename = section(intf.interfacename);
        append(interfacename,intf);
        append(interfacechapter,interfacename);
    end
end

profiles

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

find all the profiles using the finder.

profilechapter = chapter("profiles appendix");
pf = profilefinder("testprofile.xml");
while hasnext(pf)
    intf = next(pf);
    profilename = section(intf.name);
    append(profilename,intf);
    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 finder.

stereotypesection = section("stereotypes");
sf = stereotypefinder("testprofile.xml");
while hasnext(sf)
    stf = next(sf);
    stereotypename = section(stf.name);
    append(stereotypename,stf);
    append(stereotypesection,stereotypename);
end
append(profilechapter, stereotypesection);

final report

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

append(rpt,introduction);
append(rpt,architecturalelements);
append(rpt,viewchapter);
append(rpt,packaging);
append(rpt,allocationchapter);
append(rpt,reqchapter);
append(rpt,interfacechapter);
append(rpt,profilechapter);
rptview(rpt)

related topics

网站地图