pro gtab_pf_str, which_str, seqno, barr, str
;
;+
;NAME:
;	gtab_pf_str
;PURPOSE:
;	Convert the SXT PFI/FFI sequence table to string mnmonics
;INPUT:
;	which_str - 'F' or 'P' for FFI or PFI
;	seqno	- Sequence number 0-12
;	barr	- Binary array holding the sequence table (only
;		  the 24 bytes for the particular sequence)
;OUTPUT:
;	str	- Output string
;HISTORY:
;	Written 1989 by M.Morrison
;	21-Nov-91 (MDM) - Updated to use filter mnemonics
;			  Also changed notation that flush uses
;			  Also added exposure cadence
;	21-Apr-92 (MDM) - Fixed bug where PFI AEC and filter
;			  alternation was always showing OFF
;-
;
ref_loop = ['1-1    ', '  2-1  ', '  2-2  ', '    3-1', '    3-2', '    3-3', '    3-4', $
			'  4-1  ', '  4-2  ', '    5-1', '    5-2', '    5-3', '    5-4', '??']
ref_shut = ['F', 'M', '?']
ref_open_closed = ['Cl', 'Op', '??']
ref_imgtyp = ['????', 'Norm', 'Dark', 'Cal ', '??']	;check and confirm
ref_res = ['F', 'H', 'Q', '?']
ref_comp = ['C', 'L', 'H', '?']
ref_cad = ['N', 'H', 'U', '?']
ref_on_off = ['Off', 'On ', '???']
;
loop	= ref_loop(seqno<13)
;flush	= '  ' + string(barr(1), '(z2.2)') + 'h'
flush	= '  ' + string(mask(barr(1), 4, 4), mask(barr(1), 2, 2), mask(barr(1), 0, 2), format='(3Z1)')
shut 	= '  ' + ref_shut( barr(2) <2)
;filt	= '  ' + strtrim(barr(3)/16,2) + '/' + strtrim(barr(3) mod 16,2)
filt	= '  ' + gt_filtb(barr(3)/16, /short) + '/' + gt_filta(barr(3) mod 16, /short)
adoor	= ' ' + ref_open_closed(barr(6)<2)
dpe	= ' ' + string(barr(7), '(i2)')
imgtyp	= ' ' + ref_imgtyp(barr(8)<4)
res	= ' ' + ref_res( barr(9) mod 4)
comp	= ref_comp( barr(9)/4 mod 4)
inroi    = (barr(9)/16 mod 4)+1
nroi    = strtrim( inroi,2 )
cad     = ref_cad(mask(barr(9), 6, 2))
;
str = loop + '                                                                  '
;if (filt ne '  7/7') then if (which_str eq 'F') then begin
if (filt ne '  ??/??') then if (which_str eq 'F') then begin
    roiarr = strarr(4,8)
    for i=0,7 do roiarr(i) = '   -'
    for i=0,inroi*2-1 do roiarr(i) = string( fix(barr(10+i)),'(i4)')
    roistr=''
    for i=0,7 do roistr = roistr + roiarr(i)
    fwimode 	= string( barr(18), '(i4)')
    bls		= '  ' + ref_on_off( barr(0) <2)

    str = loop + flush + shut + filt + adoor + dpe + imgtyp + res + comp + nroi + cad + $
	roistr + fwimode + bls
end else begin
    filt_alt1	= ' ' + strtrim(barr(4)/16,2) + '/' + strtrim(barr(4) mod 16,2)
    filt_alt2	= ' ' + strtrim(barr(5)/16,2) + '/' + strtrim(barr(5) mod 16,2)
    roit	= string(barr(10),'(i3)')
    alt		= '  ' + ref_on_off( barr(11)<2 )
    st_alt_lev	= string(barr(12), '(i3)')
    aec		= '  ' + ref_on_off( barr(13)<2 )
    aecstrarr = strarr(4,4)
    for i=0,3 do aecstrarr(i) = '   -'
    if (aec eq '  On ') then begin
	for i=0,1 do aecstrarr(i) = string(fix(barr(14+i)),'(i4)') ;ULT, LLT
	for i=0,1 do begin
	    temp = barr(16+i*2) + fix(barr(17+i*2))*256		;UAT, LAT
	    aecstrarr(i+2) = string(temp,'(i4)')
	end
    end
    aecstr = ''
    for i=0,3 do aecstr = aecstr + aecstrarr(i)
    if (alt eq '  Off') then begin
	filt_alt1 = '  - '
	filt_alt2 = '  - '
    end

    str = loop + flush + shut + filt + filt_alt1 + filt_alt2 + $
		adoor + dpe + imgtyp + res + comp + nroi + cad + $
		roit + alt + st_alt_lev + aec + aecstr
end

end

