comparison m-toolbox/classes/@LTPDARepositoryManager/startTimer.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 % STARTTIMER returns a started timer.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % description: STARTTIMER returns a started timer.
5 %
6 % call: t = startTimer(name, fcn, period)
7 %
8 % inputs: name - name of the timer
9 % fcn - call back function of the timer
10 % period - period of the timer
11 %
12 % outputs: t - new timer object.
13 %
14 % version: $Id: startTimer.m,v 1.3 2011/02/03 13:44:02 ingo Exp $
15 %
16 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
17
18 function t = startTimer(name, fcn, period)
19
20 t = timerfind('name', name);
21
22 if isempty(t) || (isa(t, 'timer') && ~isvalid(t))
23
24 t = timer(...
25 'TimerFcn', fcn, ...
26 'StartDelay', period, ...
27 'Period', period, ...
28 'ExecutionMode', 'fixedRate', ...
29 'Name', name);
30 end
31
32 % start the timer
33 if ~strcmp(get(t,'Running'), 'on')
34 start(t);
35 end
36
37 end