setSeparators
(削除予定) メトリクス ダッシュボードのグループの辺にラインを指定する
メトリクス ダッシュボード ユーザー インターフェイス、関数 metricdashboard、slmetric パッケージ API、および対応するカスタマイズは将来のリリースで削除される予定です。詳細については、Migrating from Metrics Dashboard to Model Maintainability Dashboardを参照してください。
説明
setSeparators( は、S)slmetric.dashboard.Group オブジェクトの辺にラインを配置するかどうかを指定します。
入力引数
入力は、以下のフィールドで構成されている構造体配列です。
S.topS.bottomS.leftS.right
各フィールドは 1 または 0 に設定する必要があります。値 1 は、グループのその辺にラインを配置することを示します。値 0 は、グループのその辺にラインを配置しないことを示します。画面サイズが変更されてもグループの辺が常に同じままになるように指定するために、1 つの構造体を渡すことができます。4 つの構造体を渡すと、画面の幅のサイズの変更に伴って、グループの辺の区切りが別のものになる可能性があることが指定されます。setWidths メソッドを使用して、最大 4 つの異なる幅を指定します。
データ型: char
例
非バーチャル ブロック数をカウントするカスタム メトリクスを作成します。このメトリクスをメトリクス ダッシュボードに表示するウィジェットを指定します。それをサイズ グループに追加します。
以下を入力してモデル vdp を開きます。
openExample('simulink_general/VanDerPolOscillatorExample')カスタム メトリクス クラスを作成します。
className = 'nonvirtualblockcount';
slmetric.metric.createNewMetricClass(className);
以下のコードを nonvirtualblockcount.m ファイルに追加して、非バーチャル ブロックをカウントするメトリクスを作成します。
classdef nonvirtualblockcount < slmetric.metric.Metric %nonvirtualblockcount calculates number of nonvirtual blocks per level. % BusCreator, BusSelector and BusAssign are treated as nonvirtual. properties VirtualBlockTypes = {'Demux','From','Goto','Ground', ... 'GotoTagVisibility','Mux','SignalSpecification', ... 'Terminator','Inport'}; end methods function this = nonvirtualblockcount() this.ID = 'nonvirtualblockcount'; this.Name = 'Nonvirtual Block Count'; this.Version = 1; this.CompileContext = 'None'; this.Description = 'Algorithm that counts nonvirtual blocks per level.'; this.ComponentScope = [Advisor.component.Types.Model, ... Advisor.component.Types.SubSystem]; this.AggregationMode = slmetric.AggregationMode.Sum; this.ResultChecksumCoverage = true; this.SupportsResultDetails = true; end function res = algorithm(this, component) % create a result object for this component res = slmetric.metric.Result(); % set the component and metric ID res.ComponentID = component.ID; res.MetricID = this.ID; % Practice D1=slmetric.metric.ResultDetail('identifier 1','Name 1'); D1.Value=0; D1.setGroup('Group1','Group1Name'); D2=slmetric.metric.ResultDetail('identifier 2','Name 2'); D2.Value=1; D2.setGroup('Group1','Group1Name'); % use find_system to get all blocks inside this component blocks = find_system(getPath(component), ... 'SearchDepth', 1, ... 'Type', 'Block'); isNonVirtual = true(size(blocks)); for n=1:length(blocks) blockType = get_param(blocks{n}, 'BlockType'); if any(strcmp(this.VirtualBlockTypes, blockType)) isNonVirtual(n) = false; else switch blockType case 'SubSystem' % Virtual unless the block is conditionally executed % or the Treat as atomic unit check box is selected. if strcmp(get_param(blocks{n}, 'IsSubSystemVirtual'), ... 'on') isNonVirtual(n) = false; end case 'Outport' % Outport: Virtual when the block resides within % SubSystem block (conditional or not), and % does not reside in the root (top-level) Simulink window. if component.Type ~= Advisor.component.Types.Model isNonVirtual(n) = false; end case 'Selector' % Virtual only when Number of input dimensions % specifies 1 and Index Option specifies Select % all, Index vector (dialog), or Starting index (dialog). nod = get_param(blocks{n}, 'NumberOfDimensions'); ios = get_param(blocks{n}, 'IndexOptionArray'); ios_settings = {'Assign all', 'Index vector (dialog)', ... 'Starting index (dialog)'}; if nod == 1 && any(strcmp(ios_settings, ios)) isNonVirtual(n) = false; end case 'Trigger' % Virtual when the output port is not present. if strcmp(get_param(blocks{n}, 'ShowOutputPort'), 'off') isNonVirtual(n) = false; end case 'Enable' % Virtual unless connected directly to an Outport block. isNonVirtual(n) = false; if strcmp(get_param(blocks{n}, 'ShowOutputPort'), 'on') pc = get_param(blocks{n}, 'PortConnectivity'); if ~isempty(pc.DstBlock) && ... strcmp(get_param(pc.DstBlock, 'BlockType'), ... 'Outport') isNonVirtual(n) = true; end end end end end blocks = blocks(isNonVirtual); res.Value = length(blocks); end end end
この新しいメトリクスをメトリクス リポジトリに登録します。
[id_metric,err_msg] = slmetric.metric.registerMetric(className);
まず、メトリクス ダッシュボード レイアウトの既定の構成を開きます。
conf = slmetric.dashboard.Configuration.open();
slmetric.dashboard.Layout オブジェクトを slmetric.dashboard.Configuration オブジェクトから取得します。
layout = getDashboardLayout(conf);
レイアウト オブジェクト内のウィジェット オブジェクトを取得します。
layoutWidget = getWidgets(layout);
Simulink ブロックをカウントするメトリクスを表現するウィジェットを削除します。
sizeGroup = layoutWidget(2); sizeGroupWidgets = sizeGroup.getWidgets(); sizeGroup.removeWidget(sizeGroupWidgets(1));
非バーチャル ブロックをカウントするメトリクスを表示するウィジェットを追加します。カスタム ウィジェットの場合、既定の可視化タイプは単一値です。これ以外の可視化手法を使用する場合、VisualizationType プロパティに別の値を指定してください。
newWidget = sizeGroup.addWidget('Custom', 1); newWidget.Title = ('Nonvirtual Block Count'); newWidget.setMetricIDs('nonvirtualblockcount'); newWidget.setWidths(slmetric.dashboard.Width.Medium); newWidget.setHeight(70);
グループ内でカスタム ウィジェットと他のウィジェットを区切るラインを表示するかどうかを指定します。次のコマンドは、ウィジェットの右側にラインが表示されることを指定します。
s.top = false; s.bottom = false; s.left = false; s.right = true; newWidget.setSeparators([s, s, s, s]);
構成オブジェクトを保存します。以下のコマンドは、API 情報を XML ファイルにシリアル化します。
save(conf,'Filename','DashboardConfig.xml');
アクティブな構成を設定します。
slmetric.dashboard.setActiveConfiguration(fullfile(pwd,'DashboardConfig.xml'));モデル vdp のメトリクス ダッシュボードを開きます。
metricsdashboard vdp[すべてのメトリクス] ボタンをクリックしてすべてのメトリクスを実行します。
バージョン履歴
R2018b で導入メトリクス ダッシュボード ユーザー インターフェイス、関数 metricdashboard、slmetric パッケージ API、および対応するカスタマイズは将来のリリースで削除される予定です。詳細については、Migrating from Metrics Dashboard to Model Maintainability Dashboardを参照してください。
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)