List execution order sorted by block execution in Simulink
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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?
0 comentarios
Respuestas (1)
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
0 comentarios
Ver también
Categorías
Más información sobre General Applications en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!