function [simOut, isMultiSim] = simulate(this, runName)
    % SIMULATE Prepares model for simulation, simulates via the Converter and handles errors
    
    % Copyright 2017-2019 The MathWorks, Inc.
    
    % FPT only currently handles normal mode
    this.AccelModeHandler.switchToNormalMode;
    
    % Disable code-view if present
    this.FPTInstance.enableCodeView(false);
    
    % setting isFPTCallbackSource to true prevents fptoolcallback
    % updatesiglog from updating data before simulation is complete
    this.FPTInstance.isFPTCallbackSource = true;
    
    try
        [simOut, isMultiSim] = this.executeSimulation(runName);
        
        % Enable code view
        this.FPTInstance.setupCodeView;
        
        % Add data to Spreadsheet, Visualizer
        % g1979913 - send all data to FPT client including each scenario,
        % not just the last simulated run
        % if simOut contains more than one Simulink.SimulationOutput then
        % we need to update the entire FPT spreadsheet, otherwise just
        % append the last run
        % TODO: g1968642 - improve performance by updateData on only the
        % new runs scenarios rather than all data
        if isMultiSim
            facade = this.DataLayer.getWorkflowTopologyFacade(this.Converter.TopModel);
            [~, runID] = this.DataLayer.getIdFromRunName(this.Converter.TopModel, this.Converter.CurrentRunName);
            scenarioIDs = facade.query(runID, 'search', 'parents', 'type', 'Collection');
            scenarioNames = this.DataLayer.getRunNameFromID(this.Converter.TopModel, str2double(scenarioIDs));
            runsToUpdate = [{this.Converter.CurrentRunName}, scenarioNames];
            this.FPTInstance.updateData('append', runsToUpdate);
        else
            this.FPTInstance.updateData('append');
        end
        
        % Stop the spinner
        ed = fxptui.FPTEventDispatcher.getInstance;
        ed.broadcastEvent('DataUpdated',fxptui.UIEventData('done'));
        
        % This callback is invoked only after InspectLoggedSignals
        % has been processed in
        % DefaultSimulationExecutionInstance.cpp. We will restore
        % the settings here with the assumption that all data has
        % been added.
        this.FPTInstance.notify('SimulationDataCompleteEvent');
        
        this.cleanupAfterSimulation;
        
    catch e
        % g1714662
        % Restore the DTO/MMO/Run name settings on the model. DTO might not be
        % restored successfully when the model is still being compiled or when
        % simulation is running. Restore DTO settings once the compilation is finished.
        this.FPTInstance.restoreSystemSettings;
        
        % Refresh the Simulation Inputs list on the client
        % g1986262
        this.resetSimulationInputsList();
        
        this.cleanupAfterSimulation;
        
        % g1993741 - refresh RunBrowser after failed callback
        this.refreshRunBrowser();
        
        % g1783351 - clear the spinner when simulation errors out
        this.FPTInstance.reEnableUI('');
        
        % Throw diagnostic with simulation error
        fxptui.showdialog('simulationerror', e);
    end
    
end
