timer

The notion of timers provides a mechanism for specifying time-related matters. Timers are just like alarm clocks. The process waiting for a timer is passively waiting since the process needs not sample them. Timers will issue time-out signals when their time is reached. There may well be several different timers active at the same time. Active timers do not affect the behaviour of the process until the timer signal is consumed by the process.

A timer is declared similarly to a variable.

Timers are set and reset in tasks . When a timer has not been set, it is inactive. When it is set, it becomes active.

A timer is set with a time value. time is a special data type and is mainly used in connection with timers. The expression "now+10" is a time value and it adds the time expression now and the duration 10 (here: seconds). now is an operator of the time data type and it returns the current real time. Duration is another special data type and it is also mainly used in connection with timers. You may add or subtract duration to time and get time. You may divide or multiply duration by a real and get duration. You may subtract a time value from another time value and get duration.

(more...)

The semantics of timers is this: a time value is set in a timer and it becomes active. When the time is reached, a signal with the same name as the timer itself will be sent to the process itself. Then the timer becomes inactive.

The timer signal can be input in the same way as ordinary signals:

A timer may be reset. It then becomes inactive and no signal will be issued. (If an inactive timer is reset, then it remains inactive.) A reset will also remove a timer signal instance already in the input port. This happens when the timer has expired, but the time-out signal has not been consumed.

If an active Timer is set, the time value associated with the timer receives a new value. The timer is still active. If a timer is set to a time which is already passed, the timer will immediately issue the time-out signal.

There is an operator active which has a timer as a parameter and which returns a Boolean that can be used to check whether a certain timer is active or not.

(more...)

Timer signals may contain data as other signals may contain data. Different parameter values in set means generation of several timer instances. reset must match these parameter values to eliminate the correct timer instance.

The following is a sketch of a finite state machine of the behaviour of a timer.

Z.100