이 페이지는 기계 번역을 사용하여 번역되었습니다. 최신 내용을 영문으로 보려면 여기를 클릭하십시오.
setGroup
클래스: slmetric.metric.ResultDetail
네임스페이스: slmetric.metric
(제거 예정) slmetric.metric.ResultDetail 개체 그룹의 이름 및 식별자 설정
Metrics Dashboard 사용자 인터페이스, metricdashboard 기능, slmetric 패키지 API 및 해당 사용자 정의는 향후 릴리스에서 제거될 예정입니다. 자세한 내용은 Migrating from Metrics Dashboard to Model Maintainability Dashboard를 참조하세요.
설명
사용자 정의 작성된 지표의 경우 slmetric.metric.ResultDetail 개체 그룹의 식별자와 이름을 설정합니다. getMetrics 개체에 대한 세부 정보를 지정하는 메트릭 알고리즘 부분 내에서 이 방법을 적용합니다.
setGroup(은 groupIdentifier,groupName)slmetric.metric.ResultDetail 개체에 대한 그룹 이름 및 식별자 값을 설정합니다.
입력 인수
slmetric.metric.ResultDetail 객체 그룹의 식별자 값을 지정합니다.
slmetric.metric.ResultDetail 객체 그룹의 이름 값을 지정합니다.
예제
자세한 결과를 그룹화하려면 setGroup 방법을 사용하세요. 사용자 정의 모델 지표를 생성할 때 이 방법을 algorithm 방법의 일부로 적용합니다.
모델에 대한 지표 데이터를 수집하려면 slmetric.Engine의 인스턴스를 사용하십시오. getMetrics 방법을 사용하여 수집하려는 지표를 지정합니다. 이 예에서는 sldemo_mdlref_dsm 모델에 대한 데이터 저장소 수 지표를 지정합니다.
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);
메트릭 엔진 개체를 만들고 분석 루트를 설정합니다.
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에 개발됨Metrics Dashboard 사용자 인터페이스, metricdashboard 기능, slmetric 패키지 API 및 해당 사용자 정의는 향후 릴리스에서 제거될 예정입니다. 자세한 내용은 Migrating from Metrics Dashboard to Model Maintainability Dashboard를 참조하세요.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- 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)