Suppose that your task has to input data from some hardware connected to an RS232 line. You can use the VAX/VMS SYS$QIO system service with your own AST handler to start the input operation, optionally call TASK_PUT_DELAY to set a timeout on the operation, and return to the task fixed-part after having put a request ACT__ASTINT.
When the input completes, VMS hands control to your AST handler which can carry out whatever actions are necessary and then use TASK_ASTMSG(NAME,LENGTH,VALUE,STATUS) to tell the fixed part to call the application again. In this call:
Provided NAME coincides with one of your actions which has requested to be called again, any associated timer is cancelled and your application is called.
TASK_GET_REASON(REASON,STATUS) returns, in REASON, value MESSYS__ASTINT if the message was received from the AST handler, or MESSYS__RESCHED if the timer completed. In the former case, you could use TASK_GET_VALUE(VALUE,STATUS) to get the information passed from the AST handler.
Let us consider an example task called DO_IO with an action called READ.
SUBROUTINE DO_IO ( STATUS ) IMPLICIT NONE INCLUDE 'SAE_PAR' INCLUDE 'ACT_ERR' INCLUDE 'MESSYS_ERR' INCLUDE 'DDMSG' INCLUDE '$IODEF' INTEGER ASTPARM CHARACTER*(MSG_VAL_LEN) VALUE INTEGER CHAN CHARACTER*80 INSTRING INTEGER REASON INTEGER STATUS INTEGER SEQ EXTERNAL READAST IF ( STATUS .NE. SAI__OK ) RETURN CALL TASK_GET_SEQ( SEQ, STATUS ) IF ( SEQ .EQ. 0 ) THEN CALL SYS$ASSIGN ( 'TTA5:', CHAN, ,) CALL SYS$QIO ( , %VAL(CHAN), IO$_READ,, READAST, ASTPARM, : %REF(INSTRING), %VAL(80),,,,) CALL TASK_PUT_DELAY ( 5000, STATUS ) CALL TASK_PUT_REQUEST ( ACT__ASTINT, STATUS ) ELSE CALL TASK_GET_REASON ( REASON, STATUS ) IF ( REASON .EQ. MESSYS__ASTINT ) THEN CALL TASK_GET_VALUE ( VALUE, STATUS ) CALL MSG_OUT ( ' ', VALUE, STATUS ) ELSE IF ( REASON .EQ. MESSYS__RESCHED ) THEN CALL MSG_OUT ( ' ', 'timed-out', STATUS ) ENDIF CALL SYS$DASSGN ( %VAL(CHAN) ) ENDIF END SUBROUTINE READAST ( ASTPARM ) IMPLICIT NONE INCLUDE 'SAE_PAR' INCLUDE 'DDMSG' INTEGER ASTPARM CHARACTER*(MSG_VAL_LEN) VALUE CHARACTER*(PAR__SZNAM) NAME INTEGER LENGTH INTEGER STATUS STATUS = SAI__OK NAME = 'READ' VALUE = 'input finished' LENGTH = 14 CALL TASK_ASTMSG ( NAME, LENGTH, VALUE, STATUS ) END
ADAM Guide to Writing Instrumentation Tasks