classdef UncertainSpec < modelpack.ParameterSpec
    %modelpack.UncertainSpec class
    %   modelpack.UncertainSpec extends modelpack.ParameterSpec.
    %

    %    modelpack.UncertainSpec properties:
    %       Description - Property is of type 'ustring'
    %       Name - Property is of type 'string'  (read only)
    %       InitialValue - Property is of type 'MATLAB array'
    %       Known - Property is of type 'MATLAB array'
    %       Minimum - Property is of type 'MATLAB array'
    %       Maximum - Property is of type 'MATLAB array'
    %       TypicalValue - Property is of type 'MATLAB array'
    %       EvaluateAllValues - Property is of type 'bool'
    %       EvaluateNominal - Property is of type 'bool'
    %       EvaluateMinMaxOnly - Property is of type 'bool'
    %
    %    modelpack.UncertainSpec methods:
    %       getUncertainValues -  return values of an uncertain parameter spec
    %       setUncertainValues -  sets the uncertain values for a uncertain parameter

    % Copyright 2000-2023 The MathWorks, Inc.

    properties (Access=protected, SetObservable)
        %UNCERTAINVALUES Property is of type 'MATLAB array'
        UncertainValues = [];
    end

    properties (SetObservable)
        %EVALUATEALLVALUES Property is of type 'bool'
        EvaluateAllValues = false;
        %EVALUATENOMINAL Property is of type 'bool'
        EvaluateNominal = false;
        %EVALUATEMINMAXONLY Property is of type 'bool'
        EvaluateMinMaxOnly = false;
    end


    methods  % constructor block
        function this = UncertainSpec(~)
            % UNCERTAINSPEC Constructor for an uncertain parameter spec
            %
            % h = modelpack.UniformParamSpec(parameterID);
            %
            % Inputs:
            %    parameterID a modelpack.ParameterID object.
            %

            error(message('SLControllib:modelpack:errAbstractClass'))
        end  % UncertainSpec

    end  % constructor block

    methods
        function set.EvaluateAllValues(obj,value)
            % DataType = 'bool'
            validateattributes(value,{'numeric','logical'}, {'scalar','nonnan'},'','EvaluateAllValues')
            value = logical(value); %  convert to logical
            obj.EvaluateAllValues = value;
        end

        function set.EvaluateNominal(obj,value)
            % DataType = 'bool'
            validateattributes(value,{'numeric','logical'}, {'scalar','nonnan'},'','EvaluateNominal')
            value = logical(value); %  convert to logical
            obj.EvaluateNominal = value;
        end

        function set.EvaluateMinMaxOnly(obj,value)
            % DataType = 'bool'
            validateattributes(value,{'numeric','logical'}, {'scalar','nonnan'},'','EvaluateMinMaxOnly')
            value = logical(value); %  convert to logical
            obj.EvaluateMinMaxOnly = value;
        end

    end   % set and get functions

    methods  % public methods
        function Values = getUncertainValues(this)
            % GETUNCERTAINVALUES  return values of an uncertain parameter spec
            %

            if this.EvaluateMinMaxOnly
                Values = {this.Minimum; this.Maximum};
            else
                Values = get(this,'UncertainValues');
                Values = vertcat(Values,this.Minimum);
                Values = vertcat(Values,this.Maximum);
            end

        end  % getUncertainValues

        function setUncertainValues(this,varargin)
            % SETUNCERTAINVALUES  sets the uncertain values for a uncertain parameter
            % spec object.
            %
            % Arguments for this method depend on the type of uncertain parameter.
            %

            warning(message('SLControllib:modelpack:warnAbstractMethod',class(this)))
        end  % setUncertainValues

    end  % public methods

end  % classdef

% LocalWords:  UNCERTAINVALUES EVALUATEALLVALUES EVALUATENOMINAL EVALUATEMINMAXONLY
% LocalWords:  GETUNCERTAINVALUES SETUNCERTAINVALUES
