view m-toolbox/classes/@ao/setFs.m @ 29:54f14716c721 database-connection-manager

Update Java code
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Mon, 05 Dec 2011 16:20:06 +0100
parents f0afece42f48
children
line wrap: on
line source

% SETFS sets the 'fs' property of the ao.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% DESCRIPTION: SETFS sets the 'fs' property of the ao.
%
% CALL:        objs.setFs(val);
%              objs.setFs(val1, val2);
%              objs.setFs(plist('fs', val));
%              objs = objs.setFs(val);
%
% INPUTS:      objs: Can be a vector, matrix, list, or a mix of them.
%              val:
%                 1. Single value e.g. [2]
%                      Each AO in objs get this value.
%                 2. Single value in a cell-array e.g. {12.1}
%                      Each AO in objs get this value.
%                 3. cell-array with the same number of values as in objs
%                    e.g. {7, 5, 12.2} and 3 AOs in objs
%                      Each AO in objs get its corresponding value from the
%                      cell-array
%
% <a href="matlab:utils.helper.displayMethodInfo('ao', 'setFs')">Parameters Description</a>
%
% VERSION:     $Id: setFs.m,v 1.28 2011/09/16 05:03:06 hewitson Exp $
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


function varargout = setFs(varargin)
  
  % Check if this is a call from a class method
  callerIsMethod = utils.helper.callerIsMethod;
  
  if callerIsMethod
    in_names = {};
  else
    % Collect input variable names
    in_names = cell(size(varargin));
    for ii = 1:nargin,in_names{ii} = inputname(ii);end
  end
  
  objects = setPropertyValue(...
    varargin{:}, ...
    in_names, ...
    callerIsMethod, ...
    'fs', ...
    @setterFcn, ...
    nargout, ...
    @getInfo);
  
  % set outputs
  varargout = utils.helper.setoutputs(nargout, objects);
  
end

% Setter function to set fs
function value = setterFcn(varargin)
  
  if nargin < 3
    error('Please provide a value for the ''fs'' property');
  end
  
  obj   = varargin{1};
  pl    = varargin{2};
  value = varargin{3};
  
  % be careful that the returned value remains an AO!
  if isa(value, 'ao')
    obj.data.setFs(value.fs);
  else
    obj.data.setFs(value);
  end
  
end


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                               Local Functions                               %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%--------------------------------------------------------------------------
% Get Info Object
%--------------------------------------------------------------------------
function ii = getInfo(varargin)
  
  if nargin == 1 && strcmpi(varargin{1}, 'None')
    sets = {};
    pl   = [];
  else
    sets = {'Default'};
    pl   = getDefaultPlist();
  end
  % Build info object
  ii = minfo(mfilename, 'ao', 'ltpda', utils.const.categories.helper, '$Id: setFs.m,v 1.28 2011/09/16 05:03:06 hewitson Exp $', sets, pl);
end

%--------------------------------------------------------------------------
% Get Default Plist
%--------------------------------------------------------------------------
function plout = getDefaultPlist()
  persistent pl;
  if ~exist('pl', 'var') || isempty(pl)
    pl = buildplist();
  end
  plout = pl;
end

function pl = buildplist()
  pl = plist({'fs', 'The sample rate to set.'}, paramValue.DOUBLE_VALUE(NaN));
end