;+
; PROJECT
;          SolarB EIS
;
; NAME
;          EIS_FLARE_PROPS_SAME
;
; PURPOSE
;          Function which ...
;
; CATEGORY
;          Timeline planning (timeline)
;
; WRITTEN
;          John Rainnie, RAL, 7-Apr-2008
;
; HISTORY
;          v0.1 JAR 25-Oct-2010
;               Include locate_x/y droplists
;          v0.2 JAR 04-Dec-2014
;               Updated to use response DB entries (in line with XRTF)
;
;-
;______________________________________________________________________________
FUNCTION eis_flare_props_same , trigger_array

; Initialise triggers - which will be populated by an array of
; response DB entries
array = 0
FOR i = 0 , N_ELEMENTS(trigger_array) - 1 DO BEGIN

   resp_id  = trigger_array[i].resp_id
   response = db_read_response_entry(id = resp_id)

   ; Now add response DB entry to "triggers" array.
   IF (N_TAGS(array) EQ 0) THEN BEGIN
       ; Re-initialise the "array" array with the first entry
       array = response
   ENDIF ELSE BEGIN
       ; Concatenate new response DB entries to list
       old_array = array
       array     = [old_array , response]
   ENDELSE

ENDFOR

valid          = {valid:0B , mText:STRARR(4)}
valid.mText[0] = "There are multiple EIS Flare trigger studies"
valid.mText[1] = "which have different properties! They must all be"
valid.mText[2] = "the same since there is only one table permitted."

; Response Study ID
test = WHERE(array[0].response_st_id NE                                $
              array[1:*].response_st_id  , count)
IF (count NE 0) THEN BEGIN
    valid.mText[3] = "Response Study ID. Aborting!"
    RETURN , valid
ENDIF
; X Repoint
test = WHERE(array[0].adjust_x NE                                $
              array[1:*].adjust_x  , count)
IF (count NE 0) THEN BEGIN
    valid.mText[3] = "Adjust_Y. Aborting!"
    RETURN , valid
ENDIF
; Y Repoint
test = WHERE(array[0].adjust_y NE                                $
              array[1:*].adjust_y  , count)
IF (count NE 0) THEN BEGIN
    valid.mText[3] = "Adjust_Y. Aborting!"
    RETURN , valid
ENDIF
; Repoint Raster Index
test = WHERE(array[0].raster_identifier NE                                $
              array[1:*].raster_identifier  , count)
IF (count NE 0) THEN BEGIN
    valid.mText[3] = "Raster Identifier. Aborting!"
    RETURN , valid
ENDIF
; X Min Limit
test = WHERE(array[0].x_min_limit NE                                $
              array[1:*].x_min_limit  , count)
IF (count NE 0) THEN BEGIN
    valid.mText[3] = "X Min Limit. Aborting!"
    RETURN , valid
ENDIF
; Y Min Limit
test = WHERE(array[0].y_min_limit NE                                $
              array[1:*].y_min_limit  , count)
IF (count NE 0) THEN BEGIN
    valid.mText[3] = "Y Min Limit. Aborting!"
    RETURN , valid
ENDIF
; X Threshold
test = WHERE(array[0].x_threshold NE                                $
              array[1:*].x_threshold  , count)
IF (count NE 0) THEN BEGIN
    valid.mText[3] = "X Threshold. Aborting!"
    RETURN , valid
ENDIF
; Y Threshold
test = WHERE(array[0].y_threshold NE                                $
              array[1:*].y_threshold  , count)
IF (count NE 0) THEN BEGIN
    valid.mText[3] = "Y Threshold. Aborting!"
    RETURN , valid
ENDIF
; Locate_x
test = WHERE(array[0].locate_x NE                                $
              array[1:*].locate_x  , count)
IF (count NE 0) THEN BEGIN
    valid.mText[3] = "Locate_X. Aborting!"
    RETURN , valid
ENDIF
; Locate_y
test = WHERE(array[0].locate_y NE                                $
              array[1:*].locate_y  , count)
IF (count NE 0) THEN BEGIN
    valid.mText[3] = "Locate_Y. Aborting!"
    RETURN , valid
ENDIF


;dummy = {eis_flare_component                                   ,           $
;               seq_id                        : 0L              ,           $
;               respond_to_eis_flare          : 0B              ,           $
;               response_study_id             : 0L              ,           $
;               x_repoint                     : 0B              ,           $
;               y_repoint                     : 0B              ,           $
;               repoint_raster_index          : 0               ,           $
;               flare_flag                    : BYTARR(25)      ,           $
;               x_pixel_threshold             : 0UL             ,           $
;               y_pixel_threshold             : 0UL             ,           $
;               locate_x                      : 0U              ,           $
;               locate_y                      : 0U              ,           $
;               x_min_limit                   : 0L              ,           $
;               y_min_limit                   : 0L                          $
;           }

valid.valid = 1

RETURN , valid

END


