;+
;Project
;          Hinode/EIS
;
; Name
;          eis_response_props_initialize
;
; Purpose
;          To initialize eis_response_props structure values
;
; Category
;          Timeline planning
;          Response Studies
;
; Written
;          John Rainnie 20-Jan-2009
;
; Version
;          v0.0 JAR 01-01-2010
;               Blah
;
;-
;______________________________________________________________________________
FUNCTION eis_response_props_initialize , struct , seq_id , new_id = new_id

; Create empty response structure
r_struct = {eis_response_props}

;stop
IF (N_ELEMENTS(new_id) EQ 1) THEN r_struct.id = new_id

; Get name of input structure
struct_name = TAG_NAMES(struct, /STRUCTURE_NAME)

; Populate the r_struct structure
; Let's start off with the common tags
r_struct.trig_st_seqid = seq_id
r_struct.type          = 'None'

IF STRCMP(struct_name,'EIS_EVENT_CONTROL',/FOLD_CASE) THEN BEGIN
   r_struct.eebp_respond      = 1
   r_struct.xrtf_respond      = 0
   r_struct.eisf_respond      = 0
   r_struct.aece_respond      = 0
   r_struct.type              = 'EEBP'
   r_struct.x_threshold       = struct.x_threshold
   r_struct.y_threshold       = struct.y_threshold
   r_struct.x_min_limit       = struct.x_min_limit
   r_struct.y_min_limit       = struct.y_min_limit
   r_struct.adjust_x          = struct.adjust_x
   r_struct.adjust_y          = struct.adjust_y
   r_struct.response_st_id    = struct.response_identifier
   r_struct.raster_identifier = struct.raster_identifier
   r_struct.line_index        = struct.line_index
   
   r_struct.ra1_xcen          = struct.ra1_xcen   
   r_struct.ra1_ycen          = struct.ra1_ycen   
   r_struct.ra1_mip           = struct.ra1_mip    
   r_struct.ra1_yip           = struct.ra1_yip    
   r_struct.ra1_sc_x          = struct.ra1_sc_x   
   r_struct.ra1_sc_y          = struct.ra1_sc_y   
   r_struct.ra1_pointed       = struct.ra1_pointed
   r_struct.ra2_use           = struct.ra2_use    
   r_struct.ra2_xcen          = struct.ra2_xcen   
   r_struct.ra2_ycen          = struct.ra2_ycen   
   r_struct.ra2_mip           = struct.ra2_mip
   r_struct.ra2_yip           = struct.ra2_yip    
   r_struct.ra2_sc_x          = struct.ra2_sc_x
   r_struct.ra2_sc_y          = struct.ra2_sc_y
   
   
   
ENDIF
IF STRCMP(struct_name,'EIS_XRT_FLARE_CONTROL',/FOLD_CASE) THEN BEGIN
   r_struct.eebp_respond      = 0
   r_struct.xrtf_respond      = 1
   r_struct.eisf_respond      = 0
   r_struct.aece_respond      = 0
   r_struct.type              = 'XRTF'
;   r_struct.x_threshold       = struct.x_threshold
;   r_struct.y_threshold       = struct.y_threshold
;   r_struct.x_min_limit       = struct.x_min_limit
;   r_struct.y_min_limit       = struct.y_min_limit
   r_struct.adjust_x          = struct.adjust_x
   r_struct.adjust_y          = struct.adjust_y
   r_struct.response_st_id    = struct.response_identifier
   r_struct.raster_identifier = struct.raster_identifier
   r_struct.line_index        = struct.line_index
   r_struct.filler_st_id      = struct.filler_identifier
ENDIF

; Need to read these tags from the Response DB
; Open database
status     = eis_open_db(/RESPONSE)
; Get DB ID from seq_id tag
id_value   = STRCOMPRESS(seq_id,/REMOVE_ALL)
constraint = STRJOIN(['TRIG_ST_SEQID',id_value],'=',/SINGLE)
; Get corresponding ID
blah = dbfind(constraint , /SILENT , count = count)
; If not found, then bail out with what we already have
IF (count NE 1) THEN RETURN , r_struct
id   = blah[0]
; Fill in the blanks
r_struct.id           = dbval(id, 'ID'       )
r_struct.created      = dbval(id, 'CREATED'  )
r_struct.modified     = dbval(id, 'MODIFIED' )
r_struct.locate_x     = dbval(id, 'LOCATE_X' )
r_struct.locate_y     = dbval(id, 'LOCATE_Y' )
r_struct.filler_st_id = dbval(id, 'FILLER_ST_ID' )


RETURN , r_struct

END
