Mercurial > hg > ltpda
diff m-toolbox/classes/@timespan/double.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/m-toolbox/classes/@timespan/double.m Wed Nov 23 19:22:13 2011 +0100 @@ -0,0 +1,83 @@ +% DOUBLE overloads double() function for timespan objects. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% DESCRIPTION: DOUBLE overloads double() function for timespan objects. +% The result is the number of seconds spanned by the object +% +% CALL: d = double(t); +% +% <a href="matlab:utils.helper.displayMethodInfo('timespan', 'double')">Parameters Description</a> +% +% VERSION: $Id: double.m,v 1.7 2011/04/08 08:56:37 hewitson Exp $ +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function varargout = double(varargin) + + % Check if this is a call for parameters + if utils.helper.isinfocall(varargin{:}) + varargout{1} = getInfo(varargin{3}); + return + end + + import utils.const.* + utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename); + + % Collect input variable names + in_names = cell(size(varargin)); + for ii = 1:nargin,in_names{ii} = inputname(ii);end + + % Collect all time objects and plists + ts = utils.helper.collect_objects(varargin(:), 'timespan', in_names); + + % go through timespan objects + td = []; + for jj = 1:numel(ts) + td(jj) = (ts(jj).endT.utc_epoch_milli - ts(jj).startT.utc_epoch_milli) / 1000.0; + end + + % Set output + if nargout == numel(ts) + % List of outputs + for ii = 1:numel(ts) + varargout{ii} = td(ii); + end + else + % Single output + varargout{1} = td; + end + +end + +%-------------------------------------------------------------------------- +% 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, 'timespan', 'ltpda', utils.const.categories.internal, '$Id: double.m,v 1.7 2011/04/08 08:56:37 hewitson Exp $', sets, pl); + ii.setModifier(false); + ii.setOutmin(0); +end + +%-------------------------------------------------------------------------- +% Get Default Plist +%-------------------------------------------------------------------------- +function plout = getDefaultPlist() + persistent pl; + if exist('pl', 'var')==0 || isempty(pl) + pl = buildplist(); + end + plout = pl; +end + +function pl = buildplist() + pl = plist.EMPTY_PLIST; +end +