3 # The geomagnetic information and calculation module
5 # Copyright (c) 1998 - Dirk Koopman G1TLH
18 use vars qw($date $sfi $k $a $forecast @allowed @denied);
20 $date = 0; # the unix time of the WWV (notional)
21 $sfi = 0; # the current SFI value
22 $k = 0; # the current K value
23 $a = 0; # the current A value
24 $forecast = ""; # the current geomagnetic forecast
25 @allowed = (); # if present only these callsigns are regarded as valid WWV updators
26 @denied = (); # if present ignore any wwv from these callsigns
27 my $dirprefix = "$main::data/wwv";
28 my $param = "$dirprefix/param";
32 mkdir $dirprefix, 0777 if !-e $dirprefix;
33 do "$param" if -e "$param";
37 # write the current data away
40 my $fh = new FileHandle;
41 open $fh, "> $param" or confess "can't open $param $!";
42 print $fh "# Geomagnetic data parameter file last mod:", scalar gmtime, "\n";
43 print $fh "\$date = $date;\n";
44 print $fh "\$sfi = $sfi;\n";
45 print $fh "\$a = $a;\n";
46 print $fh "\$k = $k;\n";
47 print $fh "\$forecast = '$forecast';\n";
48 print $fh "\@denied = qw(", join(' ', @denied), ");\n" if @denied > 0;
49 print $fh "\@allowed = qw(", join(' ', @allowed), ");\n" if @allowed > 0;
53 # update WWV info in one go (usually from a PC23)
56 my ($mydate, $mytime, $mysfi, $mya, $myk, $myforecast, $from, $node) = @_;
57 if ((@allowed && grep {$_ eq $from} @allowed) ||
58 (@denied && !grep {$_ eq $from} @denied) ||
59 (@allowed == 0 && @denied == 0)) {
61 my $trydate = cltounix($mydate, sprintf("%02d18Z", $mytime));
62 if ($trydate >= $date) {
66 $forecast = $myforecast;
72 # add or substract an allowed callsign
77 push @allowed, map {uc $_} @_;
81 @allowed = map {$_ ne uc $c} @allowed;
87 # add or substract a denied callsign
92 push @denied, map {uc $_} @_;
96 @denied = map {$_ ne uc $c} @denied;
102 # accessor routines (when I work how symbolic refs work I might use one of those!)
105 @_ ? $sfi = shift : $sfi ;
110 @_ ? $k = shift : $k ;
115 @_ ? $a = shift : $a ;
120 @_ ? $forecast = shift : $forecast ;