;+
; Project     :	SOHO - CDS
;
; Name        :	SET_EXPOSURE()
;
; Purpose     :	Sets the exposure units for a given exposure time.
;
; Explanation :	The units the VDS exposure time is specified in are
;               variable. This routine chooses suitable units for 
;               a particular exposure time.
;               The GIS uses fixed 100 ms exposure units.
;
; Use         : < set_exposure, exposure_time, raster >
;
; Inputs      : exposure_time : exposure time in seconds.
;               raster        : Structure containing raster information.
;               
; Opt. Inputs : None.
;
; Outputs     : Modifies the .expunits and .exptm fields of the raster
;               structure.
;
; Opt. Outputs:	None.
;
; Keywords    : None.
;
; Calls       :	None.
;                
; Common      :	None.
;
; Restrictions:	None.
;
; Side effects:	None.
;
; Category    :	Command preparation.
;
; Prev. Hist. :	None.
;
; Written     :	Version 0.0, Martin Carter, RAL, 11/8/95
;
; Modified    :	Version 0.1, 11/10/95, MKC
;                            Added GIS exposure time.
; 
; Version     :	Version 0.1, 11/10/95
;-
;**********************************************************

PRO set_exposure, exposure_time, raster

  ; check which detector

  IF raster.detector EQ 'N' THEN BEGIN

    ; NIS detector

    IF exposure_time GT 1023.0 THEN BEGIN

      MESSAGE, 'Exposure time too long' 

    ENDIF ELSE IF exposure_time GT 102.3 THEN BEGIN

      raster.expunits = 8 ; 1000 ms units

      raster.exptm    = FIX(ROUND(exposure_time/1.0))

    ENDIF ELSE IF exposure_time GT 10.23 THEN BEGIN

      raster.expunits = 4 ; 100 ms units

      raster.exptm    = FIX(ROUND(exposure_time/0.1))

    ENDIF ELSE IF exposure_time GT 1.023 THEN BEGIN

      raster.expunits = 2 ; 10 ms units

      raster.exptm    = FIX(ROUND(exposure_time/0.01))

    ENDIF ELSE BEGIN

      raster.expunits = 1 ; 1 ms units

      raster.exptm    = FIX(ROUND(exposure_time/0.001))

    ENDELSE

  ENDIF ELSE IF raster.detector EQ 'G' THEN BEGIN

    ; GIS detector

    raster.expunits = 4 ; 100 ms units

    raster.exptm    = FIX(ROUND(exposure_time/0.1))

  ENDIF ELSE BEGIN

    ; Invalid detector label

    MESSAGE, 'Invalid detector : ' + raster.detector

  ENDELSE

END
