Timer

classes
   end            seconds        start          

SYNTAX

timer = new Timer("stmt")

DESCRIPTION

Execute "stmt" at the end of each interval specified by timer.seconds(interval). The timer must be started and can be stopped. A Timer is used to implement the NEURONMainMenu/Tools/MovieRun in nrn/lib/hoc/movierun.hoc

EXAMPLES

execute following example
load_file("nrngui.hoc")
objref timer
timer = new Timer("p()")
invl = .2
nstep = 10
proc p() {local x
	istep += 1
	tt = startsw() - t0
	print istep, tt
	if (istep >= nstep) {
		timer.end()
	}
	doNotify()
}
proc begin() {
	istep = 0
	timer.seconds(invl)
	t0 = startsw()
	tt = 0
	timer.start()
}

xpanel("Timer Demo")
	xbutton("Start", "begin()")
	xbutton("Stop", "timer.end()")
	xpvalue("Interval", &invl, 1)
	xpvalue("#steps", &nstep, 1)
	xpvalue("istep", &istep)
	xpvalue("t", &tt)
xpanel()
begin()


seconds

Timer

SYNTAX

interval = timer.seconds()
interval = timer.seconds(interval)

DESCRIPTION

Specify the timer interval. Timer resolution is system dependent but is probably around 10 ms. The time it takes to execute the "stmt" is a part of the interval.


start

Timer

SYNTAX

timer.start()

DESCRIPTION

Start the timer. "stmt" will be called at the end of each interval defined by the argument to timer.seconds(interval).


end

Timer

SYNTAX

timer.end()

DESCRIPTION

Stop calling the "stmt". At least on linux, this will prevent the calling of "stmt" at the end of the current interval.


neuron/general/classes/timer.hel : May 13 2012