X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FGeomag.pm;h=d78ff2cd3f007fd67cd7b5233ec3db33551ff699;hb=0542c1871c9563b7577a4b9a1282fd5d2c203047;hp=d68e724d436214b64825b2052164122e22628397;hpb=324bd80ed4aef7e2636f5a03288788ce11ab2663;p=spider.git diff --git a/perl/Geomag.pm b/perl/Geomag.pm index d68e724d..d78ff2cd 100644 --- a/perl/Geomag.pm +++ b/perl/Geomag.pm @@ -14,17 +14,18 @@ use DXVars; use DXUtil; use DXLog; use Julian; -use FileHandle; +use IO::File; use Carp; use strict; -use vars qw($date $sfi $k $a $forecast @allowed @denied $fp $node $from); +use vars qw($date $sfi $k $a $r $forecast @allowed @denied $fp $node $from); $fp = 0; # the DXLog fcb $date = 0; # the unix time of the WWV (notional) $sfi = 0; # the current SFI value $k = 0; # the current K value $a = 0; # the current A value +$r = 0; # the current R value $forecast = ""; # the current geomagnetic forecast $node = ""; # originating node $from = ""; # who this came from @@ -44,13 +45,14 @@ sub init # write the current data away sub store { - my $fh = new FileHandle; + my $fh = new IO::File; open $fh, "> $param" or confess "can't open $param $!"; print $fh "# Geomagnetic data parameter file last mod:", scalar gmtime, "\n"; print $fh "\$date = $date;\n"; print $fh "\$sfi = $sfi;\n"; print $fh "\$a = $a;\n"; print $fh "\$k = $k;\n"; + print $fh "\$r = $r;\n"; print $fh "\$from = '$from';\n"; print $fh "\$node = '$node';\n"; print $fh "\@denied = qw(", join(' ', @denied), ");\n" if @denied > 0; @@ -58,13 +60,13 @@ sub store close $fh; # log it - $fp->writeunix($date, "$from^$date^$sfi^$a^$k^$forecast^$node"); + $fp->writeunix($date, "$from^$date^$sfi^$a^$k^$forecast^$node^$r"); } # update WWV info in one go (usually from a PC23) sub update { - my ($mydate, $mytime, $mysfi, $mya, $myk, $myforecast, $myfrom, $mynode) = @_; + my ($mydate, $mytime, $mysfi, $mya, $myk, $myforecast, $myfrom, $mynode, $myr) = @_; if ((@allowed && grep {$_ eq $from} @allowed) || (@denied && !grep {$_ eq $from} @denied) || (@allowed == 0 && @denied == 0)) { @@ -72,6 +74,7 @@ sub update # my $trydate = cltounix($mydate, sprintf("%02d18Z", $mytime)); if ($mydate >= $date) { $sfi = 0 + $mysfi; + $r = 0 + $myr unless !$r && $myk == $k; $k = 0 + $myk; $a = 0 + $mya; $forecast = $myforecast; @@ -125,6 +128,11 @@ sub k @_ ? $k = shift : $k ; } +sub r +{ + @_ ? $r = shift : $r ; +} + sub a { @_ ? $a = shift : $a ; @@ -135,6 +143,7 @@ sub forecast @_ ? $forecast = shift : $forecast ; } + # # print some items from the log backwards in time # @@ -155,7 +164,7 @@ sub search $eval = qq( my \$c; my \$ref; - for (\$c = \$ #in; \$c >= 0; \$c--) { + for (\$c = \$#in; \$c >= 0; \$c--) { \$ref = \$in[\$c]; if ($search) { \$count++;