	PRO EVS_DECODE, EVSBYTE, EV_STATUS
;+
; Project     :	SOHO - CDS
;
; Name        :	EVS_DECODE
;
; Purpose     :	Decode the event status byte in the telemetry.
;
; Explanation :	This procedure takes the event status byte in the telemetry,
;		and extracts out the relevent information.
;
; Use         :	EVS_DECODE, EVSBYTE, EV_STATUS
;
; Inputs      :	EVSBYTE	 = Input byte scalar or array containing the telemetry
;			   bits corresponding to the event status byte.
;
; Opt. Inputs :	None.
;
; Outputs     :	EV_STATUS = A structure variable containing the following tags:
;
;			EV_RECOG = True if event recognition is enabled.
;			EV_DETEC = True if an event is detected.
;			EV_VALID = True if the solar coordinates are valid.
;
; Opt. Outputs:	None.
;
; Keywords    :	None.
;
; Calls       :	None.
;
; Common      :	None.
;
; Restrictions:	None.
;
; Side effects:	None.
;
; Category    :	Data_handling, I/O, Telemetry.
;
; Prev. Hist. :	None.
;
; Written     :	William Thompson, GSFC, 22 December 1994
;
; Modified    :	Version 1, William Thompson, 22 December 1994
;
; Version     :	Version 1, 22 December 1994
;-
;
	ON_ERROR, 2
;
;  Check the number of parameters.
;
	IF N_PARAMS() NE 2 THEN MESSAGE,	$
		'Syntax:  EVS_DECODE, EVSBYTE, EV_STATUS'
;
;  Make sure that the input is of the correct type.
;
	IF DATATYPE(EVSBYTE,1) NE 'Byte' THEN MESSAGE,	$
		'EVSBYTE must be a byte variable'
;
;  Extract the bits from the status byte.  Ignore any dimension information for
;  now.
;
	EVS_BYTE = EVSBYTE(*)
	DEC2BIN, EVS_BYTE, EVSBITS, /QUIET
;
;  Form the output structure.
;
	EV_STATUS = {EV_STATUS_STRUC,	$
		EV_RECOG: 0B,		$
		EV_DETEC: 0B,		$
		EV_VALID: 0B}
;
;  Populate the output structure.  The bits are extracted by DEC2BIN in the
;  order from most significant to least significant.
;
	IF N_ELEMENTS(EVSBYTE) EQ 1 THEN BEGIN
		EV_STATUS.EV_RECOG = EVSBITS(7)			;7-0
		EV_STATUS.EV_DETEC = EVSBITS(6)			;7-1
		EV_STATUS.EV_VALID = EVSBITS(5)			;7-2
	END ELSE BEGIN
		EV_STATUS = REPLICATE(EV_STATUS, N_ELEMENTS(EVSBYTE))
		EV_STATUS.EV_RECOG = REFORM(EVSBITS(7,*))	;7-0
		EV_STATUS.EV_DETEC = REFORM(EVSBITS(6,*))	;7-1
		EV_STATUS.EV_VALID = REFORM(EVSBITS(5,*))	;7-2
	ENDELSE
;
;  Make sure that the dimensions of the output match those of the input.
;
	IF N_ELEMENTS(EVSBYTE) NE 1 THEN BEGIN
		SZ = SIZE(EVSBYTE)
		EV_STATUS = REFORM(EV_STATUS, SZ(1:SZ(0)))
	ENDIF
;
	RETURN
	END
