'outdated' property of slmetric.m​etric.Resu​ltCollecti​on not showing true even though model is changed

1 次查看(过去 30 天)
I want to execute the model metric programmatically only if there is change in the model. I am using 'outdated' property of slmetric.metric.ResultCollection to read the information.As per documentation ,outdated property of slmetric.metric.ResultCollection returns true if there is a model change. But its not happening.
I am follwing the below sequence of operation.
  • metric_engine = slmetric.Engine();
  • setAnalysisRoot(metric_engine,'Root',<model_name>,'RootType', 'Model');
  • execute(metric_engine)
2)did some modification in the model manullly(removed some blocks)
3)res_col = getMetrics(metric_engine, 'mathworks.metrics.SimulinkBlockCount');
my expectation is res_col.Outdated should return true as there are model changes after the metrics execution.But its returining false always
Please let me know how to execute the model metric programmatically only if there is change in the mode?

回答(1 个)

Aneela
Aneela 2024-10-10
Hi Abina Ansary,
You should call “execute” after any changes to a metric to ensure that the status of “outdated” property is updated for previously collected metrics.
Refer to the below example:
metric_engine = slmetric.Engine();
setAnalysisRoot(metric_engine,'Root','MySimpleModel','RootType', 'Model');
execute(metric_engine, 'mathworks.metrics.SimulinkBlockCount')
res_col = getMetrics(metric_engine, 'mathworks.metrics.SimulinkBlockCount');
res_col.Outdated ;
% modify the model and save
execute(metric_engine, 'mathworks.metrics.FileCount');
%get block count results and see Outdated == true
res_col = getMetrics(metric_engine, 'mathworks.metrics.SimulinkBlockCount');
res_col.Outdated ;

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by