このページの内容は最新ではありません。最新版の英語を参照するには、ここをクリックします。
algorithm
クラス: slmetric.metric.Metric
名前空間: slmetric.metric
(削除予定) メトリクス データ解析のロジックの指定
メトリクス ダッシュボード ユーザー インターフェイス、関数 metricdashboard
、slmetric
パッケージ API、および対応するカスタマイズは将来のリリースで削除される予定です。詳細については、Migrating from Metrics Dashboard to Model Maintainability Dashboardを参照してください。
説明
入力引数
新規メトリクスのために定義するモデル メトリクス クラス。
メトリクス解析用の Advisor.component.Component
のインスタンス。
出力引数
アルゴリズム データ。slmetric.metric.Result
オブジェクトの配列として返されます。
例
この例では、algorithm
メソッドを使用して、非バーチャル ブロックをカウントするメトリクスを作成する方法を説明します。
関数 createNewMetricClass
を使用して、nonvirtualblockcount
という名前のメトリクス クラスを作成します。この関数は、nonvirtualblockcount.m
ファイルを現在の作業フォルダー内に作成します。
className = 'nonvirtualblockcount';
slmetric.metric.createNewMetricClass(className);
メトリクス アルゴリズム ファイル nonvirtualblockcount.m
を開いて、編集します。このファイルには、空のメトリクス アルゴリズム メソッドが含まれています。
edit(className);
以下のコードをコピーして、nonvirtualblockcount.m
ファイルに貼り付けます。nonvirtualblockcount.m
を保存します。コードは、非バーチャル ブロックをカウントするためのメトリクス アルゴリズムを提供します。
classdef nonvirtualblockcount < slmetric.metric.Metric % nonvirtualblockcount calculate number of non-virtual blocks per level. % BusCreator, BusSelector and BusAssign are treated as non-virtual. properties VirtualBlockTypes = {'Demux','From','Goto','Ground', ... 'GotoTagVisibility','Mux','SignalSpecification', ... 'Terminator','Inport'}; end methods function this = nonvirtualblockcount() this.ID = 'nonvirtualblockcount'; 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]; 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; % use find_system to get all blocks inside this component blocks = find_system(getComponentSource(component), ... 'FollowLinks','on', 'SearchDepth', 1, ... 'Type', 'Block', ... 'FollowLinks', 'On'); 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 % any 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
バージョン履歴
R2016a で導入メトリクス ダッシュボード ユーザー インターフェイス、関数 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)