pro telem_packet_checker,log,outfile ; PC version 11/23/04, CSee ; Last modified 9/28/98 by CSee ; Check a test logs idx file to look for mission packets on either side A or ; side B. Report missing packets to outfile. ; The default output filename is telem_packet_ck.out. It gets dumped in the ; analysed log. If no logname is specified, the current log is used. CSee if n_params() le 1 then outfile ='telem_packet_ck.out' ;csee 6/7/97 cd,'',current=cdir & cd,cdir ;csee 6/7/97 if n_params() eq 0 then Log = cdir+'\' ;csee 6/7/97 err = 0 ; <--error flag, csee 6/5/97 str='' side='' time='' last_a_packet=0L last_b_packet=0L no=0L cd,Log close,1 file_ck=findfile(Log+'DB2') if file_ck(0) eq '' then DB='DB' else DB='DB2' ;file_ck=findfile(Log+'idx2') ;if file_ck(0) eq '' then input_file='idx' else input_file='idx2' input_file='idx' ;% signs in idx2 present a problem openr,1,Log+input_file ;if n_params() eq 2 then begin ;ed csee 6/7/97 out_lun=2 close,out_lun openw,out_lun,outfile ;endif else begin ;ed csee 6/7/97 ; out_lun=-1 ;ed csee 6/7/97 ;endelse ;ed csee 6/7/97 first_a=1L ;ed csee 6/9/97 first_b=1L ;ed csee 6/9/97 printf,out_lun,'____________________________________' printf,out_lun,'Telemetry packet check for test log ',Log readf,1,str readf,1,str printf,out_lun,strmid(str,20,255) printf,out_lun,'' printf,out_lun,'Today is ',systime(0) ; Algorithm: ; Initialize: first_a = 1, last_a_packet = 0 ; Read packet number (no) ; if first_a eq 0 then <--this loop was bypassed by setting first_a = 1 ; 1) first_a = 1 ; 2) last_a_packet = 0 ; 3) goto, next: ; else if no eq last_a_packet +1 then <-- now flow starts here ; 1) last_a_packet = no ; 2) goto, next: ; else (if not #1 packet) ; 1) err = 1 ; 2) print error message ; last_a_packet = no ; goto, next: ;___________________________________________________________________________________ ;Find the time offset from the time datasets for mission time... ;files=findfile('DB/Time/*', count = nfiles) cd,Log+DB+'\Time',current=savedlog ;spawn,'ls',files & siz=size(files) & count=siz(1) files=t_getfil('*.*') & siz=size(files) & count=siz(1) ;for lots of files if files(0) eq '' then begin Print,'There were no Time datasets found, I am assuming an offset of 80 seconds' t_off=80 ;offset between DDB time and DISR time goto,onward_and_upward endif d_read,files(0),h,p t_off=(p(0,0)-p(1,0))/10000 ;uses the first two entrees in the time data sets Print,'The offset between the DDB time & DISR time = ',sstr(t_off),' seconds' Print,'For a typical system test (co1 or co2) the offset is 78 or 79 seconds' printf,out_lun,'The offset between the DDB time & DISR time = ',sstr(t_off),' seconds' Printf,out_lun,'For a typical system test (co1 or co2) the offset is 78 or 79 seconds' printf,out_lun,'' onward_and_upward: cd,savedlog flag=0 ;first packet flag while not eof(1) do begin readf,1,str if strpos(str,'Telem') ne -1 then begin reads,str,time,side,no,format='(9x,a8,9x,a1,2x,i)' ;reads,str,time,side,no,format='(9x,a8,10x,a1,2x,i6)' if flag eq 0 then first_packet_time=seconds(time) ;saves the time of the first packet flag=1 ;first packet found if side eq 'A' then begin if first_a eq 0 then begin first_a=1 last_a_packet=0 goto,next endif else begin ;if no eq (last_a_packet+1L) mod 16384 then begin if no eq (last_a_packet+1L) then begin last_a_packet=no goto,next endif else begin if no ne 1L then begin err = 1 ;csee 6/5/97 printf,out_lun,last_a_packet+1L,no-1L,sstr(no-last_a_packet-1L),$ format='("Side A packets ",i7," through ",i7," are missing! (",a," Packets)")' ;stop T1=(seconds(last_time)-first_packet_time+15+t_off)/60. T2=(seconds(time)-first_packet_time+15+t_off)/60. printf,out_lun,last_time,time,T1,T2,$ format='("These packets are between times ",a8," and ",a8," (",f6.2," & ",f6.2," min. MET)"/)' endif last_a_packet=no endelse endelse endif if side eq 'B' then begin if first_b eq 0 then begin first_b=1 last_b_packet=no goto,next endif else begin ;if no eq (last_b_packet+1L) mod 16384 then begin if no eq (last_b_packet+1L) then begin last_b_packet=no goto,next endif else begin if no ne 1L then begin err = 1 ;csee 6/5/97 printf,out_lun,last_b_packet+1L,no-1L,sstr(no-last_b_packet-1L),$ format='("Side B packets ",i7," through ",i7," are missing! (",a," Packets)")' ;stop T1=(seconds(last_time)-first_packet_time+15+t_off)/60. T2=(seconds(time)-first_packet_time+15+t_off)/60. printf,out_lun,last_time,time,T1,T2,$ format='("These packets are between times ",a8," and ",a8," (",f6.2," & ",f6.2," min. MET)"/)' endif last_b_packet=no endelse endelse endif endif next: last_time=time endwhile print,'This list is in the test Log as: telem_packet_ck.out',string(10b) if err eq 0 then printf,out_lun,'There were no packet errors!!' ;csee 6/5/97 close,1 close,2 cd,Log,curr=cdir spawn,"notepad telem_packet_ck.out" cd,cdir end