;+
; Project     : SOHO - CDS     
;                   
; Name        : SHOW_CDS_TEMP
;               
; Purpose     : Plot CDS temperature statistics.
;               
; Explanation : Reads temperature log and allows any parameter to be plotted.
;               
; Use         : IDL> show_cds_temp [,timerange=...]
;
; Inputs      : None
;               
; Opt. Inputs : None
;
; Outputs     : None
;               
; Opt. Outputs: None
;               
; Keywords    : TIMERANGE - A 2-element string array giving the start and
;                           stop times for plotting.  Elements are CDS string
;                           format.
;
;                           Note the time range can also be specified 
;                           graphically within the program.
;               SINGLE    - if given, hardcopy plots are printed singly.
;
; Calls       : CDS_TEMP_MENU
;
; Common      : cds_temperature.com
;               
; Restrictions: Requires $CDS_ENG_DATA
;               
; Side effects: 
;               
; Category    : Telemetry
;               
; Prev. Hist. : None
;
; Written     : C D Pike, RAL, 27-oct-95
;               
; Modified    : Add SINGLE keyword.  CDP, 18-Dec-95
;
; Version     : Version 1, 27-Oct-95
;-            

pro show_cds_temp, timerange=timerange, single=single


; 
;  common for communication
;
@cds_temperature.com

;
;  has the correct evar been defined
;
if getenv('CDS_ENG_DATA') eq '' then begin
   bell
   print,'$CDS_ENG_DATA is not defined.'
   return
endif

;
;  format for hardcopies?
;
if keyword_set(single) then single_plot=1 else single_plot=0

;
;  get the mask etc details for the mnemonic comments
;
get_mask_etc, mask

;
;  read the temperature log data
;
cds_temp_log = 0
if file_exist(concat_dir('$CDS_ENG_DATA','temperature_log')) then begin
   restore,concat_dir('$CDS_ENG_DATA','temperature_log')
endif else begin
   bell
   print,concat_dir('$CDS_ENG_DATA','temperature_log')
   print,'Temperature log file does not exist.'
   return
endelse

;
;  format the names together with the comment field for info
;
n = where(strmid(mask(0,*),1,1) eq 'T')
full_names = strpad(cds_temp_log.name,15,/after) + mask(17,n)


;
;  set up default time range
;
if not keyword_set(timerange) then begin
   tplot_min = min(cds_temp_log(0).time)
   tplot_max = max(cds_temp_log(0).time)
endif else begin
   if datatype(timerange(0),1) eq 'String' and $
          n_elements(timerange) eq 2 then begin
      tplot_min = utc2tai(str2utc(timerange(0)))
      tplot_max = utc2tai(str2utc(timerange(1)))
   endif else begin
      bell
      print,'Invalid time range specification'
      print,"Timerange: ['start time','end time']"
      return
   endelse
endelse

print,anytim2cal(tplot_min)
print,anytim2cal(tplot_max)

;
;  Set up the widgets
;
cds_temp_menu



end

