Main Content

이 페이지는 기계 번역을 사용하여 번역되었습니다. 영어 원문을 보려면 여기를 클릭하십시오.

slmetric.metric.ResultDetail 클래스

네임스페이스: slmetric.metric
슈퍼클래스:

(제거 예정) slmetric.metric.Result 객체의 인스턴스에 대한 세부정보

Metrics Dashboard 사용자 인터페이스, metricdashboard 기능, slmetric 패키지 API 및 해당 사용자 정의는 향후 릴리스에서 제거될 예정입니다. 자세한 내용은 Migrating from Metrics Dashboard to Model Maintainability Dashboard를 참조하세요.

설명

slmetric.metric.Result 개체 속성 Value에 대해 메트릭 엔진이 계산하는 내용에 대한 세부 정보입니다.

생성

slmetric.Engine.execute 메서드를 호출하면 slmetric.metric.Result 개체가 생성되며, 여기에는 선택적으로 slmetric.metric.ResultDetail 개체가 포함됩니다. Details1 = slmetric.metric.ResultDetail = (ID, Name)slmetric.metric.ResultDetail 객체를 생성합니다. 생성자에 대한 입력으로 ID와 이름을 제공해야 합니다.

속성

모두 확장

결과 세부 사항 인스턴스가 계산되는 엔터티의 고유 식별자입니다. 이 속성은 읽기/쓰기입니다.

데이터형: char

세부 인스턴스 수를 계산하는 모델 엔터티의 이름입니다. 이 속성은 읽기/쓰기입니다.

데이터형: char

ID에 대한 지표 알고리즘으로 생성된 스칼라 값입니다. 이 속성은 읽기/쓰기입니다.

데이터형: double

메서드

getGroupIdentifier(제거 예정) slmetric.metric.ResultDetail 객체 그룹의 식별자를 얻습니다.
getGroupName(제거 예정) slmetric.metric.ResultDetail 객체 그룹의 이름 얻기
setGroup(제거 예정) slmetric.metric.ResultDetail 개체 그룹의 이름 및 식별자 설정

예제

모두 축소

클론 그룹의 이름과 식별자를 얻으려면 getGroupNamegetGroupIdentfier 방법을 사용하십시오.

예제 모델을 엽니다.

openExample('slcheck/EnableSubsystemReuseWithCloneExample','supportingfile','ex_clone_detection');

예제 모델을 현재 작업 폴더에 저장합니다.

execute 메서드를 호출합니다. mathworks.metric.CloneDetection 지표에 대해 getMetrics 방법을 적용합니다.

metric_engine = slmetric.Engine();
setAnalysisRoot(metric_engine,'Root','ex_clone_detection','RootType','Model');
execute(metric_engine);
rc = getMetrics(metric_engine,'mathworks.metrics.CloneDetection');

slmetric.metric.Result 개체에 대해 ComponentPath를 표시합니다. 각 slmetric.metric.ResultDetail 객체에 대해 클론 그룹 이름과 식별자를 표시합니다.

for n=1:length(rc.Results)
    if rc.Results(n).Value > 0
	for m=1:length(rc.Results(n).Details)
	  disp(['ComponentPath: ',rc.Results(n).ComponentPath]);
          disp(['Group Name: ',rc.Results(n).Details(m).getGroupName]);
          disp(['Group Identifier: ',rc.Results(n).Details(m).getGroupIdentifier]);
        end
    else
        disp(['No results for ComponentPath: ',rc.Results(n).ComponentPath]);
    end
    disp(' ');
end

결과는 모델에 두 개의 클론이 포함된 하나의 클론 그룹인 CloneGroup1이 포함되어 있음을 보여줍니다.

자세한 결과를 그룹화하려면 setGroup 방법을 사용하세요. 사용자 정의 모델 지표를 생성할 때 이 방법을 algorithm 방법의 일부로 적용합니다.

sldemo_mdlref_dsm 모델을 엽니다.

openExample('sldemo_mdlref_dsm');

createNewMetricClass 함수를 사용하여 DataStoreCount라는 메트릭 클래스를 만듭니다. 이 지표는 Data Store ReadData Store Write 블록 수를 계산하고 해당 데이터 저장소 메모리 블록별로 그룹화합니다. createNewMetricClass 함수는 현재 작업 폴더에 DataStoreCount.m 파일을 생성합니다. 파일에는 생성자와 빈 메트릭 알고리즘 메서드가 포함되어 있습니다. 이 예에서는 쓰기 가능한 폴더에서 작업하고 있는지 확인하십시오.

className = 'DataStoreCount';
slmetric.metric.createNewMetricClass(className);

메트릭 알고리즘을 작성하려면 DataStoreCount.m 파일을 열고 메트릭을 파일에 추가하세요. 이 예에서는 이 논리를 DataStoreCount.m 파일에 복사하여 지표 알고리즘을 생성할 수 있습니다.

