	PRO OPS_DECODE, OPS, BITS, POSITION, MAP=MAP
;+
; Project     :	SOHO - CDS
;
; Name        :	OPS_DECODE
;
; Purpose     :	Decode MCU telemetry format for the OPS L or R position.
;
; Explanation :	This procedure takes the OPS L or R position in MCU telemetry
;		format, and extracts the status bits and position value.
;
; Use         :	OPS_DECODE, OPS, BITS, POSITION  [, /MAP ]
;
; Inputs      :	OPS	 = Short integer input scalar or array containing the
;			   telemetry bits corresponding to the OPS L or R
;			   position.
;
; Opt. Inputs :	None.
;
; Outputs     :	BITS	 = The status bits in one of two formats:
;
;				* Character string containing the status bits
;				  as ones and zeros.  This is the default, and
;				  is suitable for use in FITS header.
;
;				* Byte variable with the status bits shifted
;				  all the way to the right.  Requires the /MAP
;				  keyword.  Suitable for use with FITS binary
;				  table bit array fields.
;
;		POSITION = The OPS L or R coordinate position.
;
; Opt. Outputs:	None.
;
; Keywords    :	MAP	 = If set, then the format of the BITS output variable
;			   is changed.
;
; Calls       :	None.
;
; Common      :	None.
;
; Restrictions:	None.
;
; Side effects:	None.
;
; Category    :	Data_handling, I/O, Telemetry.
;
; Prev. Hist. :	None.
;
; Written     :	William Thompson, GSFC, 16 December 1993.
;
; Modified    :	Version 1, William Thompson, GSFC, 16 December 1993.
;
; Version     :	Version 1, 16 December 1993.
;-
;
	ON_ERROR, 2
;
;  Check the number of parameters.
;
	IF N_PARAMS() NE 3 THEN MESSAGE,	$
		'Syntax:  OPS_DECODE, OPS, BITS, POSITION'
;
;  Make sure that the input is of the correct type.
;
	IF DATATYPE(OPS,1) NE 'Integer' THEN MESSAGE,	$
		'OPS must be a short integer'
;
;  Extract the status bits, 0 through 3.
;
	IF KEYWORD_SET(MAP) THEN BEGIN
		BITS = BYTE(ISHFT(OPS,-12))
	END ELSE BEGIN
		DEC2BIN, OPS, OPSBITS, /QUIET
		BITS = STRTRIM(FIX(OPSBITS(0)),2)
		FOR I = 1,3 DO BITS = BITS + STRTRIM(FIX(OPSBITS(I)),2)
	ENDELSE
;
;  Extract the unsigned position, bits 4 through 15.
;
	POSITION = OPS AND 'FFF'X
;
	RETURN
	END
