Main Content

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

getGroupIdentifier

클래스: slmetric.metric.ResultDetail
네임스페이스: slmetric.metric

(제거 예정) slmetric.metric.ResultDetail 객체 그룹의 식별자를 얻습니다.

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

설명

slmetric.metric.ResultDetail 객체 그룹의 식별자를 얻습니다. execute 메서드를 호출하면 메트릭 데이터가 수집됩니다. getMetrics를 호출하면 slmetric.metric.ResultDetail 개체를 포함하는 slmetric.metric.Result 개체에 액세스합니다. getGroupIdentifier 메서드를 slmetric.metric.ResultDetail 개체에 적용합니다.

예제

groupIdentifier = getGroupIdentifier(mrd)slmetric.metric.ResultDetail 개체 mrd에 대한 그룹 식별자를 가져옵니다.

입력 인수

모두 확장

slmetric.Engine.execute 메서드를 호출하면 slmetric.metric.ResultDetail 개체를 포함하는 slmetric.metric.Result 개체가 생성됩니다.

출력 인수

모두 확장

slmetric.metric.ResultDetail 개체 그룹의 식별자입니다.

예제

모두 확장

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

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

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이 포함되어 있음을 보여줍니다.

모델을 닫습니다.

bdclose('ex_clone_detection');

자세한 결과를 그룹화하려면 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/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를 참조하세요.