## Initializes some variables and starts a software. my $nff = new NffInterface; my $logid = $nff->loadLog($inputFile); ## Picks an index in the log my $fid1 = $nff->createFilter($logid, {type => "logcode", logcode => 0x1069}); my $fid2 = $nff->createFilter($logid, {type => "logcode", logcode => 0x108A}); ## Creates an array of multiple filters on order of the particular logId. my $view = $nff->createView([ $fid1, $fid2 ]); my @hist; ## Iterates on filter indices and gets the next log in the view array. while((my $log = $nff->getNextLogFromView($view)) != -1){ my $code = getLogCode($log); printf "%X\n", $code; if($code == 0x108A){ # use == for numbers my $fngpkt = parse108A($log); # fngpkt instead of obj1 my $slen = $fngpkt->{numF}; for(my $i = 0; $i < $slen; $i++){ my $sum = 0; my $sec = $fngpkt->{sectors}{$i}; my $flen = $sec->{numFingers}; for(my $j = 0; $j < $flen; $j++){ $sum += $sec->{$j}{c2i}; } ## collects the sum for each SECTOR... ## note that c2i history entries have 2 elements print "c2i sum = $sum\n"; push @hist, [ $fngpkt->{timestamp}, $sum ]; } }elsif($code == 0x1069){ my $logpkt = parse1069($log); # logpkt (or something) instead of obj2 ## agc entries have 3 elements push @hist, [ $logpkt->{timestamp}, $logpkt->{0}{rxAgc0}, $logpkt->{1}{rxAgc0} ]; } } ## Now we have a history of the data we care about... calcstuff(\@hist); sub isc2i { my ($elt) = @_; return @$elt == 2; } sub isagc { my ($elt) = @_; return @$elt == 3; } sub recentagcs { my ($hist, $idx) = @_; my $pivot = $hist->[$idx]; my @fnd; # search backwards my $i = $idx - 1; while($i >= 0){ my $x = $hist->[$i--]; unless(freshentry($pivot, $x)){ last } if(isagc($x)){ unshift @fnd, $hist; } } # search forwards $i = $idx + 1; while($i <= $#$hist){ my $x = $hist->[$i++]; unless(freshentry($pivot, $x)){ last } if(isagc($x)){ push @fnd, $hist; } } return \@fnd; } my $FRESHMS = 50; sub freshentry { my ($l, $r) = @_; # timestamps are the first elem return (abs($l->[0] - $r->[0]) <= $FRESHMS); } sub calcstuff { my ($hist) = @_; for my $i (0 .. $#$hist){ my $log = $hist->[$i]; if(isc2i($log)){ my $agcs = recentagcs($hist, $i); for my $agc (@$agcs){ ## ... etc ... } } } }