view m-toolbox/classes/@LTPDARepositoryManager/startTimer.m @ 8:2f5c9bd7d95d database-connection-manager

Clarify ltpda_uo.retrieve parameters handling
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Mon, 05 Dec 2011 16:20:06 +0100
parents f0afece42f48
children
line wrap: on
line source

% STARTTIMER returns a started timer.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% description: STARTTIMER returns a started timer.
%
% call:        t = startTimer(name, fcn, period)
%
% inputs:      name   - name of the timer
%              fcn    - call back function of the timer
%              period - period of the timer
%
% outputs:     t      - new timer object.
%
% version:     $Id: startTimer.m,v 1.3 2011/02/03 13:44:02 ingo Exp $
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function t = startTimer(name, fcn, period)
  
  t = timerfind('name', name);
  
  if isempty(t) || (isa(t, 'timer') && ~isvalid(t))
    
    t = timer(...
      'TimerFcn',       fcn, ...
      'StartDelay',     period, ...
      'Period',         period, ...
      'ExecutionMode', 'fixedRate', ...
      'Name',           name);
  end
  
  % start the timer
  if ~strcmp(get(t,'Running'), 'on')
    start(t);
  end
  
end