J
Hello,
I've added lib/logic/timer.h to CVS, containing a proposed "timer" type. This is intended as a module-private timer, to be used, among other places, in the basic demo.
Any comments before implementation?
It can be thought of as a real-valued variable which magically increments its value at a rate of 1.0 per second. On-, off- etc timers can be built
out of this using standard C comparisons and if/while statements.
The functions provided are:
zero - zeroes and stops the timer. This is an init function.
start - zero and start the timer. This is an init function.
get - get the current value of the timer (in seconds).
elapsed - returns true or false depending on whether the given time
has already elapsed. This is a one-line wrapper around get.
stop - stop the timer. No effect if already stopped.
restart - start the timer at its current value. No effect if
already running.
add - advance or retard the timer. Can be used on both stopped and
running timers.
Note: for count-down semantics, start the timer at a negative value.
Jiri
--
Jiri Baum <[email protected]>
What we do Every Night! Take Over the World!
_______________________________________________
LinuxPLC mailing list
[email protected]
http://linuxplc.org/mailman/listinfo/linuxplc
I've added lib/logic/timer.h to CVS, containing a proposed "timer" type. This is intended as a module-private timer, to be used, among other places, in the basic demo.
Any comments before implementation?
It can be thought of as a real-valued variable which magically increments its value at a rate of 1.0 per second. On-, off- etc timers can be built
out of this using standard C comparisons and if/while statements.
The functions provided are:
zero - zeroes and stops the timer. This is an init function.
start - zero and start the timer. This is an init function.
get - get the current value of the timer (in seconds).
elapsed - returns true or false depending on whether the given time
has already elapsed. This is a one-line wrapper around get.
stop - stop the timer. No effect if already stopped.
restart - start the timer at its current value. No effect if
already running.
add - advance or retard the timer. Can be used on both stopped and
running timers.
Note: for count-down semantics, start the timer at a negative value.
Jiri
--
Jiri Baum <[email protected]>
What we do Every Night! Take Over the World!
_______________________________________________
LinuxPLC mailing list
[email protected]
http://linuxplc.org/mailman/listinfo/linuxplc