필터 지우기
필터 지우기

What would happen if the time for function execution is bigger that the t.Period using timer object

조회 수: 1 (최근 30일)
Hello, guys! I am wondering what would happen if I use a timer object to execute a program, but the period of the timer is smaller than the time required for the program execution.
For example:
t = timer;
t.TimerFcn = @(~,thisEvent)disp([thisEvent.Type ' executed '...
datestr(thisEvent.Data.time,'dd-mmm-yyyy HH:MM:SS.FFF')]);
t.Period = 10;
t.ExecutionMode = 'fixedRate';
start(t)
and the time for the function execution takes, let's say 20 sec. Are there any methods which send us a message that the program could not be done, because it requires more time? Thank you!

답변 (1개)

Guillaume
Guillaume 2018년 10월 17일
It's completely documented in the timer documentation and the behaviour will depends on what you set the BusyMode property to. It can drop the missed task, queue it, or simply error.
  댓글 수: 1
Jan
Jan 2018년 10월 17일
+1. Exactly. And you can check manually what happens:
t.TimerFcn = @myTask;
t.BusyMode = 'drop'; % or 'queue' or 'error'
...
function myTask(TimerH, Event)
disp([Event.Type ' executed ' ...
datestr(Event.Data.time,'dd-mmm-yyyy HH:MM:SS.FFF')]
pause(11)
end

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Construct and Work with Object Arrays에 대해 자세히 알아보기

제품


릴리스

R2015a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by