classdef (CaseInsensitiveProperties = true, TruncatedProperties = true) pidtune < ltioptions.Generic
    % Options class for specifying PID design options
    %
    % See also PIDOPTIONS.
    
    %   Author(s): Rong Chen
    %   Copyright 2009-2011 The MathWorks, Inc.
    
    properties (Hidden)
        CrossoverFrequency  = []
    end
    
    properties
        PhaseMargin  = 60
        NumUnstablePoles = 0
        DesignFocus = 'balanced'
    end
    
    methods (Access = protected)
        function cmd = getCommandName(~)
            cmd = 'pidtune';
        end
    end
    
    methods
        
        function this = set.CrossoverFrequency(this,Value)
            if isempty(Value)
                Value = [];
            elseif ~(isnumeric(Value) && isscalar(Value) && ...
                    isreal(Value) && Value>0 && Value<inf)
                error(message('Control:design:pidtune7'))
            end
            this.CrossoverFrequency = double(Value);
        end
        
        function this = set.PhaseMargin(this,Value)
            if ~(isnumeric(Value) && isscalar(Value) && ...
                    isreal(Value) && Value>=0 && Value<=90)
                error(message('Control:design:pidtune8'))
            end
            this.PhaseMargin = double(Value);
        end
        
        function this = set.NumUnstablePoles(this,Value)
            if ~(isnumeric(Value) && isscalar(Value) && isreal(Value) && ...
                    Value>=0 && Value<inf && rem(Value,1)==0)
                error(message('Control:design:pidtune9'))
            end
            this.NumUnstablePoles = double(Value);
        end
        
        function this = set.DesignFocus(this,Value)
            if ~(ischar(Value) || isStringScalar(Value))
                error(message('Control:design:pidtune12'))
            end
            Value = regexprep(Value,'-','');
            N = length(Value);
            trimmedValues = {'referencetracking';'disturbancerejection';'balanced'};
            if ~any(strncmpi(Value,trimmedValues,N))
                error(message('Control:design:pidtune12'))
            end
            validValues = {'reference-tracking';'disturbance-rejection';'balanced'};
            this.DesignFocus = validValues{strncmpi(Value,trimmedValues,N)};
        end
    end
end


