pro wrap_xrt_id_miss_pack, year, month, miss_p, miss_pn, tot_p, $
                           p_idx, file, ql=ql 
;+
; PROJECT: 
;       Solar-B / Hinode / XRT
; 
; NAME: 
;       WRAP_XRT_ECID_MONTHL
;
; CATEGORY:
;
;       Wrapper for XRT Data Verification Code XRT_ID_MISS_PACK
; 
; PURPOSE:
;
;       Evaluate how many data packets are missing in a
;       given month. 
;
;
; MODIFICATION HISTORY:
; 
progver='v2011.Feb.10'     ;--- K. Reeves, modified from WRAP_XRT_ECID_MONTHLY
;
;-
;==================================================================

  mm    = month
  mm0   = month - 1 
  if (month lt 10) then mm  = '0' + strtrim(month,1)
  if (month le 10) then mm1 = '0' + strtrim(month-1,1) else mm1 = month-1

  year1 = year
  if (month eq 1) then begin
     mm1   = 12                   ;
     year1 = year1 - 1            ;
  endif

  miss_p = 0ul                    ;
  miss_pn= 0ul                    ;
  tot_p  = 0ul                    ;
;  fi_idx = [0]                  ;
  p_idx  = [0]                  ;
  file   = ['']                 ;
  tstamp = ['']                 ;

; ignore what month it is. 
  for d = 1, 31 do begin 

     print, '--------------------------------' ;
     print, ' Processing the date: ' + strtrim(year,1) + '/' + strtrim(month,1) + $
            '/' + strtrim(d,1) + '  '
     print, '--------------------------------' ;

     
; initialize the key return values to zero. 

     miss_pi = 0
     tot_pi  = 0
     p_idxi  = 0
     filei   = ''

     xrt_id_miss_pack, year,month,d,miss_pi,tot_pi, p_idxi, filei

  ;   xrt_ecid, year, month, d, miss_fi, fi_idxi, tstampi, miss_pi, tot_pi, p_idxi, filei, $
   ;            obevfile=obevfile, /stop_default

     if ((filei[0] ne '') and (n_elements(filei) ne 1)) then begin
  
        hh = where(p_idxi ne 0, cnt) ;
        miss_pn = miss_pn + cnt      ;
        ;miss_f  = miss_f  + miss_fi  ;
        miss_p  = miss_p  + miss_pi  ;
        tot_p   = tot_p   + tot_pi   ;
        
        ;fi_idx  = [fi_idx, fi_idxi] ;
        p_idx   = [p_idx,  p_idxi ] ;
        file    = [file,   filei  ] ;
        ;tstamp  = [tstamp, tstampi] ;
        
        ;print, miss_f, miss_fi
        ;if (miss_f lt 0) then stop
        ;print, ' Number of Missing Files  : ' + strtrim(miss_fi,1)                                      ;
        print, ' Number of Missing Packets: ' + strtrim(miss_pi,1) + ' in unit of 64 pixels per packet' ;
        print, '                   (out of the expected total of ' + strtrim(tot_pi,1) + ' packets)'    ; 
        print, ' Number of Files with Missing Packets : ' + strtrim(cnt,1)                              ;

     endif
 
  endfor

  remove,[0], p_idx, file

  print,' '
  print,' * Process Complete * ' 
  print,' ' 
  tbeep, 5

  print, '  '
  print, '--------------------------------------------------------------------'
  print, '  '
  print, ' Missing XRT Packet Report for ' + strtrim(year,1) + '/' + strtrim(month,1) + ':'
  print, '  '
;  print, '  Number of Missing Files  : ' + strtrim(miss_f,1) 
  print, '  Number of Missing Packets: ' + strtrim(miss_p,1) + ' in unit of 64 pixels per packet' ;
  print, '                    (out of the expected total of ' + strtrim(tot_p,1) + ' packets)'    ; 
  print, '  Number of Files with Missing Packets : ' + strtrim(miss_pn,1)                         ;
  print, '  '
  print, '--------------------------------------------------------------------'


return
end
