;+
; NAME:
;     GET_ENDTYP
; PURPOSE:
;     Returns a string identifying a reason for an end of scan,
;       as indicated by the last byte of an EOS recod.
; CATEGORY:
;     OVRO APC DATA-ANALYSIS
; CALLING SEQUENCE:
;     endtypstr = get_endtyp(endcode)
; INPUTS:
;     endcode    the end code as read from the last byte
;                  of an EOS record.
; OPTIONAL (KEYWORD) INPUT PARAMETERS:
; ROUTINES CALLED:
; OUTPUTS:
;     endtypstr  a string giving the reason for ending the scan, or the
;                  string 'UNKNOWN' if the endcode is zero, or 'UNDEFINED'
;                  if the endcode is invalid.
; COMMENTS:
; SIDE EFFECTS:
; RESTRICTIONS:
; SEE ALSO:
;     get_scntyp, get_segtyp
; MODIFICATION HISTORY:
;     Written 17-Mar-1999 by Dale E. Gary
;-
function get_endtyp,endcode

   endtyp = ['UNKNOWN','SEQSTOP command','DATA-OFF command','UNDEFINED',$
             'DATA-WAIT command','UNDEFINED','UNDEFINED','UNDEFINED',   $
             'UNDEFINED','UNDEFINED','UNDEFINED','END SEQUENCE',     $
             'END TRAJECTORY','SUNSET','WINDSCRAM','BRIGHTSCRAM']

   ntyps = n_elements(endtyp)
   if (endcode lt 0 or endcode ge ntyps) then begin
      return,'***Unknown segment type***'
   endif else return,endtyp(endcode)
end
