remove $Id$ strings from everywhere that I can find
[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 #
7 #
8
9 my ($self, $line) = @_;
10 my @f = split /\s+/, $line;
11 my $days = 31;
12 my $i;
13 my @in;
14 my $now;
15 my $date = cldate($main::systime);
16 my $utime = $main::systime;
17 my @out;
18
19 while (@f) {
20         my $f = shift @f;
21
22         if ($f =~ /^\d+$/ && $f < 366) {                # no of days
23                 $days = $f;
24                 next;
25         }
26         if (my $ut = Date::Parse::str2time($f)) {       # is it a parseable date?
27                 $utime = $ut+3600;
28                 next;
29         }
30         push @out, $self->msg('e33', $f);
31 }
32
33 return (1, @out) if @out;
34
35 $now = Julian::Day->new($utime);
36 $now = $now->sub($days);
37 $date = cldate($utime);
38
39 # generate the spot list
40 for ($i = 0; $i < $days; $i++) {
41         my $fh = $Spot::statp->open($now); # get the next file
42         unless ($fh) {
43                 Spot::genstats($now);
44                 $fh = $Spot::statp->open($now);
45         }
46         while (<$fh>) {
47                 chomp;
48                 my @l = split /\^/;
49                 next unless $l[0] eq 'TOTALS';
50                 next unless $l[1];
51                 $l[0] = $now; 
52                 push @in, \@l; 
53                 last;
54         }
55         $now = $now->add(1);
56 }
57
58 my @tot;
59
60 push @out, $self->msg('statvhf', $date, $days);
61 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);
62 foreach my $ref (@in) {
63         my $linetot = 0;
64         foreach my $j (14..16,18..23) {
65                 $tot[$j] += $ref->[$j];
66                 $tot[0] += $ref->[$j];
67                 $linetot += $ref->[$j];
68         }
69         push @out, join('|', sprintf("%11s|%6d", $ref->[0]->as_string, $linetot), map {$_ ? sprintf("%5d", $_) : '     '} @$ref[14..16,18..23]) . '|';
70 }
71 push @out, join('|', sprintf("%11s|%6d", 'Total', $tot[0]), map {$_ ? sprintf("%5d", $_) : '     '} @tot[14..16,18..23]) . '|';
72
73 return (1, @out);