next up previous 61
Next: Making coffee
Up: Making tea and coffee
Previous: Making tea and coffee

Making tea

interface test_tea
#  Test tea task
    parameter param
        type '_integer'
        range 1,10
        vpath 'internal'
        default 2
    endparameter
    action lapsang1
        obey
        endobey
    endaction
    action lapsang2
        obey
        endobey
    endaction
    action lapsang3
        obey
        endobey
    endaction
    action lapsang4
        obey
        endobey
    endaction
    action lapsang5
        obey
        endobey
    endaction
endinterface

      SUBROUTINE TEST_TEA (STATUS)

*     Test D-task that is run from a rescheduling control task

      IMPLICIT NONE
      INTEGER   STATUS          ! Modified STATUS
 
      INCLUDE   'SAE_PAR'
      INCLUDE   'ADAMDEFNS'
      INCLUDE   'ACT_ERR'
 
      INTEGER   SEQ             ! Action sequence number
      INTEGER   CONTEXT         ! Context (OBEY or CANCEL)
      INTEGER   PARAM           ! Arbitrary integer parameter
      INTEGER   DELAY           ! Delay between initial and final entries
      CHARACTER NAME*24         ! Action name
      CHARACTER VALUE*80        ! Value string
 
      SAVE PARAM                ! Value must be saved

      IF (STATUS .NE. SAI__OK) RETURN

*  Pick up required "ACT parameters"

      CALL TASK_GET_NAME (NAME,STATUS)
      CALL TASK_GET_CONTEXT (CONTEXT,STATUS)
      CALL TASK_GET_SEQ (SEQ,STATUS)

*  Loop through possible OBEYs
 
      IF (NAME(1:7) .EQ. 'LAPSANG') THEN
         IF (SEQ .EQ. 0) THEN
*         Produce error - undefined parameter on LAPSANG2
            IF (NAME(8:8) .EQ. '2') THEN
               CALL PAR_GET0I ('X',PARAM,STATUS)
               IF (STATUS .NE. SAI__OK) THEN
                  CALL ERR_REP (' ',
     :            'TEA: LAPSANG1 Deliberate error - '//
     :            'No parameter X: ^STATUS', STATUS)
*               Flush the error messages and allow task to continue
                  CALL ERR_FLUSH ( STATUS )
               ENDIF

*         Get parameter value on LAPSANG3
*         to be used as a count of TRIGGERS
            ELSE IF (NAME(8:8) .EQ. '3') THEN
               CALL PAR_GET0I ('PARAM',PARAM,STATUS)
               IF (STATUS .NE. SAI__OK) THEN
                  CALL ERR_REP (' ',
     :            'TEA: LAPSANG3 Failed to get PARAM: ^STATUS',
     :             STATUS)
*              Set harmless value for PARAM
                  PARAM = -1
                  RETURN
               ENDIF
            ENDIF
            CALL MSG_SETC ('NAME',NAME)
            CALL MSG_OUT (' ','TEA: Starting ^NAME action',STATUS)
            DELAY = 1000 * (ICHAR(NAME(8:8)) - ICHAR('0'))
            CALL TASK_PUT_DELAY (DELAY,STATUS)
            CALL TASK_PUT_REQUEST ( ACT__WAIT, STATUS )
         ELSE IF (NAME(8:8) .EQ. '4' .AND. SEQ .LE. PARAM) THEN
            VALUE = NAME(1:8)//' is paging you ...'
            CALL TASK_TRIGGER (NAME,VALUE,STATUS)
            IF (STATUS .NE. SAI__OK) THEN
               CALL ERR_REP (' ',
     :         'TEA: LAPSANG4 Failed to trigger control task: ^STATUS',
     :          STATUS)
            ENDIF
            CALL TASK_PUT_DELAY (2000,STATUS)
            CALL TASK_PUT_REQUEST ( ACT__WAIT, STATUS )
         ELSE
            CALL MSG_SETC ('NAME',NAME)
            CALL MSG_OUT (' ','TEA: Finishing ^NAME action',STATUS)
            CALL TASK_PUT_VALUE ('Lapsang''s ready!',STATUS)
         ENDIF

      ENDIF
      END



next up previous 61
Next: Making coffee
Up: Making tea and coffee
Previous: Making tea and coffee

ADAM Guide to Writing Instrumentation Tasks
Starlink User Note 134
B D Kelly
A J Chipperfield

30 March 1992
E-mail:ussc@star.rl.ac.uk

Copyright © 2000 Council for the Central Laboratory of the Research Councils