pro ipcom, seq_filnam, hc=hc
;+
;NAME:
;	ipcom
;PURPOSE:
;	TO evaluate the IP commision LFFT test
;SAMPLE CALLING SEQUENCE:
;	ipcom, '/md66/log/sci160k/940417_033526
;INPUT:
;	seq_filnam - The sequence or telemetry file name
;OPTIONAL KEYWORD INPUT:
;	hc	- If set, produce a hardcopy (don't display to the screen)
;HISTORY:
;	Written 18-Apr-94 by M.Morrison
;	17-Jul-95 (MDM) - Removed "rdtfr2" compilation
;V2.0	24-Aug-95 (MDM) - Modified to use different set of images for
;			  the DMA add and subract check
;			  OLD: [6,7,8,9]	NEW: [8,9,10,11]
;-
;
progver = 'IPCOM.PRO  Ver 2.0'
;
if (keyword_set(hc)) then begin
    save_device = !d.name
    set_plot, 'ps
    device, /land
end
;
ans_arr = ['FAILED', 'PASSED']
step = .03
!p.multi = [0,2,2]
;
;----- IPTBLTST (table test)
;
tit_arr = ['SQRT Table', 'Reciprical Table', 'Velocity Table']
for i=0,2 do begin				;ffffff70-72
    read_mdi, seq_filnam, 3+i, img, head
    dattim = gt_day(sxpar(head, 'DATE-OBS'),/str) + '  ' +  sxpar(head, 'TIME-OBS')          ;convert to letter format
    ;
    plot, img, ytit=tit_arr(i), tit=dattim
end
;
;---- IPMEMTST (Memory and Compression Algorithm test)
;
read_mdi, seq_filnam, [0,1,2], img, head	;ffffff60-62
;
check = img(*,*,0) - img(*,*,1)
ss = where(check ne 0, n1)
;
check = img(*,*,0) - img(*,*,2)
ss = where(check ne 0, n2)
;
xyouts, .5, .5 - 3*step, /norm, 'MEM Test:  Image Compression: ' + ans_arr( n1 eq 0 )
xyouts, .5, .5 - 4*step, /norm, 'MEM Test:  Image Packing:     ' + ans_arr( n2 eq 0 )
;
;---- IPDMATST (DMA test)
;
;read_mdi, seq_filnam, [6,7,8,9], img, head
read_mdi, seq_filnam, [8,9,10,11], img, head	;ffffff50-52
img = temporary(img(*,1:1007,*))	;differences after line 1007 are because only 1024x1024 words are sent down (?)
diff = img(*,*,0) - img(*,*,1)
sum = img(*,*,1) + img(*,*,0)
;
check = sum - img(*,*,2)
ss = where(check ne 0, nsum)
;
check = diff - img(*,*,3)
ss = where(check ne 0, ndiff)
;
xyouts, .5, .5 - 7*step, /norm, 'DMA Test:  Image Subtraction: ' + ans_arr( ndiff eq 0 )
xyouts, .5, .5 - 8*step, /norm, 'DMA Test:  Image Addition:    ' + ans_arr( nsum eq 0 )
;
;---- IPDYNTST (Dynamics Test)
;
xyouts, .5, .5 - 11*step, /norm, 'Dynamics Test:  SQRT Table Lookup: ' + '??'
xyouts, .5, .5 - 12*step, /norm, 'Dynamics Test:  Velocity Table Lookup: ' + '??'

plottime, 0, 0, progver
plottime
!p.multi = 0
;
if (!d.name eq 'PS') then begin
    pprint
    if (n_elements(save_device) ne 0) then set_plot, save_device
end
;
end
