Main Content

setResultDetails

結果の詳細をチェック オブジェクトに関連付ける

構文

setResultDetails(ElementResults)

説明

チェック コールバック関数で、setResultDetails(ElementResults) を使用して ElementResults をチェック (CheckObj) に関連付けます。

ElementResultsModelAdvisor.ResultDetail クラスのインスタンスの集合です。

入力引数

ElementResults

ResultDetailObjs オブジェクトの集合

この例では、AdvisorCustomizationExample モデルにおけるチェック [ブロック名がブロックの下になっているかどうかをチェック] の実行に対応する結果の詳細を示します。コードの最後で、CheckObj.setResultDetails(ElementResults); は結果をチェック オブジェクトに関連付けています。詳細については、モデル アドバイザー カスタム構成の作成と展開を参照してください。

% -----------------------------
% This callback function uses the DetailStyle CallbackStyle type. 
% -----------------------------
function DetailStyleCallback(system, CheckObj)
mdladvObj = Simulink.ModelAdvisor.getModelAdvisor(system); % get object

% Find all blocks whose name does not appear below blocks
violationBlks = find_system(system, 'Type','block',...
    'NamePlacement','alternate',...
    'ShowName', 'on');
if isempty(violationBlks)
    ElementResults = ModelAdvisor.ResultDetail;
    ElementResults.IsInformer = true;
    ElementResults.Description = 'Identify blocks where the name is not displayed below the block.';
    ElementResults.Status = 'All blocks have names displayed below the block.';
    mdladvObj.setCheckResultStatus(true);
else
    for i=1:numel(violationBlks)
	 ElementResults(1,i) = ModelAdvisor.ResultDetail;
    end
    for i=1:numel(ElementResults)
        ModelAdvisor.ResultDetail.setData(ElementResults(i), 'SID',violationBlks{i});
        ElementResults(i).Description = 'Identify blocks where the name is not displayed below the block.';
        ElementResults(i).Status = 'The following blocks have names that do not display below the blocks:';
        ElementResults(i).RecAction =  'Change the location such that the block name is below the block.';
    end
    mdladvObj.setCheckResultStatus(false);
    mdladvObj.setActionEnable(true);
end
CheckObj.setResultDetails(ElementResults);
end

バージョン履歴

R2018b で導入