;+
; NAME:  
;    plot_xrt_software_mode
;
; PURPOSE: 
;    plot XRT software mode values for xrt metrics 
;
; CALLING SEQUENCE:
; 
;    plot_xrt_software_mode, start_time, end_time, $
;                            [,gif_dir=gif_dir]
; INPUTS:
;
;    start_time: [Mandatory] Beginning of timerange to plot
;    end_time:   [Mandatory] End of timerange to plot
;
; OPTIONAL INPUTS:
;
;    None
;
; KEYWORD PARAMETERS:
;
;    gif_dir:  Directory to save gif file in
;
; OUTPUTS:
;
;    gif file plot of software mode, saved as xrt_software_mode_yyyymm.gif
;
; OPTIONAL OUTPUTS:
;
;    None
;
;
; EXAMPLE: 
;
;    plot_xrt_software_mode, '1-Apr-2008 00:00:00', '30-Apr-2008 00:00:00',$
;                             gif_dir = '/home/mweber/'
;
;;
; MODIFICATION HISTORY:
;
;    Written 05-08-2008 by KKR. 
;    Based heavily on plot_hk_val_vs2.pro, by KKR & PRJ
;  
;-

pro plot_xrt_software_mode, start_time, end_time, gif_dir=gif_dir



  hk_key = 'mod_S_SOFTWARE_MODE_'
 
  if not keyword_set(gif_dir) then gif_dir = './'

  get_xrt_hk_value, hk_key, start_time, end_time, data_str

  plot_xrt_hk_value, hk_key, data_str, start_time, end_time, 8, 0

  legend, ['0 - Reserved','1 - Standby', '2 - Operations', '3 - Safehold',$
           '4 - Bakeout','5 - Maintenance', '6 - Critical command',$
           '7 - Diagnostic'], /left, /top

;; write gif file

  gif_file = gif_dir+ 'xrt_software_mode_' + $
             strmid(anytim2cal(start_time, form=8),0,6) + '.gif'

  write_gif, gif_file, tvrd()
  print,'Wrote image as: ',gif_file



end