classdef DataStoreCount < slmetric.metric.Metric
    % Count the number of Data Store Read and Data Store Write
    % blocks and correlate them across components.
    
    methods
        function this = DataStoreCount()
            this.ID = 'DataStoreCount';
            this.ComponentScope = [Advisor.component.Types.Model, ...
                Advisor.component.Types.SubSystem];
            this.AggregationMode = slmetric.AggregationMode.Sum;
            this.CompileContext = 'None';
            this.Version = 1;
            this.SupportsResultDetails = true;
            
            %Textual information on the metric algorithm
            this.Name = 'Data store usage';
            this.Description = 'Metric that counts the number of Data Store Read and Write'; 
                  'blocks and groups them by the corresponding Data Store Memory block.';
            
        end
        
        function res = algorithm(this, component)
            % Use find_system to get all blocks inside this component.
            dswBlocks = find_system(getPath(component), ...
                'SearchDepth', 1, ...
                'BlockType', 'DataStoreWrite');
            dsrBlocks = find_system(getPath(component), ...
                'SearchDepth', 1, ...
                'BlockType', 'DataStoreRead');          
            
            % Create a ResultDetail object for each data store read and write block.
			% Group ResultDetails by the data store name.
            details1 = slmetric.metric.ResultDetail.empty();
            for i=1:length(dswBlocks)
                details1(i) = slmetric.metric.ResultDetail(getfullname(dswBlocks{i}),...
                            get_param(dswBlocks{i}, 'Name'));
		   groupID = get_param(dswBlocks{i},'DataStoreName');
		   groupName = get_param(dswBlocks{i},'DataStoreName');
                details1(i).setGroup(groupID, groupName);                
                details1(i).Value = 1;
            end
            
            details2 = slmetric.metric.ResultDetail.empty();
            for i=1:length(dsrBlocks)
                details2(i) = slmetric.metric.ResultDetail(getfullname(dsrBlocks{i}),...
                   get_param(dsrBlocks{i}, 'Name'));
                groupID = get_param(dsrBlocks{i},'DataStoreName');
				groupName = get_param(dsrBlocks{i},'DataStoreName');
                details2(i).setGroup(groupID, groupName);
                details2(i).Value = 1;
            end
            
            res = slmetric.metric.Result();
            res.ComponentID = component.ID;
            res.MetricID = this.ID;
            res.Value = length(dswBlocks)+ length(dsrBlocks);
            res.Details = [details1 details2];
        end
    end
end

DataStoreCount 지표 클래스에서 SupportsResultDetail 메서드는 true로 설정됩니다. 메트릭 알고리즘에는 setGroup 방법에 대한 논리가 포함되어 있습니다.

이제 새 모델 메트릭이 DataStoreCount.m에 정의되었으므로 새 메트릭을 등록하십시오.

[id_metric,err_msg] = slmetric.metric.registerMetric(className);

모델에 대한 지표 데이터를 수집하려면 slmetric.Engine의 인스턴스를 사용하십시오. getMetrics 방법을 사용하여 수집하려는 지표를 지정합니다. 이 예에서는 sldemo_mdlref_dsm 모델에 대한 데이터 저장소 수 지표를 지정합니다.

메트릭 엔진 개체를 만들고 분석 루트를 설정합니다.

metric_engine = slmetric.Engine();
setAnalysisRoot(metric_engine,'Root','sldemo_mdlref_dsm',...
'RootType','Model');

데이터 저장소 수 메트릭에 대한 메트릭 데이터를 수집합니다.

execute(metric_engine);
rc=getMetrics(metric_engine, id_metric);

slmetric.metric.Result 개체에 대해 ComponentPath를 표시합니다. 각 slmetric.metric.ResultDetails 개체에 대해 데이터 저장소 그룹 이름과 식별자를 표시합니다.

for n=1:length(rc.Results)
    if rc.Results(n).Value > 0
	for m=1:length(rc.Results(n).Details)
	  disp(['ComponentPath: ',rc.Results(n).ComponentPath]);
          disp(['Group Name: ',rc.Results(n).Details(m).getGroupName]);
          disp(['Group Identifier: ',rc.Results(n).Details(m).getGroupIdentifier]);
        end
    else
        disp(['No results for ComponentPath: ',rc.Results(n).ComponentPath]);
    end
    disp(' ');
end

결과는 다음과 같습니다.

ComponentPath: sldemo_mdlref_dsm
Group Name: ErrorCond
Group Identifier: ErrorCond
 
No results for ComponentPath: sldemo_mdlref_dsm/A
 
No results for ComponentPath: sldemo_mdlref_dsm/A1
 
No results for ComponentPath: sldemo_mdlref_dsm/More Info1
 
ComponentPath: sldemo_mdlref_dsm_bot
Group Name: RefSignalVal
Group Identifier: RefSignalVal
 
ComponentPath: sldemo_mdlref_dsm_bot2
Group Name: ErrorCond
Group Identifier: ErrorCond
 
ComponentPath: sldemo_mdlref_dsm_bot/PositiveSS
Group Name: RefSignalVal
Group Identifier: RefSignalVal
 
ComponentPath: sldemo_mdlref_dsm_bot/NegativeSS
Group Name: RefSignalVal
Group Identifier: RefSignalVal

이 예에서는 데이터 저장소 수 지표를 등록 취소합니다.

slmetric.metric.unregisterMetric(id_metric);

모델을 닫습니다.

bdclose('sldemo_mdlref_dsm');

버전 내역

R2017b에 개발됨

모두 축소

R2022a: Metrics Dashboard이 제거됩니다

Metrics Dashboard 사용자 인터페이스, metricdashboard 기능, slmetric 패키지 API 및 해당 사용자 정의는 향후 릴리스에서 제거될 예정입니다. 자세한 내용은 Migrating from Metrics Dashboard to Model Maintainability Dashboard를 참조하세요.