Home > classes > @time > time.m

time

PURPOSE ^

TIME time object class constructor.

SYNOPSIS ^

function varargout = time(varargin)

DESCRIPTION ^

 TIME time object class constructor.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION:  TIME time object class constructor.
               Create a time object.

 PROPERTIES:   utc_epoch_milli  - Unix epoch time of the utc time.
               timezone         - Timezone of the date/time
               timeformat       - Matlab timeformat of the date/time
               time_str         - Time string of the unix time in the specified
                                  timezone.

 CONSTRUCTORS: t1 = time()
               t1 = time('t0_default')
               t1 = time('2007-06-06 14:00:05')
               t1 = time(1186135200000)
               t1 = time('14:00:00', 'HH:MM:SS')
               t1 = time('14:00:00',  31)               31 --> MATLAB format Nr.
               t1 = time('T1: 14:00:00', 'T1: HH:MM:SS')
               t1 = time(plist)

 Parameter sets for plist constructor (in order of priority):

 From XML File
 -------------

   Construct an TIME by loading it from an XML file.

   'filename' - construct an TIME from a filename.
                Example: plist('filename', 't1.xml')
                [default: empty string]


 From MAT File
 -------------

   Construct an TIME by loading it from a MAT file.

   'filename' - construct an TIME from a filename.
                Example: plist('filename', 't1.mat')
                [default: empty string]


 From Repository
 ---------------

   Construct an TIME by retrieving it from an LTPDA repository.

   'Hostname' - the repository hostname. Only those objects which
                are TIMEs are returned.
                [default: 'localhost'];

                Additional parameters:

                'Database'   - The database name [default: 'ltpda']
                'ID'         - A vector of object IDs. [default: []]


 From Time Definition
 --------------------
   Construct an TIME by its properties definition
   'utc_epoch_milli' - the time in milliseconds [default: 0];

                Additional parameters:

                'timezone'   - Timezone (string or java object) [default: 'UTC']
                'timeformat' - Time format (string) [default: 'yyyy-mm-dd HH:MM:SS.FFF']%

 From Time String
 --------------------
   Construct an TIME by its properties definition
   'time_str'        - the time string [default: '1970-01-01 00:00:00.000'];

                Additional parameters:

                'timezone'   - Timezone (string or java object) [default: 'UTC']
                'timeformat' - Time format (string) [default: 'yyyy-mm-dd HH:MM:SS.FFF']


 From Plist
 ----------

   'Plist'    - construct from a plist. The value passed should be a plist
                object.
                [default: empty plist]

 VERSION:      $Id: time.html,v 1.12 2008/03/31 10:27:40 hewitson Exp $

 HISTORY:      23-07-2007 Diepholz
                  Creation

 The following call returns a parameter list object that contains the
 default parameter values:

 >> pl = time(time,'Params')

 The following call returns a string that contains the routine CVS version:

 >> version = time(time,'Version')

 The following call returns a string that contains the routine category:

 >> category = time(time,'Category')

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function varargout = time(varargin)
0002 % TIME time object class constructor.
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION:  TIME time object class constructor.
0007 %               Create a time object.
0008 %
0009 % PROPERTIES:   utc_epoch_milli  - Unix epoch time of the utc time.
0010 %               timezone         - Timezone of the date/time
0011 %               timeformat       - Matlab timeformat of the date/time
0012 %               time_str         - Time string of the unix time in the specified
0013 %                                  timezone.
0014 %
0015 % CONSTRUCTORS: t1 = time()
0016 %               t1 = time('t0_default')
0017 %               t1 = time('2007-06-06 14:00:05')
0018 %               t1 = time(1186135200000)
0019 %               t1 = time('14:00:00', 'HH:MM:SS')
0020 %               t1 = time('14:00:00',  31)               31 --> MATLAB format Nr.
0021 %               t1 = time('T1: 14:00:00', 'T1: HH:MM:SS')
0022 %               t1 = time(plist)
0023 %
0024 % Parameter sets for plist constructor (in order of priority):
0025 %
0026 % From XML File
0027 % -------------
0028 %
0029 %   Construct an TIME by loading it from an XML file.
0030 %
0031 %   'filename' - construct an TIME from a filename.
0032 %                Example: plist('filename', 't1.xml')
0033 %                [default: empty string]
0034 %
0035 %
0036 % From MAT File
0037 % -------------
0038 %
0039 %   Construct an TIME by loading it from a MAT file.
0040 %
0041 %   'filename' - construct an TIME from a filename.
0042 %                Example: plist('filename', 't1.mat')
0043 %                [default: empty string]
0044 %
0045 %
0046 % From Repository
0047 % ---------------
0048 %
0049 %   Construct an TIME by retrieving it from an LTPDA repository.
0050 %
0051 %   'Hostname' - the repository hostname. Only those objects which
0052 %                are TIMEs are returned.
0053 %                [default: 'localhost'];
0054 %
0055 %                Additional parameters:
0056 %
0057 %                'Database'   - The database name [default: 'ltpda']
0058 %                'ID'         - A vector of object IDs. [default: []]
0059 %
0060 %
0061 % From Time Definition
0062 % --------------------
0063 %   Construct an TIME by its properties definition
0064 %   'utc_epoch_milli' - the time in milliseconds [default: 0];
0065 %
0066 %                Additional parameters:
0067 %
0068 %                'timezone'   - Timezone (string or java object) [default: 'UTC']
0069 %                'timeformat' - Time format (string) [default: 'yyyy-mm-dd HH:MM:SS.FFF']%
0070 %
0071 % From Time String
0072 % --------------------
0073 %   Construct an TIME by its properties definition
0074 %   'time_str'        - the time string [default: '1970-01-01 00:00:00.000'];
0075 %
0076 %                Additional parameters:
0077 %
0078 %                'timezone'   - Timezone (string or java object) [default: 'UTC']
0079 %                'timeformat' - Time format (string) [default: 'yyyy-mm-dd HH:MM:SS.FFF']
0080 %
0081 %
0082 % From Plist
0083 % ----------
0084 %
0085 %   'Plist'    - construct from a plist. The value passed should be a plist
0086 %                object.
0087 %                [default: empty plist]
0088 %
0089 % VERSION:      $Id: time.html,v 1.12 2008/03/31 10:27:40 hewitson Exp $
0090 %
0091 % HISTORY:      23-07-2007 Diepholz
0092 %                  Creation
0093 %
0094 % The following call returns a parameter list object that contains the
0095 % default parameter values:
0096 %
0097 % >> pl = time(time,'Params')
0098 %
0099 % The following call returns a string that contains the routine CVS version:
0100 %
0101 % >> version = time(time,'Version')
0102 %
0103 % The following call returns a string that contains the routine category:
0104 %
0105 % >> category = time(time,'Category')
0106 %
0107 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0108 
0109 ALGONAME = mfilename;
0110 VERSION  = '$Id: time.html,v 1.12 2008/03/31 10:27:40 hewitson Exp $';
0111 CATEGORY = 'Constructor';
0112 
0113 %% Check if this is a special call:
0114 % default parameter list, cvs-version, category
0115 if (nargin == 2 || nargin == 3) && isa(varargin{1}, 'time') && ischar(varargin{2})
0116   in = char(varargin{2});
0117   if strcmp(in, 'Params')
0118     if nargin == 2
0119       varargout{1} = getDefaultPlist();
0120     else
0121       varargout{1} = getDefaultPlist(varargin{3});
0122     end
0123     return
0124   elseif strcmp(in, 'Version')
0125     varargout{1} = VERSION;
0126     return
0127   elseif strcmp(in, 'Category')
0128     varargout{1} = CATEGORY;
0129     return
0130   end
0131 end
0132 
0133 
0134 %% Getting parameters and current time
0135 
0136 import java.util.GregorianCalendar;
0137 import java.util.TimeZone;
0138 
0139 %%%%%%%%%%%%%%%%%%%%%%%%%%%   Get default values   %%%%%%%%%%%%%%%%%%%%%%%%%%%%
0140 
0141 setup_timezone   = getappdata(0, 'timezone');
0142 setup_format_str = getappdata(0, 'time_format_str');
0143 
0144 % REMARK: The default properties must match together.
0145 %         They must represent the same time format.
0146 default_matlab_str = 'yyyy-mm-dd HH:MM:SS.FFF';
0147 default_matlab_nr  = -1;
0148 default_java_str   = 'yyyy-MM-dd HH:mm:ss.SSS';
0149 
0150 %%%%%%%%%%%%%%%%%%%%%%%%%%%%   Get current time   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0151 
0152 % Define local/utc timezone
0153 timezone = TimeZone.getTimeZone(setup_timezone);
0154 
0155 % Define a utc calendar
0156 cal_utc    = GregorianCalendar(timezone);
0157 
0158 % Get the unix time (timezone = UTC) in milliseconds
0159 utc_epoch_milli = cal_utc.getTimeInMillis;
0160 
0161 %%%%%%%%%%%%%%%%%%%%%%%%%   define time properties   %%%%%%%%%%%%%%%%%%%%%%%%%%
0162 
0163   function tt = init(version)
0164     tt.name            = 'None';
0165     tt.utc_epoch_milli = utc_epoch_milli;
0166 
0167     tt.timezone        = timezone;
0168 
0169     tt.timeformat      = timeformat(setup_format_str,   ...
0170       default_matlab_str, ...
0171       default_matlab_nr,  ...
0172       default_java_str);
0173 
0174     t_format = java.text.SimpleDateFormat(default_java_str);
0175     t_format.setTimeZone(tt.timezone);
0176 
0177     tt.time_str = char(t_format.format (tt.utc_epoch_milli));
0178     tt.created  = tt.time_str;
0179     tt.version  = version;
0180     tt.plist    = '';
0181     tt = class(tt, 'time');
0182 
0183     % Set the ltpda_startup time format
0184     tt = set(tt, 'timeformat', tt.timeformat.format_str);
0185   end
0186 
0187 %% %%%%%%%%%%%%%%%%%%%%%%%%%   Create time object   %%%%%%%%%%%%%%%%%%%%%%%%%%%%
0188 
0189 switch nargin
0190 
0191   case 0
0192     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0193     %%%                              No Parameters                              %%%
0194     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0195 
0196     %%%%%%%%%%  t1 = time()   %%%%%%%%%%
0197     % Create standard time object
0198     tt = init(VERSION);
0199 
0200   case 1
0201     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0202     %%%                              One Parameter                              %%%
0203     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0204 
0205     if isa(varargin{1}, 'time')
0206       %%%%%%%%%%   t1 = time(time-object)   %%%%%%%%%%
0207       % Duplicate input time object
0208       tt = varargin{1};
0209 
0210     elseif ischar(varargin{1})
0211 
0212       % is this a filename?
0213       [path, name, ext, vers] = fileparts(varargin{1});
0214       if ~isempty(ext) && length(ext) == 4 && isempty(str2num(ext(2)))
0215         %%%%%%%%%%   t1 = time('foo.mat')               %%%%%%%%%%
0216         %%%%%%%%%%   t1 = time('foo.xml')               %%%%%%%%%%
0217 
0218         switch ext
0219           case '.mat'
0220             tt = load(varargin{1});
0221             tt = tt.a;
0222           case '.xml'
0223             root_node = xmlread(varargin{1});
0224             tt = ltpda_xmlread(root_node, 'time');
0225           otherwise
0226             error('### Unknown file type.');
0227         end
0228 
0229       elseif strcmp(varargin{1}, 't0_default')
0230         %%%%%%%%%%   t1 = time('t0_default')   %%%%%%%%%%
0231         % Time object with default time value
0232         tt = init(VERSION);
0233         tt = set(tt, 'utc_epoch_milli', 0);
0234 
0235       else
0236         %%%%%%%%%%   t1 = time('2007-08-03 10:00:00')   %%%%%%%%%%
0237         % Time from time string
0238         tt = init(VERSION);
0239         tt = set(tt, 'time_str', varargin{1});
0240       end
0241 
0242 
0243     elseif isnumeric(varargin{1})
0244       %%%%%%%%%%   t1 = time(1186135200000)   %%%%%%%%%%
0245       % Time from time value in milliseconds
0246       tt = init(VERSION);
0247       tt = set(tt, 'utc_epoch_milli', varargin{1});
0248 
0249     elseif isstruct(varargin{1})
0250       %%%%%%%%%%   t1 = time(struct)   %%%%%%%%%%
0251       % Struct constructor
0252       tt = init(VERSION);
0253 
0254       fields = fieldnames(varargin{1});
0255       for ii = 1:length(fields)
0256         field = fields{ii};
0257         %%% timeformat -> timeformat-object
0258         if strcmp(field, 'timeformat')
0259           tf = varargin{1}.timeformat;
0260           if isstruct(tf)
0261             tf = timeformat(tf);
0262           end
0263           tt.timeformat = tf;
0264           %% All other
0265         else
0266           try
0267             tt.(field) = varargin{1}.(field);
0268           catch
0269             error('### The field ''%s'' in the struct is not a time property.', field)
0270           end
0271         end
0272       end
0273 
0274     elseif isa(varargin{1}, 'plist')
0275       %%%%%%%%%%   t1 = time(plist)   %%%%%%%%%%
0276       % Parameter list
0277 
0278       pl   = varargin{1};
0279 
0280       filename       = find(pl, 'filename');
0281       hostname       = find(pl, 'hostname');
0282       pl_epoch_milli = find(pl, 'utc_epoch_milli');
0283       pl_time_str    = find(pl, 'time_str');
0284       ipl            = find(pl, 'plist');
0285 
0286 
0287       % Selection of construction method
0288       if ~isempty(filename)
0289 
0290         %-----------------------------------------------------
0291         %--- Construct from file
0292         %-----------------------------------------------------
0293         [path, name, ext, vers] = fileparts(filename);
0294         switch ext
0295           case '.mat'
0296             % Do a filename constructor
0297             tt = load(filename);
0298             tt = tt.a;
0299             tt.plist = pl;
0300           case '.xml'
0301             % Do a filename constructor
0302             root_node = xmlread(filename);
0303             tt = ltpda_xmlread(root_node, 'time');
0304             tt.plist = pl;
0305           otherwise
0306             error('### Unknown file type.');
0307         end
0308 
0309       elseif ~isempty(hostname)
0310 
0311         %-----------------------------------------------------
0312         %--- Construct from repository
0313         %-----------------------------------------------------
0314 
0315         % do hostname constructor
0316         tt = timeFromRepository(pl, VERSION, ALGONAME);
0317         tt.plist = remove(pl, 'conn');
0318 
0319       elseif ~isempty(pl_epoch_milli)
0320 
0321         %-----------------------------------------------------
0322         %--- Construct from millisecs time definition
0323         %-----------------------------------------------------
0324         tt = init(VERSION);
0325         tt = timeFromTimeValue(tt, pl_epoch_milli, pl);
0326 
0327       elseif ~isempty(pl_time_str)
0328 
0329         %-----------------------------------------------------
0330         %--- Construct from string time definition
0331         %-----------------------------------------------------
0332         tt = init(VERSION);
0333         tt = timeFromTimeString(tt, pl_time_str, pl);
0334 
0335       elseif ~isempty(ipl)
0336 
0337         %-----------------------------------------------------
0338         %--- Construct from plist
0339         %-----------------------------------------------------
0340 
0341         % if the plist is empty, we return the default time object
0342         if nparams(ipl) == 0
0343           tt = init(VERSION);
0344           tt.plist = ipl;
0345         else
0346           % do plist constructor
0347           tt = time(ipl);
0348         end
0349 
0350       else
0351 
0352         %-----------------------------------------------------
0353         %--- ERROR
0354         %-----------------------------------------------------
0355 
0356         %% if the plist is empty then return the default time object
0357         if nparams(pl) == 0
0358           tt = init(VERSION);
0359           tt.plist = pl;
0360         else
0361           error('### Unknown TIME constructor method.');
0362         end
0363       end
0364 
0365       %%%%%%%%%%   Unknown constructor   %%%%%%%%%%
0366     else
0367       error ('### Unknown constructor');
0368     end
0369 
0370   case 2
0371     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0372     %%%                              Two Parameter                              %%%
0373     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0374 
0375     if ischar(varargin{1}) && (ischar(varargin{2}) || isnumeric(varargin{2}))
0376       %%%%%%%%%%   t1 = time('14:00:00', 'HH:MM:SS')   %%%%%%%%%%
0377       tt = init(VERSION);
0378       tt = set(tt, 'time_str'  , varargin{1});
0379       tt = set(tt, 'timeformat', varargin{2});
0380 
0381     elseif isa(varargin{1}, 'database')
0382       %%%%%%%%%%  f = time(database, IDs)   %%%%%%%%%%
0383       % From DATABASE
0384       tt = retrieve(varargin{1}, varargin{2:end});
0385 
0386     else
0387       %%%%%%%%%%   Unknown constructor   %%%%%%%%%%
0388       error ('### Unknown constructor');
0389     end
0390 
0391   otherwise
0392 
0393     error ('### Unknown number of inputs');
0394 
0395 end
0396 
0397 varargout{1} = tt;
0398 end % varargout = time(varargin)
0399 
0400 
0401 %% Helper functions
0402 
0403 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0404 %
0405 % FUNCTION:    timeFromRepository
0406 %
0407 % DESCRIPTION: Construct an time from a repository
0408 %
0409 % CALL:        t = timeFromRepository(pli, version, algoname)
0410 %
0411 % PARAMETER:   pli:      Parameter list object
0412 %              version:  cvs version string
0413 %              algoname: The m-file name (use the mfilename command)
0414 %
0415 % HISTORY:     22-03-2008 M Hewitson
0416 %              Creation
0417 %
0418 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0419 function t = timeFromRepository(pli, version, algoname)
0420 
0421 % Add default values
0422 pl = combine(pli, getDefaultPlist('From Repository'));
0423 
0424 % Get parameters
0425 conn = find(pl, 'conn');
0426 hostname = find(pl, 'hostname');
0427 database = find(pl, 'database');
0428 ids      = find(pl, 'id');
0429 
0430 % do we have a connection?
0431 closeConn = 0;
0432 if isempty(conn)
0433   closeConn = 1;
0434   % Connect to repository
0435   conn = mysql_connect(hostname, database);
0436 end
0437 if ~isa(conn, 'database')
0438   error('### connection failed.');
0439 end
0440 % Get each ID
0441 Nids = length(ids);
0442 t  = [];
0443 for kk=1:Nids
0444 
0445   %---- This id
0446   id = ids(kk);
0447   disp(sprintf('  - retrieving ID %d', id));
0448 
0449   %---- check ID object type
0450   tt = mysql_getObjType(conn, id);
0451   %---- If this is a time
0452   if strcmp(tt, mfilename)
0453     %---- call database constructor
0454     a = ltpda_obj_retrieve(conn, id);
0455     %---- Add history
0456     %---- Add to output array
0457     t = [t a];
0458   else
0459     warning('    !skipping ID %d, type %s', id, tt);
0460   end
0461 
0462 end
0463 
0464 % close connection
0465 if closeConn
0466   close(conn);
0467 end
0468 
0469 end % function t = timeFromRepository(pli, version, algoname)
0470 
0471 
0472 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0473 %
0474 % FUNCTION:    timeFromTimeValue
0475 %
0476 % DESCRIPTION: Construct an time from a millisec value
0477 %
0478 % CALL:        t = timeFromTimeValue(t, time_val, pli);
0479 %
0480 % PARAMETER:   t:       Initialized time object
0481 %              time_val: Time value in millisec
0482 %              pli:      Parameter list object
0483 %
0484 % HISTORY:     25-03-2008 M Hueller
0485 %              Creation
0486 %
0487 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0488 function t = timeFromTimeValue(t, time_val, pli)
0489 
0490 % Add default values
0491 pl = combine(pli, getDefaultPlist('From Time Definition'));
0492 
0493 t = set(t, 'timeformat', find(pl, 'timeformat'));
0494 t = set(t, 'timezone', find(pl, 'timezone'));
0495 
0496 t = set(t, 'utc_epoch_milli', time_val);
0497 
0498 t.plist = pli;
0499 
0500 end % function t = timeFromTimeValue(t, time_val, pli);
0501 
0502 
0503 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0504 %
0505 % FUNCTION:    timeFromTimeString
0506 %
0507 % DESCRIPTION: Construct an time from a time string
0508 %
0509 % CALL:        t = timeFromTimeString(t1, time_str, pli);
0510 %
0511 % PARAMETER:   t1:       Initialized time object
0512 %              time_str: Time formatted string
0513 %              pli:      Parameter list object
0514 %
0515 % HISTORY:     25-03-2008 M Hueller
0516 %              Creation
0517 %
0518 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0519 function t = timeFromTimeString(t, time_str, pli)
0520 
0521 pl = combine(pli, getDefaultPlist('From Time String'));
0522 
0523 t = set(t, 'timeformat', find(pl, 'timeformat'));
0524 t = set(t, 'timezone', find(pl, 'timezone'));
0525 
0526 t = set(t, 'time_str', time_str);
0527 
0528 % Sets again the user defined timeformat
0529 if find(pli, 'timeformat')
0530   t = set(t, 'timeformat', find(pli, 'timeformat'));
0531 end
0532 
0533 t.plist = pli;
0534 
0535 end % function t = timeFromTimeString(t, time_str, pli);
0536 
0537 
0538 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0539 %
0540 % FUNCTION:    getDefaultPlist
0541 %
0542 % DESCRIPTION: Default Parameter Lists
0543 %
0544 % CALL:        out = getDefaultPlist(set-string)
0545 %
0546 % PARAMETER:   set-string: A string which defines the default parameter list.
0547 %
0548 % HISTORY:     11-02-2008 M Hueller
0549 %              Creation
0550 %
0551 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0552 function out = getDefaultPlist(varargin)
0553 
0554 % list of available parameter sets
0555 sets = {'From XML File', 'From MAT File', ...
0556   'From Repository', ...
0557   'From Time Definition', ...
0558   'From Time String', ...
0559   'From Plist'};
0560 
0561 if nargin == 0
0562   out = sets;
0563   return
0564 end
0565 
0566 set = varargin{1};
0567 switch set
0568 
0569   %------------------------------------------
0570   %--- Repository constructor
0571   %------------------------------------------
0572   case 'From Repository'
0573     out = plist('hostname', 'localhost', 'database', 'ltpda', 'ID', []);
0574 
0575     %------------------------------------------
0576     %--- Definition constructor
0577     %------------------------------------------
0578   case 'From Time Definition'
0579     out = plist('utc_epoch_milli', 0, ...
0580       'timezone', 'UTC', ...
0581       'timeformat', 'yyyy-mm-dd HH:MM:SS.FFF');
0582 
0583     %------------------------------------------
0584     %--- String constructor
0585     %------------------------------------------
0586   case 'From Time String'
0587     out = plist('time_str', '1970-01-01 00:00:00.000', ...
0588       'timezone', 'UTC', ...
0589       'timeformat', 'yyyy-mm-dd HH:MM:SS.FFF');
0590 
0591     %------------------------------------------
0592     %--- Read from XML file
0593     %------------------------------------------
0594   case 'From XML File'
0595     out = plist('filename', '');
0596 
0597     %------------------------------------------
0598     %--- Read from MAT file
0599     %------------------------------------------
0600   case 'From MAT File'
0601     out = plist('filename', '');
0602 
0603     %------------------------------------------
0604     %--- Create from a plist
0605     %------------------------------------------
0606   case 'From Plist'
0607     out = plist('Plist', []);
0608 
0609   otherwise
0610     out = plist();
0611 end
0612 
0613 
0614 end % function varargout = time(varargin)
0615 
0616 
0617 
0618

Generated on Mon 31-Mar-2008 12:20:24 by m2html © 2003