Borrar filtros
Borrar filtros

List execution order sorted by block execution in Simulink

8 visualizaciones (últimos 30 días)
Stefan Brunecker
Stefan Brunecker el 27 de Jul. de 2016
Respondida: Jerbin J el 15 de Sept. de 2023
I need to get a list of all blocks in a Simulink model in order in which they are executed. I know I can use slist but the blocks are only ordered within each SubSystem. So if I have two Subsystems A and B with sorted execution order 0:1 and 0:2 then blocks in A might have execution order 2:x and blocks in B 1:x. Then slist lists the blocks in B before A. Now I need a list that orders blocks in A before B. Is that possible?

Respuestas (1)

Jerbin J
Jerbin J el 15 de Sept. de 2023
% Get model name
modelName = bdroot(gcs);
% Empty array for execution order
executionOrder = [];
% Turn off data logging
mdlsignals = find_system(gcs,'FindAll','on','LookUnderMasks','all','FollowLinks','on','type','line','SegmentType','trunk');
portHandle = get_param(mdlsignals,'SrcPortHandle');
for i=1: length(portHandle)
set_param(portHandle{i},'datalogging','off')
end
% Get blocks by execution order
sortedList = get_param(modelName, 'SortedList');
%% Logic
for ii = 1:length(sortedList)
handl = sortedList(ii);
% Get block name
blkName = string(get_param(handl,'Name'));
% Get block type
blkType = get_param(handl,'BlockType');
% Check if block is "Constant"
if strcmp(blkType,'Constant') == 0
% Form the array
executionOrder = [executionOrder;blkName];
end
end

Categorías

Más información sobre Programmatic Model Editing en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by