Guardian Programmer's Guide

Table Of Contents
Managing Time
Guardian Programmer’s Guide 421922-014
18 - 17
Setting and Canceling Timers: Process Time
CANCELTIMEOUT or TIMER_STOP_ procedures. CANCELTIMEOUT or
TIMER_STOP_ uses this value to distinguish between multiple timers.
The Time signal message received from $RECEIVE when the timer expires has the
following format:
The following example starts a timer to expire in one minute. The example uses the
parameter-1 parameter to supply an identifier that will be returned in word 1 of the
system message. The SIGNALTIMEOUT procedure returns a value in the tag
parameter for passing to the CANCELTIMEOUT procedure, which will use it to identify
this timer.
TIMEOUT^VALUE := 6000D;
PARAMETER^1 := 1;
CALL SIGNALTIMEOUT(TIMEOUT^VALUE,PARAMETER^1,
!parameter^2!,
TAG^1);
Note that parameter-2 is not supplied in this case. The purpose of parameter-2 is
the same as parameter-1, but parameter-2 allows you to use a 32-bit value
instead of a 16-bit value. If used, the value of parameter-2 is returned in word 2 of
the Time signal message.
To cancel the timer set above, supply the CANCELTIMEOUT procedure with the tag
val
ue that was returned by the SIGNALTIMEOUT procedure:
CALL CANCELTIMEOUT(TAG^1);
For details on how to read system messages from the $RECEIVE file, see Section
6,
Communicating With Processes. You can identify the timer by checking word 1 of the
Time signal message; in this case, its value will be equal to parameter-1.
Setting and Canceling Timers: Process Time
Setting and canceling timers of process time is like setting and canceling timers of
elapsed time, except that the time period measured is limited to the number of
milliseconds that the process is active.
You start a process timer using the SIGNALPROCESSTIMEOUT procedure and
cancel the timer using the CANCELPROCESSTIMEOUT procedure. Your process will
Format of system message -22 (Time signal message):
sysmsg[0] = -22
sysmsg[1] = First parameter supplied by SIGNALTIMEOUT;
default value 0
sysmsg[2] FOR 2 = Second parameter supplied by SIGNALTIMEOUT;
default value 0D
Note. There are special considerations when using timers to measure long intervals of
elapsed time, such as several hours or more. For information on this topic, refer to the
subsection
Measuring Long Time Intervals.