comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1 % DOUBLE overloads double() function for timespan objects.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: DOUBLE overloads double() function for timespan objects.
5 % The result is the number of seconds spanned by the object
6 %
7 % CALL: d = double(t);
8 %
9 % <a href="matlab:utils.helper.displayMethodInfo('timespan', 'double')">Parameters Description</a>
10 %
11 % VERSION: $Id: double.m,v 1.7 2011/04/08 08:56:37 hewitson Exp $
12 %
13 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14
15 function varargout = double(varargin)
16
17 % Check if this is a call for parameters
18 if utils.helper.isinfocall(varargin{:})
19 varargout{1} = getInfo(varargin{3});
20 return
21 end
22
23 import utils.const.*
24 utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename);
25
26 % Collect input variable names
27 in_names = cell(size(varargin));
28 for ii = 1:nargin,in_names{ii} = inputname(ii);end
29
30 % Collect all time objects and plists
31 ts = utils.helper.collect_objects(varargin(:), 'timespan', in_names);
32
33 % go through timespan objects
34 td = [];
35 for jj = 1:numel(ts)
36 td(jj) = (ts(jj).endT.utc_epoch_milli - ts(jj).startT.utc_epoch_milli) / 1000.0;
37 end
38
39 % Set output
40 if nargout == numel(ts)
41 % List of outputs
42 for ii = 1:numel(ts)
43 varargout{ii} = td(ii);
44 end
45 else
46 % Single output
47 varargout{1} = td;
48 end
49
50 end
51
52 %--------------------------------------------------------------------------
53 % Get Info Object
54 %--------------------------------------------------------------------------
55 function ii = getInfo(varargin)
56 if nargin == 1 && strcmpi(varargin{1}, 'None')
57 sets = {};
58 pl = [];
59 else
60 sets = {'Default'};
61 pl = getDefaultPlist;
62 end
63 % Build info object
64 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);
65 ii.setModifier(false);
66 ii.setOutmin(0);
67 end
68
69 %--------------------------------------------------------------------------
70 % Get Default Plist
71 %--------------------------------------------------------------------------
72 function plout = getDefaultPlist()
73 persistent pl;
74 if exist('pl', 'var')==0 || isempty(pl)
75 pl = buildplist();
76 end
77 plout = pl;
78 end
79
80 function pl = buildplist()
81 pl = plist.EMPTY_PLIST;
82 end
83