function runTests(obj,sldvData)
%

%   Copyright 2014-2021 The MathWorks, Inc.
    
    paramNameValStruct = obj.getBaseSimStruct;

    % Caching loggers need to be called after getting compiled info
    obj.cacheExistingLoggers;
    modelToSim = get_param(obj.TopLevelModelH,'Name');
    obj.turnOffAndStoreWarningStatus;
    obj.initForSim;
    
    paramNameValStruct.CovEnable = 'off';
    paramNameValStruct.CovScope = 'EntireSystem';
    if isempty(obj.intervalStartTime) || obj.intervalStartTime == 0
        if obj.recordCoverage
            % This if section will be dead-path for Model Slicer if enhanced
            % coverage is enabled.
            cvto = cvtest(modelToSim);
            cvto.settings.decision = 1;
            cvto.settings.condition = 1;
            % Disable all other metrics for better performance
            cvto.settings.mcdc = 0;
            cvto.settings.tableExec = 0;
            cvto.settings.sigrange = 0;
            cvto.settings.sigsize = 0;
            cvto.settings.designverifier = 0;
            cvto.settings.overflowsaturation = 0;
            cvto.settings.relationalop = 0;
            
            cvto.modelRefSettings.enable = 'all'; % Enable coverage for all referenced models
            cvto.modelRefSettings.excludeTopModel = 0; % Collect coverage for top model.
            cvto.filter = ''; % Disabling coverage filtering
            if ~isempty(obj.intervalStopTime)
                paramNameValStruct.StopTime = num2str(obj.intervalStopTime);
            end

            [~, obj.covData, simOut] = evalc('cvsim(cvto,paramNameValStruct);');
            if obj.intervalStartTime > 0
                evalin('base', ['clear ' tempSimStateName]);
            end
        else
            if ~isempty(obj.intervalStopTime)
            paramNameValStruct.StopTime = num2str(obj.intervalStopTime);
            end
            % g2442205: Disable all coverage related settings
            paramNameValStruct.RecordCoverage = 'off';
            paramNameValStruct.CovModelRefEnable = 'off';
            paramNameValStruct.CovExternalEMLEnable = 'off';
            paramNameValStruct.CovSFcnEnable = 'off';
            [~,simOut] = evalc('sim(modelToSim,paramNameValStruct);');
        end
    else
        simHandler = Coverage.SimulationHandler(obj.TopLevelModelH);
        simHandler.configureModelParameters(paramNameValStruct);
        simHandler.setPauseTime(obj.intervalStartTime);
        simHandler.setStopTime(obj.intervalStopTime);
        if obj.recordCoverage
            simHandler.enableCoverageRecording();
        end
        if isempty(obj.subsystemIO)
            simHandler.initializeStepper;
            Sldv.SubsystemLogger.checkUnsupportedSystem(obj.TestUnitBlockH,false);
            obj.subsystemIO = Sldv.SubsystemLogger.deriveSubsystemPortInfo(obj.TestUnitBlockH);
            sldvData = obj.generateDataForLogging;
        end
        simHandler.run;
        obj.SimState = simHandler.getSimState;
        simHandler.run;
        simOut = simHandler.getSimOut;
        if obj.recordCoverage
            obj.covData =  simHandler.getCoverage();
        end
        delete(simHandler);
    end
    
    sigLogs = simOut.find(paramNameValStruct.SignalLoggingName);
    dsmLogs = simOut.find(paramNameValStruct.DSMLoggingName);
    sldvData.TestCases.dataValues = ...
        obj.deriveFunctionalTestCase(...
        sigLogs,dsmLogs, ...
        1);
    if checkAllSignalEmpty(sldvData)
        error('Sldv:SubsystemLogger:NoSignalLogged',...
            getString(message('Sldv:SubsystemLogger:NoLoggedSignalIs')));
    end
    obj.convertLoggedDataToCellFormat(sldvData);            
end

function tf = checkAllSignalEmpty(sldvData)
    simData = Sldv.DataUtils.getSimData(sldvData);
    tf = true;
    for idx=1:length(simData)
        for jdx=1:simData(idx).dataValues.getLength
            logData = simData(idx).dataValues.getElement(jdx);
            if isa(logData,'timeseries') && ~isempty(logData.Time)
                tf = false;
            end
        end
    end
end
