classdef VerificationStatus
    %% VerificationStatus Enumeration of the possible verification statuses
    % Defines the possible statuses created by
    % fxptds.WorkflowTopology.element.AutoscalerDesign and used by
    % DataTypeWorkflow.VerificationResult
    
    %   Copyright 2018-2019 The MathWorks, Inc.
    
    enumeration
        NotApplicable % A verification status is not applicable for the given run
        UnknownBaseline % No connection between baseline for verification run
        NoSignalsLogged % No signals have signal logging on
        UnsetTolerance % Tolerances have not been set
        Verifiable % Intermediate state
        Pass % All signals have passed
        Fail % One or more signals failed
        MergeSimulationWarning % The baseline run is a collection of Merged Runs and cannot be verified
        MisalignedSignalWarning % Signals selected for the baseline do not match that of the verification run
        Null % No status has been set yet
    end
    
    methods
        
        function value = getString(this)
            switch this
                case fxptds.VerificationStatus.Pass
                    value = 'Pass';
                case fxptds.VerificationStatus.Fail
                    value = 'Fail';
                case {fxptds.VerificationStatus.MergeSimulationWarning, ...
                        fxptds.VerificationStatus.MisalignedSignalWarning, ...
                        fxptds.VerificationStatus.UnsetTolerance, ...
                        fxptds.VerificationStatus.NoSignalsLogged, ...
                        fxptds.VerificationStatus.UnknownBaseline
                        }
                    value = 'Warning';
                otherwise
                    value = 'Not Applicable';
            end
        end
        
        function b = isVerfied(this)
            b = (this == fxptds.VerificationStatus.Pass) ...
                || (this == fxptds.VerificationStatus.Fail);
        end
        
    end
    
    methods(Static)
        function status = getDominantStatus(inStatuses)
             % get the ranking of VerificationStatus as rankedStatuses array
            rankedStatuses = fxptds.VerificationStatus.getRanking();
            
            % return the first of the ranked statuses array that was found
            % in the array of statuses
            status = rankedStatuses(find(ismember(rankedStatuses, inStatuses), 1));
        end
    end
    
    methods(Static, Hidden)
        function ranking = getRanking()
            % getRanking returns the ordered list of which status is most
            % dominant
            % to be used for determining of the 2 statuses given (one for
            % each scenario), what would be the representative status for
            % the merged run
            ranking = [ ...
                fxptds.VerificationStatus.NotApplicable, ...
                fxptds.VerificationStatus.UnknownBaseline, ...
                fxptds.VerificationStatus.Verifiable, ... % intermediate status - should not be hit
                fxptds.VerificationStatus.NoSignalsLogged, ...
                fxptds.VerificationStatus.UnsetTolerance, ...
                fxptds.VerificationStatus.MergeSimulationWarning, ...
                fxptds.VerificationStatus.MisalignedSignalWarning, ...
                fxptds.VerificationStatus.Fail, ...
                fxptds.VerificationStatus.Pass, ...
                fxptds.VerificationStatus.Null ...
                ];
            
        end
    end
    
    
end

