change callsign to date
[spider.git] / cmd / show / vhfstats.pl
1 #
2 # Show total VHF DX Spot Stats per day
3 #
4 # Copyright (c) 2001 Dirk Koopman G1TLH
5 #
6 # $Id$
7 #
8
9 my ($self, $line) = @_;
10 my @f = split /\s+/, $line;
11 my $days = 31;
12 my $now = Julian::Day->new(time())->sub(31);
13 my $i;
14 my @in;
15
16 # generate the spot list
17 for ($i = 0; $i < $days; $i++) {
18         my $fh = $Spot::statp->open($now); # get the next file
19         unless ($fh) {
20                 Spot::genstats($now);
21                 $fh = $Spot::statp->open($now);
22         }
23         while (<$fh>) {
24                 chomp;
25                 my @l = split /\^/;
26                 next unless $l[0] eq 'TOTALS';
27                 next unless $l[1];
28                 $l[0] = $now; 
29                 push @in, \@l; 
30                 last;
31         }
32         $now = $now->add(1);
33 }
34
35 my @out;
36 my @tot;
37
38 push @out, $self->msg('statvhf');
39 push @out, sprintf "%11s|%6s|%5s|%5s|%5s|%5s|%5s|%5s|%5s|%5s|%5s|", qw(Date Total 6m 4m 2m 70cm 23cm 13cm 9cm 6cm 3cm);
40 foreach my $ref (@in) {
41         my $linetot = 0;
42         foreach my $j (12..14,16..21) {
43                 $tot[$j] += $ref->[$j];
44                 $tot[0] += $ref->[$j];
45                 $linetot += $ref->[$j];
46         }
47         push @out, join('|', sprintf("%11s|%6d", $ref->[0]->as_string, $linetot), map {$_ ? sprintf("%5d", $_) : '     '} @$ref[12..14,16..21]) . '|';
48 }
49 push @out, join('|', sprintf("%11s|%6d", 'Total', $tot[0]), map {$_ ? sprintf("%5d", $_) : '     '} @tot[12..14,16..21]) . '|';
50
51 return (1, @out);