이 페이지는 기계 번역을 사용하여 번역되었습니다. 영어 원문을 보려면 여기를 클릭하십시오.
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
에 대한 그룹 식별자를 가져옵니다.
입력 인수
mrd
— slmetric.metric.ResultDetail
개체
문자형 벡터
slmetric.Engine.execute
메서드를 호출하면 slmetric.metric.ResultDetail
개체를 포함하는 slmetric.metric.Result
개체가 생성됩니다.
출력 인수
groupIdentifier
— 그룹 식별자
문자형 벡터
slmetric.metric.ResultDetail
개체 그룹의 식별자입니다.
예제
클론 그룹 이름 및 식별자 얻기
클론 그룹의 이름과 식별자를 얻으려면 getGroupName
및 getGroupIdentfier
방법을 사용하십시오.
예제 모델 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 Read 및 Data 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를 참조하세요.
MATLAB 명령
다음 MATLAB 명령에 해당하는 링크를 클릭했습니다.
명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 MATLAB 명령을 지원하지 않습니다.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)