Command-Line Switch: -MB_EPC Default value: {}
Command-Line Switch: -MID Default value: {}
Command-Line Switch: -offset Default value: 00:00
Command-Line Switch: -period Default value: 00:01
The ep_timer command creates a new Tcl command whose name is timer_id. The command is then used to initiate actions in the future - either one-shot or periodic. The ep_timer class was developed as part of the Event Processing Component (EPC), but it can be used generally.
There are two ways to initiate periodic actions. The first way is to set the period using the public variable, period, and to call the run_at method to begin periodic actions from a specified time. Alternatively, periodic actions can be configured using the period and offset public variables combined with calling the run method. With this alternative, the offset time is added to the beginning of the current day, and then an integral number of periods is added until a future event time is computed. Subsequent future event times are computed by adding the period interval to each future event time.
The class can be used for general timing purposes by supplying Tcl code for the action argument to the run, run_at, or at methods. The default action is to send a timer event message to the EPC. The format of the timer event message sent to the EPC is:
"event_id TIMER.timer_id timer_id timer_id"or
"event_id TIMER.timer_id timer_id timer_id MID MID"if the MID value is non-blank.
The cancel method is used to stop the periodic actions, or to stop a one-shot action.
One-shot actions are scheduled for future execution by calling the at method.
A timer is designed to be used for only a single future action, either one-shot or periodic. Use multiple timer instances to have multiple future actions. Timers use the Tcl after command for implementation which is supported by the Tcl/Tk event loop, and does not incur busy polling. A timer can be used for a new action after it has become idle from being cancelled or from executing a one-shot action.
The temporal accuracy of the timer event is typically well within a tenth of a second of the specified time, but may vary depending on the busyness of processing. Accuracy is diminished by scheduling multiple tasks to occur at the same instant. For best accuracy in measuring rates, use the timer events as a data acquisition trigger, and divide the occurrence count over the actual time period instead of the scheduled period.
package require Humelib catch {delete object timer_$mid} # send an event to the EPC every minute ep_timer timer_$mid -period 00:01 -MID $mid timer_$mid run