	PRO SPS_DECODE, SPSWORD, SP_STATUS
;+
; Project     :	SOHO - CDS
;
; Name        :	SPS_DECODE
;
; Purpose     :	Decode the science process status word in the telemetry.
;
; Explanation :	This procedure takes the science process status word in the
;		telemetry, and extracts out the relevent information.
;
; Use         :	SPS_DECODE, SPSWORD, SP_STATUS
;
; Inputs      :	SPSWORD	 = Short integer input scalar or array containing the
;			   telemetry bits corresponding to the science process
;			   status word.
;
; Opt. Inputs :	None.
;
; Outputs     :	SP_STATUS = A structure variable containing the following tags:
;
;			EVENT_REC  = True if event recognition is enabled.
;			COMP_ERR   = True if a data compression scheme error
;				     was detected.
;			VDS_ORIENT = The VDS readout orientation, either 0 for
;				     rows or 1 for columns.
;			VDS_ACCUM  = True if VDS accumulate mode is enabled.
;
; 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, 18 August 1994
;
; Modified    :	Version 1, William Thompson, 26 August 1994
;
; Version     :	Version 1, 26 August 1994
;-
;
	ON_ERROR, 2
;
;  Check the number of parameters.
;
	IF N_PARAMS() NE 2 THEN MESSAGE,	$
		'Syntax:  SPS_DECODE, SPSWORD, SP_STATUS'
;
;  Make sure that the input is of the correct type.
;
	IF DATATYPE(SPSWORD,1) NE 'Integer' THEN MESSAGE,	$
		'SPSWORD must be a short integer'
;
;  Extract the bits from the status word.  Ignore any dimension information for
;  now.
;
	SPS_WORD = SPSWORD(*)
	DEC2BIN, SPS_WORD, SPSBITS, /QUIET
;
;  Form the output structure.
;
	SP_STATUS = {SP_STATUS_STRUC,	$
		EVENT_REC: 0B,		$
		COMP_ERR: 0B,		$
		VDS_ORIENT: 0B,		$
		VDS_ACCUM: 0B}
;
;  Populate the output structure.  The bits are extracted by DEC2BIN in the
;  order from most significant to least significant.
;
	IF N_ELEMENTS(SPSWORD) EQ 1 THEN BEGIN
		SP_STATUS.EVENT_REC  = SPSBITS(15)		;15-0
		SP_STATUS.COMP_ERR   = SPSBITS(14)		;15-1
		SP_STATUS.VDS_ORIENT = SPSBITS(12)		;15-3
		SP_STATUS.VDS_ACCUM  = SPSBITS(9)		;15-6
	END ELSE BEGIN
		SP_STATUS = REPLICATE(SP_STATUS, N_ELEMENTS(SPSWORD))
		SP_STATUS.EVENT_REC  = REFORM(SPSBITS(15,*))	;15-0
		SP_STATUS.COMP_ERR   = REFORM(SPSBITS(14,*))	;15-1
		SP_STATUS.VDS_ORIENT = REFORM(SPSBITS(12,*))	;15-3
		SP_STATUS.VDS_ACCUM  = REFORM(SPSBITS(9,*))	;15-6
	ENDELSE
;
;  Make sure that the dimensions of the output match those of the input.
;
	IF N_ELEMENTS(SPSWORD) NE 1 THEN BEGIN
		SZ = SIZE(SPSWORD)
		SP_STATUS = REFORM(SP_STATUS, SZ(1:SZ(0)))
	ENDIF
;
	RETURN
	END
