3 # The geomagnetic information and calculation module
5 # Copyright (c) 1998 - Dirk Koopman G1TLH
20 use vars qw($date $sfi $k $a $forecast @allowed @denied $fp $node $from);
22 $fp = 0; # the DXLog fcb
23 $date = 0; # the unix time of the WWV (notional)
24 $sfi = 0; # the current SFI value
25 $k = 0; # the current K value
26 $a = 0; # the current A value
27 $forecast = ""; # the current geomagnetic forecast
28 $node = ""; # originating node
29 $from = ""; # who this came from
30 @allowed = (); # if present only these callsigns are regarded as valid WWV updators
31 @denied = (); # if present ignore any wwv from these callsigns
32 my $dirprefix = "$main::data/wwv";
33 my $param = "$dirprefix/param";
37 $fp = DXLog::new('wwv', 'dat', 'm');
38 mkdir $dirprefix, 0777 if !-e $dirprefix; # now unnecessary DXLog will create it
39 do "$param" if -e "$param";
43 # write the current data away
46 my $fh = new FileHandle;
47 open $fh, "> $param" or confess "can't open $param $!";
48 print $fh "# Geomagnetic data parameter file last mod:", scalar gmtime, "\n";
49 print $fh "\$date = $date;\n";
50 print $fh "\$sfi = $sfi;\n";
51 print $fh "\$a = $a;\n";
52 print $fh "\$k = $k;\n";
53 print $fh "\$from = '$from';\n";
54 print $fh "\$node = '$node';\n";
55 print $fh "\@denied = qw(", join(' ', @denied), ");\n" if @denied > 0;
56 print $fh "\@allowed = qw(", join(' ', @allowed), ");\n" if @allowed > 0;
60 $fp->writeunix($date, "$from^$date^$sfi^$a^$k^$forecast^$node\n");
63 # update WWV info in one go (usually from a PC23)
66 my ($mydate, $mytime, $mysfi, $mya, $myk, $myforecast, $myfrom, $mynode) = @_;
67 if ((@allowed && grep {$_ eq $from} @allowed) ||
68 (@denied && !grep {$_ eq $from} @denied) ||
69 (@allowed == 0 && @denied == 0)) {
71 my $trydate = cltounix($mydate, sprintf("%02d18Z", $mytime));
72 if ($trydate >= $date) {
76 $forecast = $myforecast;
86 # add or substract an allowed callsign
91 push @allowed, map {uc $_} @_;
95 @allowed = map {$_ ne uc $c} @allowed;
101 # add or substract a denied callsign
106 push @denied, map {uc $_} @_;
110 @denied = map {$_ ne uc $c} @denied;
116 # accessor routines (when I work how symbolic refs work I might use one of those!)
119 @_ ? $sfi = shift : $sfi ;
124 @_ ? $k = shift : $k ;
129 @_ ? $a = shift : $a ;
134 @_ ? $forecast = shift : $forecast ;