Сбор и доступ к метрическим данным модели для sldemo_mdlref_basic модели.
Создайте slmetric.Engine объект. Включите модели и библиотеки-ссылки в анализ и установите корень в модели для анализа.
metric_engine = slmetric.Engine();
metric_engine.ModelReferencesSimulationMode = 'AllModes';
metric_engine.AnalyzeLibraries = 1;
setAnalysisRoot(metric_engine, 'Root', 'sldemo_mdlref_basic');
Сбор метрических данных модели
execute(metric_engine, 'mathworks.metrics.ExplicitIOCount');
Получите метрические данные модели, которая возвращает массив slmetric.metric.ResultCollection объекты, res_col.
res_col = getMetrics(metric_engine, 'mathworks.metrics.ExplicitIOCount');
Отображение результатов для mathworks.metrics.ExplicitIOCount метрический.
for n=1:length(res_col)
if res_col(n).Status == 0
result = res_col(n).Results;
for m=1:length(result)
disp(['MetricID: ',result(m).MetricID]);
disp([' ComponentPath: ', result(m).ComponentPath]);
disp([' Value: ', num2str(result(m).Value)]);
disp([' AggregatedValue: ', num2str(result(m).AggregatedValue)]);
disp([' Measures: ', num2str(result(m).Measures)]);
disp([' AggregatedMeasures: ', num2str(result(m).AggregatedMeasures)]);
end
else
disp(['No results for:', result(n).MetricID]);
end
disp(' ');
endВот результаты:
MetricID: mathworks.metrics.ExplicitIOCount
ComponentPath: sldemo_mdlref_basic
Value: 3
AggregatedValue: 4
Measures: 0 3
AggregatedMeasures: 3 3
MetricID: mathworks.metrics.ExplicitIOCount
ComponentPath: sldemo_mdlref_basic/More Info
Value: 0
AggregatedValue: 0
Measures: 0 0
AggregatedMeasures: 0 0
MetricID: mathworks.metrics.ExplicitIOCount
ComponentPath: sldemo_mdlref_counter
Value: 4
AggregatedValue: 4
Measures: 3 1
AggregatedMeasures: 3 1
Для ComponentPath: sldemo_mdlref_basic, значение 3 потому что есть 3 выходы. Три выхода находятся во втором элементе Measures массив. The slmetric.metric.AggregationMode является Max, так что AggregatedValue является 4 которое является количеством входов и выходов для sldemo_mdlref_counter. The AggregratedMeasures массив содержит максимальное количество входов и выходов для компонента или подкомпонента.