SETXUNITS sets the 'xunits' property of the ao. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: SETXUNITS sets the 'xunits' property of the ao. CALL: ao = setXunits(ao, val) obj = obj.setXunits(plist('xunits', 'sec'); M-FILE INFO: Get information about this methods by calling >> ao.getInfo('setXunits') Get information about a specified set-plist by calling: >> ao.getInfo('setXunits', 'None') VERSION: $Id: setXunits.m,v 1.9 2008/09/05 14:15:33 hewitson Exp $ HISTORY: 31-01-2007 M Hewitson Creation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 % SETXUNITS sets the 'xunits' property of the ao. 0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0003 % 0004 % DESCRIPTION: SETXUNITS sets the 'xunits' property of the ao. 0005 % 0006 % CALL: ao = setXunits(ao, val) 0007 % obj = obj.setXunits(plist('xunits', 'sec'); 0008 % 0009 % M-FILE INFO: Get information about this methods by calling 0010 % >> ao.getInfo('setXunits') 0011 % 0012 % Get information about a specified set-plist by calling: 0013 % >> ao.getInfo('setXunits', 'None') 0014 % 0015 % VERSION: $Id: setXunits.m,v 1.9 2008/09/05 14:15:33 hewitson Exp $ 0016 % 0017 % HISTORY: 31-01-2007 M Hewitson 0018 % Creation 0019 % 0020 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0021 0022 function varargout = setXunits(varargin) 0023 0024 %%% Check if this is a call for parameters 0025 if utils.helper.isinfocall(varargin{:}) 0026 varargout{1} = getInfo(varargin{3}); 0027 return 0028 end 0029 0030 %%% Internal call: Only one object + don't look for a plist 0031 if strcmp(varargin{end}, 'internal') 0032 0033 %%% decide whether we modify the first object, or create a new one. 0034 varargin{1} = copy(varargin{1}, nargout); 0035 0036 varargin{1}.data.setXunits(varargin{2}); 0037 varargout{1} = varargin{1}; 0038 return 0039 end 0040 0041 import utils.const.* 0042 utils.helper.msg(msg.MNAME, 'running %s/%s', mfilename('class'), mfilename); 0043 0044 % Collect input variable names 0045 in_names = cell(size(varargin)); 0046 for ii = 1:nargin,in_names{ii} = inputname(ii);end 0047 0048 % Collect all AOs 0049 [as, ao_invars,rest] = utils.helper.collect_objects(varargin(:), 'ao', in_names); 0050 [pls, invars, rest] = utils.helper.collect_objects(rest(:), 'plist'); 0051 0052 %%% If pls contains only one plist with the only key 'xunits' then set the 0053 %%% property with a plist. 0054 if length(pls) == 1 && isa(pls, 'plist') && nparams(pls) == 1 && isparam(pls, 'xunits') 0055 rest{1} = find(pls, 'xunits'); 0056 end 0057 0058 if numel(rest) ~= 1 0059 error('### Please specify a value for xunits, either in a plist or directly.'); 0060 end 0061 0062 %%% Combine plists 0063 if isempty(pls) 0064 pls = plist('xunits', rest{1}); 0065 else 0066 pls = pls.combine(plist('xunits', rest{1})); 0067 end 0068 0069 % Decide on a deep copy or a modify 0070 bs = copy(as, nargout); 0071 0072 % Loop over AOs 0073 for j=1:numel(bs) 0074 bs(j).data.setXunits(rest{1}); 0075 bs(j).addHistory(getInfo, pls, ao_invars(j), bs(j).hist); 0076 end 0077 0078 if nargout > 0 0079 varargout{1} = bs; 0080 end 0081 end 0082 0083 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0084 % Local Functions % 0085 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0086 %-------------------------------------------------------------------------- 0087 % Get Info Object 0088 %-------------------------------------------------------------------------- 0089 function ii = getInfo(varargin) 0090 0091 if nargin == 1 && strcmpi(varargin{1}, 'None') 0092 sets = {}; 0093 pl = []; 0094 else 0095 sets = {'Default'}; 0096 pl = getDefaultPlist; 0097 end 0098 % Build info object 0099 ii = minfo(mfilename, 'ao', '', utils.const.categories.helper, '$Id: setXunits.m,v 1.9 2008/09/05 14:15:33 hewitson Exp $', sets, pl); 0100 end 0101 0102 %-------------------------------------------------------------------------- 0103 % Get Default Plist 0104 %-------------------------------------------------------------------------- 0105 function pl = getDefaultPlist() 0106 pl = plist('xunits', unit); 0107 end 0108