pro idx_check,log ; Created 4/24/98 by C. See ; This program pulls out information on the first & last 3 packets, ; from each side, from the idx file and places them in the test Log ; in a file called idx_check.out ; The current directory is the default cd,'',current=cdir & cd,cdir ; if n_params() eq 0 then log = cdir+'\' file_ck=findfile(Log+'idx2') if file_ck(0) eq '' then input_file='idx' else input_file='idx2' close,1 openr,1,log+input_file seqno='' time = '' rest = '' lastA='' second2lastA='' third2lastA='' lastB='' second2lastB='' third2lastB='' flag1=0 lines=strarr(12) ;lines(0:2)=first A packets, lines(3:5)=first B packets, etc. count=lonarr(2) ;count(0) is A and count(1) is B while not eof(1) do begin readf,1,seqno,time,rest,format ='(a8,a10,a)' ;For the first packet calculate the start time if flag1 eq 0 and strpos(rest,' Telem ') ne -1 then begin starttime=time flag1=1 endif if strpos(rest,' Telem A ') ne -1 then begin count(0)=count(0)+1 if count(0) le 3 then lines(count(0)-1)=seqno+time+rest ;captures the first 3 third2lastA=second2lastA ;captures the last 3 second2lastA=lastA lastA=seqno+time+rest endif if strpos(rest,' Telem B ') ne -1 then begin count(1)=count(1)+1 if count(1) le 3 then lines(count(1)+2)=seqno+time+rest ;captures the first 3 third2lastB=second2lastB ;captures the last 3 second2lastB=lastB lastB=seqno+time+rest endif if strpos(rest,' Telem ') ne -1 then endtime=time ;captures the last time endwhile ;There is no time like the present... mtime=sstr(starttime) hrs=float(strmid(mtime,0,2)) min=float(strmid(mtime,3,2)) sec=float(strmid(mtime,6,2)) starttime=sec+60*min+3600*hrs mtime=sstr(endtime) hrs=float(strmid(mtime,0,2)) min=float(strmid(mtime,3,2)) sec=float(strmid(mtime,6,2)) endtime=sec+60*min+3600*hrs totaltime=endtime-starttime ;Total on time in seconds if totaltime lt 0 then totaltime=totaltime+86400 ;corrects for clock rollover hrs=fix(totaltime/3600) min=fix((totaltime-hrs*3600)/60) sec=fix(totaltime-hrs*3600-min*60) ;Calculate the expected number of counts... remainder_a=strmid(lastA,strpos(lastA,' #')+2,6) ;acounts=long(totaltime/4464)*16384+long(remainder_a) ;4464 was 3511 (adj for flight data) acounts=long(count(0)/16384)*16384+long(remainder_a) ;roll over + remainder remainder_b=strmid(lastB,strpos(lastB,' #')+2,6) ;bcounts=long(totaltime/4464)*16384+long(remainder_b) ;4464 was 3511 (adj for flight data) bcounts=long(count(1)/16384)*16384+long(remainder_b) ;roll over + remainder ;Print it out... lines(6)=third2lastA lines(7)=second2lastA lines(8)=lastA lines(9)=third2lastB lines(10)=second2lastB lines(11)=lastB close,2 openw,2,Log+'idx_check.out' printf,2,"____________________________________________________________________" printf,2,"This is the First & Last Packets information from the idx file for: " printf,2,' ',cdir printf,2,"" printf,2,"" printf,2,'First Packets:' printf,2,'' printf,2," Seq. # Time Packet Information..." for i=0,5 do Printf,2,lines(i) printf,2,"" printf,2,'Last Packets:' printf,2,'' printf,2," Seq. # Time Packet Information..." for i=6,11 do Printf,2,lines(i) printf,2,"" printf,2,"" printf,2,'The total DISR ON time was: ',sstr(hrs)+':'+sstr(min)+':'+sstr(sec),' hms' printf,2,'A typical CO1 runs 02:18:28 hms' printf,2,'A typical CO2 runs 01:13:25 hms' printf,2,"" Printf,2,'The number of packets received were:' printf,2,' Side A Side B Total' Printf,2,'Counted Packets ',sstr(count(0)),' ',sstr(count(1)),' ',sstr(count(0)+count(1)) Printf,2,'Numbered Packets ',sstr(acounts),' ',sstr(bcounts),' ',sstr(acounts+bcounts) Printf,2,'Typical for CO1 ~37300 ~37100 ~74400' Printf,2,'Typical for CO2 ~18230 ~18230 ~36460' printf,2,"" Printf,2,'The ratio of Counted Packets/Numbered Packets is: ',sstr(float(count(0)+count(1))/float(acounts+bcounts)) Printf,2,'If this ratio is less that 1, some packets are missing' Printf,2,'If this ratio is greater than 1, there was probably a reset' printf,2,"" close,/all cd,log,current=cdir spawn,'more -e idx_check.out' cd,cdir end