;+
; PROJECT
;
;           Solar-B EIS
;
; NAME
;           EIS_GET_TL_ENTRY
;
;
; PURPOSE
;
;           Function to return an entry from the timeline (as-planned)
;           database
;
; INPUTS
;
;           seq_id - the sequence_id of the entry
;
; OUPUTS
;
;           tl
;
; CATEGORY
;
;           EIS Timeline Planning
;
; WRITTEN
;           John A Rainnie RAL Feb-2006
;
; HISTORY
;
;           v0.1 JAR 26-Mar-2007
;               Introduced check that this entry exists
;           v0.2 JAR 18-Apr-2007
;               Included message when more than 1 entry exists, including
;               a print of those values.
;-
;************************************************************************
FUNCTION eis_get_tl_entry , seq_id

;replace call to astrolib
defsysv,'!DEBUG', 0
defsysv,'!TEXTUNIT', 0
defsysv,'!PRIV', 2
defsysv,'!TEXTOUT', EXIST = EXIST

status = eis_open_db(/TIME)

r      = dbfind('SEQUENCE_ID = ' + STRCOMPRESS(seq_id,/REMOVE_ALL) ,        $
                           count = count , /SILENT)

IF (count  EQ 0   ) THEN BEGIN
    print,"+++++++++++++++++++++++++++++++++++++++"
    print,"Timeline Entry (seq_id = "           +                           $
                STRCOMPRESS(seq_id,/REMOVE) + ") NOT found"
    print,"+++++++++++++++++++++++++++++++++++++++"
    RETURN , -1
ENDIF

IF (count  GT 1   ) THEN BEGIN

    nEntries = STRCOMPRESS(count , /REMOVE_ALL)
    print,"+++++++++++++++++++++++++++++++++++++++"
    print,STRJOIN(["There are ",nEntries, " entries for this "  +           $
                   "sequence_id..."],/SINGLE)
    print,r
    print,"+++++++++++++++++++++++++++++++++++++++"
    RETURN , -1

ENDIF

tl = {eis_timeline_entry}
tl.time_component    = eis_get_timeline_details(seq_id)
tl.science_component = eis_get_science_entry(seq_id)

RETURN , tl

END
