このページの内容は最新ではありません。最新版の英語を参照するには、ここをクリックします。
システム アーキテクチャの System Composer レポートの生成
この例では、System Composer™ アーキテクチャ モデルとそのアーティファクトのレポート生成スクリプトのさまざまな部分を示します。
関連する名前空間をインポートします。
import mlreportgen.report.* import slreportgen.report.* import slreportgen.finder.* import mlreportgen.dom.* import mlreportgen.utils.* import systemcomposer.query.* import systemcomposer.rptgen.finder.*
レポートを初期化します。
rpt = slreportgen.report.Report('OutputPath','SystemModel'+".pdf",... 'CompileModelBeforeReporting',false); % for html: rpt = slreportgen.report.Report('Type','html-file',... % 'OutputPath','SystemModel','CompileModelBeforeReporting',false);
モデルと参照モデルを読み込みます。
systemcomposer.loadModel('mTest'); model = systemcomposer.loadModel("mTestModel");
タイトル ページと目次を追加します。
add(rpt,TitlePage("Title",sprintf('%s',model.Name))); add(rpt,TableOfContents);
はじめに
節と段落を追加してレポートにテキストによる情報を追加します。
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);
アーキテクチャ要素
新しい章を作成してアーキテクチャ要素を表現します。
ArchitecturalElements = Chapter("Architecture Description");Simulink® のslreportgen.finder.SystemDiagramFinder (Simulink Report Generator)ファインダーを使用して、レポートにモデルのスナップショットを追加します。
systemContext = Section(model.Name); finder = SystemDiagramFinder(model.Name); finder.SearchDepth = 0; results = find(finder); append(systemContext,results); append(ArchitecturalElements,systemContext);
systemcomposer.rptgen.finder.ComponentFinderファインダーを使用して、モデル内のコンポーネントについてレポートします。
cf = ComponentFinder(model.Name); cf.Query = AnyComponent(); comp_finder = find(cf); for comp = comp_finder componentSection = Section("Title",comp.Name);
systemcomposer.rptgen.finder.AllocationListFinderファインダーを使用して、特定のコンポーネントの割り当て元または割り当て先コンポーネントのリストを作成します。
d = AllocationListFinder("AllocationSet.mldatx"); compObject = lookup(model,'UUID',comp.Object); d.ComponentName = getfullname(compObject.SimulinkHandle); result = find(d); append(componentSection,comp);
レポートにコンポーネント情報を追加します。
append(systemContext,componentSection);
レポートに割り当て情報を追加します。
append(systemContext, result);
end割り当てセット
章を作成して、モデルに関連付けられている割り当てセットについてレポートします。
systemcomposer.rptgen.finder.AllocationSetFinderファインダーを使用して、すべての割り当てセットを検索します。
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
アーキテクチャ ビュー
章を作成して、モデル内のアーキテクチャ ビューに関する情報を表示します。
systemcomposer.rptgen.finder.ViewFinderファインダーを使用して、すべてのビューを検索します。
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
要件解析
モデルに関連付けられているすべての要件セットと要件リンク セットについてレポートします。
ReqChapter = Chapter("Requirements Analysis");要件セット
systemcomposer.rptgen.finder.RequirementSetFinderファインダーを使用して、要件セットを収集します。
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);
要件リンク セット
systemcomposer.rptgen.finder.RequirementLinkFinderファインダーを使用して、要件リンク セットを収集します。
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);
インターフェイス
章を作成して、モデル内のすべてのインターフェイスについてレポートします。
systemcomposer.rptgen.finder.DictionaryFinderファインダーを使用して、モデル内にリンクされているディクショナリがあるかどうかをチェックします。
df = DictionaryFinder(model.Name); dictionary = find(df); boolHasNoDictionary = isempty(dictionary)
boolHasNoDictionary = logical
1
boolHasNoDictionary が true であるため、インターフェイス用に別の章を作成して、systemcomposer.rptgen.finder.InterfaceFinderファインダーを使用してモデルに関連付けられているすべてのインターフェイスについてレポートします。
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
プロファイル
章を作成して、モデル内のすべてのプロファイルについてレポートします。
systemcomposer.rptgen.finder.ProfileFinderファインダーを使用して、すべてのプロファイルを検索します。
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
ステレオタイプ
節を作成して、モデル内のプロファイルにあるすべてのステレオタイプについてレポートします。
systemcomposer.rptgen.finder.StereotypeFinderファインダーを使用して、すべてのステレオタイプを検索します。
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);
最終的なレポート
すべての章を目的の順序でレポートに追加します。
append(rpt,Introduction); append(rpt,ArchitecturalElements); append(rpt,ViewChapter); append(rpt,AllocationChapter); append(rpt,ReqChapter); append(rpt,InterfaceChapter); append(rpt,ProfileChapter); rptview(rpt)
アーキテクチャのレポートの対話的な生成
あるいは、次のコマンドを使用して、アーキテクチャのカスタム レポートを対話的に生成することもできます。
systemcomposer.rptgen.app.launch
参考
クラス
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