www.gusucode.com > mbctools 工具箱 matlab 源码程序 > mbctools/@testplansweepsetfilter/set.m

    function obj = set(obj, Properties, Values)
%SET

%  Copyright 2000-2011 The MathWorks, Inc. and Ford Global Technologies, Inc.


valid_props = {'clusteralg',...
        'label',...
        'defaultselectionapply',...
        'defaultselectionmoredata',...
        'defaultselectionmoredesign',...
        'defaultselectionunmatcheddata'};

% Have we got any properties?
ALLPROPS = nargin < 2;
if ALLPROPS
    obj = valid_props';
    return
end

ISCHAR = ischar(Properties);
if ISCHAR
    Properties = {Properties};
    Values = {Values};
end

for i = 1:length(Properties)
    property = lower(Properties{i});
    mInd = find( strncmp( property,valid_props,length(property) ) );
    if length(mInd) > 1
        error(message('mbc:testplansweepsetfilter:InvalidProperty1', property));
    end
    if isempty(mInd)
        % Try calling the inherited set method
        obj.sweepsetfilter = set(obj.sweepsetfilter, {property}, Values(i));
    else
        switch mInd
            case 1
                % clusteralg
                obj.clusterAlg = Values{i};
            case 2
                % label
                obj = i_setLabel(obj, Values{i});
            case 3
                % defaultselectionapply
                obj.defaultSelection.apply = Values{i};
            case 4
                % defaultselectionmoredata
                if ~ismember(Values{i}, {'all', 'closest'})
                    error(message('mbc:testplansweepsetfilter:InvalidState1'));
                end
                obj.defaultSelection.moredata = Values{i};              
            case 5
                % defaultselectionmoredesign
                if ~ismember(Values{i}, {'none', 'closest'})
                    error(message('mbc:testplansweepsetfilter:InvalidState2'));
                end
                obj.defaultSelection.moredesign = Values{i};
            case 6
                % defaultselectionununmatcheddata
                if ~ismember(Values{i}, {'all', 'none'})
                    error(message('mbc:testplansweepsetfilter:InvalidState3'));
                end
                obj.defaultSelection.unmatcheddata = Values{i};
        end
    end
end


%------------------------------------------------------------------------
%
%------------------------------------------------------------------------
function obj = i_setLabel(obj, newLabel)
% Are the first elements of the name the same as the testplan name
% Get the testplan prefix
testplanPrefix = [name(getTestplan(obj)) ' : '];
lengthPrefix = length(testplanPrefix);
% Is the testplan prefix the beginning of the label
if strncmp(testplanPrefix, newLabel, lengthPrefix)
    newLabel = newLabel(lengthPrefix+1:end);
end
% Do the set
obj.sweepsetfilter = set(obj.sweepsetfilter, 'Label', newLabel);