;$Id: eis_data__read.pro 405 2010-07-04 11:21:38Z viggoh $
;+
; NAME:
;       EIS_DATA__READ
;
; PURPOSE:
;       EIS_DATA__READ reads EIS data files and stores data and other
;       information in the object fields of an EIS_DATA class object. 
;
; CATEGORY:
;       Hansteen/Wikstol Data analysis SW
;
; CALLING SEQUENCE:
;       An object of class EIS_DATA is declared with this statement: 
;                   eis_data = obj_new('eis_data')
;
;       EIS_DATA__READ reads EIS data files and stores information
;       into the object, with this statement:
;                     eis_data-> read, filename [, eis_hdr = eis_hdr]
;
;       If called from within an eis_data procedure, the
;       EIS_DATA__READ statement looks like this:
;                     self-> read, file [, eis_hdr = eis_hdr]
;
; INPUTS:
;       file:  Name of file (string) containing EIS data (and headers).
;
; KEYWORD PARAMETERS:
;       eis_hdr: Set this keyword to obtain also the header
;       information in the form of an object of type EIS_HDR. 
;
; OUTPUTS:
;       Reads EIS data files and fills the parameters of the EIS_DATA
;       object with information.
;
; CALLS:
;       EIS_HDR__DEFINE
;       EIS_HDR__READ
;       CCSDS_HDR__DEFINE
;       CCSDS_HDR__READ
;
; COMMON BLOCKS:
;       
;
; PROCEDURE:
;       
;       
;
; RESTRICTIONS:
;
;
; MODIFICATION HISTORY:
;       28-Mar-2001: Oivind Wikstol.
;       21-Sep-2001: Oivind Wikstol. Added documentation.
;        3-Jul-2008: A. Gardini    . Added init keyword.
;-
pro eis_data::read, file, hdr = hdr, error=error, init=init
  if n_elements(init) eq 1 then return
  catch,error
  if error ne 0 then begin 
    catch,/cancel
    message = dialog_message(!error_state.msg, /error)
    return
  endif
  if n_params() ne 1 then begin
    message, 'No datafile specified!', /informational
    message, 'usage: read_data, file, eis_hdr = eis_hdr', $
              /informational
    return
  endif
  case self.datasource of
    'ccsds': self-> readccsds, file, eis_hdr = hdr
    'fits': self-> readfits, file, hdr = hdr
    'xrt': self-> readforeign, file, hdr = hdr
    'sot': self-> readforeign, file, hdr = hdr
    else: begin
            ok=dialog_message('Invalid datasource '+self.fit+'!!')
          end
  endcase
end
