interface cmotask
# Motor task controller
parameter motor
type ’_char’
in ’FILTER_WHEEL’, ’FOCUS_WHEEL’
prompt ’which wheel - FILTER_WHEEL or FOCUS_WHEEL?’
endparameter
action motor_control
obey
needs motor
endobey
cancel
needs motor
endcancel
endaction
endinterface
SUBROUTINE CMOTASK( STATUS )
* Control the task Motask which moves 2 imaginary motors
IMPLICIT NONE ! No implicit typing
INCLUDE ’SAE_PAR’ ! Standard SAE constants
INCLUDE ’ADAMDEFNS’
INCLUDE ’MESSYS_ERR’
INCLUDE ’ACT_ERR’
INCLUDE ’DTASK_ERR’
INTEGER STATUS ! modified status
INTEGER CONTEXT ! context OBEY or CANCEL
INTEGER SEQ ! action sequence number
INTEGER GOOD_STATUS ! local status
INTEGER MOTASK_PATH ! path to subsidiary task
INTEGER MOTASK_MESSID ! message id
CHARACTER*80 MOTOR ! name of motor to be moved
CHARACTER*80 INVAL ! parameter string sent
CHARACTER*80 OUTVAL ! parameter string returned
INTEGER REASON ! subsidiary completion status
IF ( STATUS .NE. SAI__OK ) RETURN
GOOD_STATUS = SAI__OK
CALL TASK_GET_CONTEXT ( CONTEXT, STATUS )
IF ( CONTEXT .EQ. OBEY ) THEN
CALL TASK_GET_SEQ ( SEQ, STATUS )
IF ( SEQ .EQ. 0 ) THEN
CALL PAR_GET0C ( ’MOTOR’, MOTOR, STATUS )
INVAL = ’ ’
CALL TASK_OBEY ( ’MOTASK’, MOTOR, INVAL, OUTVAL,
: MOTASK_PATH, MOTASK_MESSID, STATUS )
IF ( STATUS .EQ. DTASK__ACTSTART ) THEN
STATUS = SAI__OK
CALL TASK_ADD_MESSINFO ( MOTASK_PATH, MOTASK_MESSID,
: STATUS )
CALL TASK_PUT_REQUEST ( ACT__MESSAGE, STATUS )
ELSE
CALL MSG_SETC ( ’MOTOR’, MOTOR )
CALL ERR_REP ( ’ ’, ’^MOTOR FAILED’, STATUS )
END IF
ELSE
CALL TASK_GET_REASON ( REASON, STATUS )
IF ( REASON .EQ. DTASK__ACTCANCEL ) THEN
CALL MSG_OUT ( ’ ’,
: ’CMOTASK: subsidiary task has been cancelled’,
: STATUS )
ELSE IF ( REASON .NE. DTASK__ACTCOMPLETE ) THEN
STATUS = REASON
CALL ERR_REP ( ’ ’,
: ’CMOTASK: subsidiary task has returned bad status’,
: STATUS )
END IF
END IF
ELSE IF ( CONTEXT .EQ. CANCEL ) THEN
CALL TASK_CANCEL ( ’MOTASK’, MOTOR, INVAL, OUTVAL, STATUS )
IF ( STATUS .EQ. DTASK__ACTCANCEL ) THEN
STATUS = SAI__OK
CALL TASK_PUT_REQUEST ( ACT__MESSAGE, STATUS )
ELSE
CALL ERR_REP ( ’ ’, ’CMOTASK: failure cancelling MOTASK’,
: STATUS )
ENDIF
END IF
CALL PAR_CANCL ( ’MOTOR’, GOOD_STATUS )
END