メインコンテンツ

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)
    % Get the Model Advisor object.
    mdladvObj = Simulink.ModelAdvisor.getModelAdvisor(system); 

    % Find the blocks whose names do not appear below the block.
    violationBlks = find_system(system, 'Type', 'block', ...
        'NamePlacement', 'alternate', ...
        'ShowName', 'on');
    
    if isempty(violationBlks)
        ElementResults = ModelAdvisor.ResultDetail;
        ElementResults.ViolationType = 'info';
        ElementResults.Description = 'Identify blocks where the name is not displayed below the block.';
        ElementResults.Status = 'All blocks have names displayed below the block.';
        
        % Disable action since no violations are found
        mdladvObj.setActionEnable(false);
    else
        ElementResults = ModelAdvisor.ResultDetail.empty;
        for i = 1:numel(violationBlks)
            ElementResults(i) = ModelAdvisor.ResultDetail;
            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 block:';
            ElementResults(i).RecAction = 'Change the location such that the block name is below the block.';
        end
        
        % Enable action since violations are found
        mdladvObj.setActionEnable(true);
    end
    
    CheckObj.setResultDetails(ElementResults);
end

バージョン履歴

R2018b で導入