;+
;Project    :SolarB EIS
;
;Name       :eis_generate_raster_title
;
;Purpose    :Used for eis_mk_raster interface
;
;Category   :EIS technical planning
;
;Input      :structure of type eis_raster
;
;Output     :string
;
;Written    :Chunkey Lepine, RAL, d.r.lepine@rl.ac.uk, 0044-1235-44-6515
;
;Version    :V0 October 2005
;
;-
;************************************************************************

FUNCTION eis_generate_raster_title, ra

;print,'generating raster title'
    CASE ra.slitindex OF
            0: Slit = '1"'
            1: Slit = '250"'
            2: Slit = '2"'
            3: Slit = '40"'
            ELSE:  stop
    ENDCASE

; Update exposure times label
expTimeValue = STRARR(ra.nExp)
FOR i = 0,ra.nExp -1 DO BEGIN

    expTime = ra.exposures[i]/1000.
    delTime = ra.delays[i]

    blah1 = STRCOMPRESS( STRING(format='(F-6.2)',expTime),/REMOVE_ALL)
    blah2 = STRCOMPRESS( STRING(format='(I-6)',delTime),/REMOVE_ALL)

    expTimeValue[i] = blah1 + '(' + blah2 + ')'

ENDFOR
expTime = STRJOIN(['[ExpT(Delay):',expTimeValue,']'],/single)

windows = '[wH:'    + STRING(format='(I4)'  , ra.windHeight) + ','    +     $
          'nWins:'  + STRING(format='(I2)'  , ra.nWindows)   + ','    +     $
          'LL:'     + STRING(format='(I06)' , ra.ll_id)     ; + ']'

IF (ra.split EQ 1) THEN split = '(s)' ELSE split = ''
windows = STRJOIN([windows,split,']'],/SINGLE)


; Raster Type
IF (ra.rasterType EQ 0) THEN BEGIN
    rType = '[Scan:'
    steps = STRING(format='(I4)',ra.scan_FM_nSteps)   + '('
    sSize = STRING(format='(I4)',ra.scan_FM_stepSize) + '")steps]'
    rT    = STRJOIN([rType,steps,sSize] , /SINGLE)
ENDIF ELSE BEGIN
    IF (ra.sns_nExps EQ 1) THEN blah = 'set' ELSE blah = 'sets'
    rT = '[SNS:'  +  STRING(format='(I5)',ra.sns_nExps)  + blah + ']'
ENDELSE

ra_id      = '[RA:'    + STRING(format='(I06)' , ra.id)      + ']'
slitSlot   = '[ss:'    + STRING(format='(A3)',Slit)          + ']'
nExposures = '[Exps:'  + expTimeValue                        + ']'

titleString = [ra_id,rt,slitSlot,windows,expTime]
title       = STRCOMPRESS(STRJOIN(titleString , /SINGLE) , /REMOVE_ALL)

RETURN, title

END
