view m-toolbox/classes/@LTPDARepositoryManager/startTimer.m @ 6:2b57573b11c7 database-connection-manager

Add utils.mysql.execute
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