;+
;PROJECT:
;           SolarB EIS
;
;NAME:      
;           db_save_raster_entry_create
;
;PURPOSE:
;           Function to save an eis_raster to the EIS raster databse
;
;CATEGORY:
;           EIS Technical Planning
;           Database
;
;INPUTS:
;           an eis_raster structure
;
;OPTIONAL INPUTS:
;           the top-level-base; useful if calling from a widget tool 
;           (eg; mk_raster). 
;
;MODIFICATION HISTORY:
;           Written by: John Rainnie, RAL - j.rainnie@rl.ac.uk (Dec 2005)
;
;-
;************************************************************************
PRO db_save_raster_entry_create , eis_raster , tlbID = tlbID

status = eis_open_db(/RASTER,/UPDATE)

dbbuild,  eis_raster.id                         ,                           $
          eis_raster.write_locked               ,                           $
          eis_raster.acronym                    ,                           $
          eis_raster.title                      ,                           $
          eis_raster.author                     ,                           $
          eis_raster.date                       ,                           $
          eis_raster.rasterType                 ,                           $
          eis_raster.scan_FM_nSteps             ,                           $
          eis_raster.scan_FM_stepSize           ,                           $
          eis_raster.sns_nExps                  ,                           $
          eis_raster.sns_duration               ,                           $
          eis_raster.ll_id                      ,                           $
          eis_raster.nWindows                   ,                           $
          eis_raster.dataWindows[*]             ,                           $
          eis_raster.windHeight                 ,                           $
          eis_raster.windWidth                  ,                           $
          eis_raster.slitIndex                  ,                           $
          eis_raster.nExp                       ,                           $
          eis_raster.exposures[*]               ,                           $
          eis_raster.delays[*]                  ,                           $
          eis_raster.compression                ,                           $
          eis_raster.split                      ,                           $
          eis_raster.duration                   ,                           $
          eis_raster.volume
dbclose

; ID needs to be in 000001 format
idValue = STRING(format='(I06)',eis_raster.ID)
messageText = ["Raster has been successfully saved." ,                      $
               ""                                       ,                   $
               "ID          = " + idValue               ,                   $
               "Description = " + eis_raster.acronym  ]
; If a tlbID is given, then display a pop-up box
IF (KEYWORD_SET(tlbID) EQ 1) THEN BEGIN
    complain = DIALOG_MESSAGE( messageText ,                                $
                                 DIALOG_PARENT = tlbID,                     $
                                 /INFORMATION )
ENDIF ELSE BEGIN
    print,messageText
ENDELSE


END
