classdef VerifyCollectHandler < fxptui.Web.CallbackService.IterativeCollectHandler
    % Class to handle the work for Collect Callback in FPT.
    
    % Copyright 2019-2020 The MathWorks, Inc.
    
    properties(Constant)
        ActionID = fxptui.internal.ActionFactory.VerifyID;
    end
    
    methods
        
        function prepare(this, varargin)
            fptInstance = varargin{1};
            workflowSettings = varargin{2};
            clientData = varargin{3};
            
            if isfield(clientData, 'VerifyRunName')
                collectionSettings = this.getCollectionSettings(workflowSettings);
                if isempty(clientData.VerifyRunName)
                    collectionSettings.RunName = collectionSettings.EmbeddedRunName;
                else
                    collectionSettings.RunName = clientData.VerifyRunName;
                end
                
            end
            
            % Disable code-view if present
            fptInstance.enableCodeView(false);
            
            % setting isFPTCallbackSource to true prevents fptoolcallback
            % updatesiglog from updating data before simulation is complete
            fptInstance.isFPTCallbackSource = true;
            
        end
        
    end
    
    methods(Hidden)
        
        function collectionSettings = getCollectionSettings(~, workflowSetting)
            
            % get the DataTypeWorkflow.CollectionSettings from the WorkflowSetting
            collectionSettings = workflowSetting.getSettingValue('VerificationSetting');
            
        end
        
    end
    
end
