3 # The WCY analog of the WWV geomagnetic information and calculation module
5 # Copyright (c) 2000 - Dirk Koopman G1TLH
21 use vars qw($date $sfi $k $expk $a $r $sa $gmf $au @allowed @denied $fp $node $from
25 $fp = 0; # the DXLog fcb
26 $date = 0; # the unix time of the WWV (notional)
27 $sfi = 0; # the current SFI value
28 $k = 0; # the current K value
29 $a = 0; # the current A value
30 $r = 0; # the current R value
31 $sa = ""; # solar activity
32 $gmf = ""; # Geomag activity
33 $au = 'no'; # aurora warning
34 $node = ""; # originating node
35 $from = ""; # who this came from
36 @allowed = (); # if present only these callsigns are regarded as valid WWV updators
37 @denied = (); # if present ignore any wwv from these callsigns
38 $duplth = 20; # the length of text to use in the deduping
39 $dupage = 12*3600; # the length of time to hold spot dups
41 $dirprefix = "$main::data/wcy";
42 $param = "$dirprefix/param";
46 $fp = DXLog::new('wcy', 'dat', 'm');
47 do "$param" if -e "$param";
51 # write the current data away
54 my $fh = new IO::File;
55 open $fh, "> $param" or confess "can't open $param $!";
56 print $fh "# WCY data parameter file last mod:", scalar gmtime, "\n";
57 my $dd = new Data::Dumper([ $date, $sfi, $a, $k, $expk, $r, $sa, $gmf, $au, $from, $node, \@denied, \@allowed ], [qw(date sfi a k expk r sa gmf au from node *denied *allowed)]);
61 $fh->print($dd->Dumpxs);
65 $fp->writeunix($date, "$date^$sfi^$a^$k^$expk^$r^$sa^$gmf^$au^$from^$node");
68 # update WWV info in one go (usually from a PC23)
71 my ($mydate, $mytime, $mysfi, $mya, $myk, $myexpk, $myr, $mysa, $mygmf, $myau, $myfrom, $mynode) = @_;
72 if ((@allowed && grep {$_ eq $from} @allowed) ||
73 (@denied && !grep {$_ eq $from} @denied) ||
74 (@allowed == 0 && @denied == 0)) {
76 # my $trydate = cltounix($mydate, sprintf("%02d18Z", $mytime));
77 if ($mydate >= $date) {
81 $r = 0 unless abs ($mysfi - $sfi) > 3;
100 # add or substract an allowed callsign
105 push @allowed, map {uc $_} @_;
109 @allowed = map {$_ ne uc $c} @allowed;
115 # add or substract a denied callsign
120 push @denied, map {uc $_} @_;
124 @denied = map {$_ ne uc $c} @denied;
131 # print some items from the log backwards in time
133 # This command outputs a list of n lines starting from line $from to $to
139 my @date = $fp->unixtoj(shift);
150 for (\$c = \$#in; \$c >= 0; \$c--) {
154 next if \$count < \$from;
156 last if \$count >= \$to; # stop after n
161 $fp->close; # close any open files
163 my $fh = $fp->open(@date);
164 for ($count = 0; $count < $to; ) {
169 push @in, [ split '\^' ] if length > 2;
171 eval $eval; # do the search on this file
172 return ("Geomag search error", $@) if $@;
173 last if $count >= $to; # stop after n
175 $fh = $fp->openprev(); # get the next file
183 # the standard log printing interpreting routine.
185 # every line that is printed should call this routine to be actually visualised
187 # Don't really know whether this is the correct place to put this stuff, but where
190 # I get a reference to an array of items
195 my $d = cldate($r->[0]);
196 my $t = (gmtime($r->[0]))[2];
198 return sprintf("$d %02d %5d %3d %3d %3d %3d %-5s %-5s %6s <%s>",
203 # read in this month's data
207 my @date = $fp->unixtoj(shift);
208 my $fh = $fp->open(@date);
215 push @in, [ split '\^' ] if length > 2;
221 # enter the spot for dup checking and return true if it is already a dup
224 my ($d, $sfi, $a, $k, $r) = @_;
227 return 2 if $d < $main::systime - $dupage;
229 my $dupkey = "C$d|$sfi|$k|$a|$r";
230 return DXDupe::check($dupkey, $main::systime+$dupage);
235 return DXDupe::listdups('C', $dupage, @_);