pro pr_seq_frame_info, sttim, entim, mat, str, hk0, quiet=quiet, $
		qplot=qplot, qcheck=qcheck, outfil=outfil, $
		inmat=inmat, tit=tit, inhk0=inhk0
;+
;NAME:
;	pr_seq_frame_info
;PURPOSE:
;	To display the per-frame information
;SAMPLE CALLING SEQUENCE:
;	pr_seq_frame_info,'31-mar','31-mar 1:00'
;	pr_seq_frame_info, sttim, entim, mat, str, outfil='filename.txt'
;	pr_seq_frame_info, inmat=mat
;INPUT:
;	sttim	- the starting time
;	entim	- the ending time
;OUTPUT:
;	mat	- the 2-d array of the information from the HK data
;	str	- the string array of the information being displayed
;OPTIONAL KEYWORD INPUT:
;	quiet	- If set, don't display the data (pass it as output)
;	qplot	- If set, plot the exposure duration data
;	qcheck	- If set, display each instance where the exposure
;		  falls in a predifined range
;	inmat	- the 2-d array from the HK data (must pass "inhk" also)
;	inhk	- the HK structure
;	outfil	- the output file to write the info to
;OPTIONAL KEYWORD OUTPUT:
;	tit	- the title array (5 lines)
;HISTORY:
;	Written 1-Apr-96 by M.Morrison
;-
;
if (n_elements(inmat) eq 0) then begin
    seq_frame_info, sttim, entim, mat, hk0
    mat = rotate(mat,4)
end else begin
    mat = inmat
    hk0 = inhk0
    if (n_elements(mat(*,0)) gt 14) then mat = rotate(mat,4)
end
;
expos = (mat(5,*)-mat(4,*))/256.
n = n_elements(expos)
daytim = fmt_tim(anytim2ints(hk0.mdi.daytime(0), off=double(reform(mat(0,*)))))
;
str0 = strarr(n)
for i=0L,n-1 do str0(i) = string(mat(*,i), expos(i), daytim(i), format='(14i7, f8.3, 1x, a)')
str = str0
;
;          A  B   C   D     E     F      G       H       I      J       K      L      M
breaks = [0, 0, 19, 20, 40.0, 40.1, 150.0, 150.16, 150.22, 150.4, 224.98, 225.1, 225.2]
nb = n_elements(breaks)
;
for i=0,nb-2 do begin
    ss = where((expos gt breaks(i)) and (expos le breaks(i+1)), nss)
    mark = ' ' + string(byte(i+65))
    if (nss ne 0) then str(ss) = str(ss) + mark
end

if (keyword_set(qplot)) then plot_expos_hist, sttim, entim, inmat=mat
;
if (keyword_set(qcheck)) then begin
    ;
    for i=0,nb-2 do begin
        ss = where((expos gt breaks(i)) and (expos le breaks(i+1)), nss)
        for j=0,nss-1 do begin
	    ist = (ss(j)-10)>0
	    ien = ss(j)+10
	    prstr, str(ist:ien)
	    pause
	end
    end
end
;
tit = ['PR_SEQ_FRAME_INFO  Ver 1.0  Program Run: ' + ut_time() + ' UT', $
	' ', $
	;     15      3      1    216   3883  42356    125    116     84     55     17    515      0      0 150.285 31-MAR-96  00:00:21 I
	'   Seconds #Frames Pntr  Rel     Shutter      PAW     M1     M2    CAL1   CAL2   Seq   Device   -- Exposure   Date   Time  Code', $
        '                        Time   Open  Close                                      Addr   Error       (msec) ', $
	' ']
;
if (not keyword_set(quiet)) then prstr, [tit,str], nomore=nomore
if (keyword_set(outfil)) then prstr, [tit,str], file=outfil
end
