function execTime = dspSimulateDataflowExample(modelName, param, value)
% Run Simulation for modelName with StopTime set to stopTime and return the
% execution time for the model. Execution time does not include time take
% for model update and model terminate.
% Example: simulateExample('familyRadioService', 'StopTime', '100');

%   Copyright 2016-2018 The MathWorks, Inc.

scope_blocks = find_system(bdroot, 'BlockType', 'SpectrumAnalyzer');
commentBlocks(scope_blocks);
closeScopes(scope_blocks);
scope_blocks = find_system(bdroot, 'BlockType', 'ArrayPlot');
commentBlocks(scope_blocks);
closeScopes(scope_blocks);
audio_sinks = find_system(bdroot, 'LookUnderMasks', 'on', ...
                        'ReferenceBlock', 'dspsnks4/Audio Device Writer');
commentBlocks(audio_sinks);

tSim = sim(modelName, param, value);
execTime = tSim.getSimulationMetadata.TimingInfo.ExecutionElapsedWallTime;

end
%--------------------------------------------------------------------------
function commentBlocks(blocks)
    for ii=1:numel(blocks)
        set_param(blocks{ii}, 'Commented', 'on');
    end
end
%--------------------------------------------------------------------------
function closeScopes(blocks)
    for ii=1:numel(blocks)
        close_system(blocks{ii});
    end
end
