X-Git-Url: http://dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FRBN.pm;h=3a906dbe7e0b5b5d816f83d59b85b93097245211;hb=1d545cc6840241395b88cc10addaa1928d9a1166;hp=0b3dfe5a937dc245c9b67958476212a9610d7664;hpb=ef77e5488c4cc47afe272f6220cc3fa0cddc5829;p=spider.git diff --git a/perl/RBN.pm b/perl/RBN.pm index 0b3dfe5a..3a906dbe 100644 --- a/perl/RBN.pm +++ b/perl/RBN.pm @@ -75,10 +75,11 @@ our $startup_delay = 5*60; # don't send anything out until this timer has expir # this is to allow the feed to "warm up" with duplicates # so that the "big rush" doesn't happen. -our $minspottime = 30*60; # the time between respots of a callsign - if a call is +our $respottime = 30*60; # the time between respots of a callsign - if a call is # still being spotted (on the same freq) and it has been # spotted before, it's spotted again after this time - # until the next minspottime has passed. + # until the next respottime has passed. + our $beacontime = 5*60; # same as minspottime, but for beacons (and shorter) @@ -90,9 +91,13 @@ our $limbotime = 5*60; # if there are fewer than $minqual candidates and $dwe # simply be that it is not in standard spot coverage. (ask G4PIQ # about this). +our $cachetime = 60*60; # The length of time spot data is cached + our $filterdef = $Spot::filterdef; # we use the same filter as the Spot system. Can't think why :-). my $spots; # the GLOBAL spot cache +my $qrg; # the GlOBAL (ephemeral) qrg cache (generated on re-read of cache) + my %runtime; # how long each channel has been running @@ -107,6 +112,9 @@ my $json; my $noinrush = 0; # override the inrushpreventor if set our $maxdeviants = 5; # the number of deviant QRGs to record for skimmer records +our %seeme; # the list of users that want to see themselves + + sub init { $json = DXJSON->new; @@ -146,7 +154,7 @@ sub new $self->{norawhour} = 0; $self->{sort} = 'N'; $self->{lasttime} = $main::systime; - $self->{minspottime} = $minspottime; + $self->{respottime} = $respottime; $self->{beacontime} = $beacontime; $self->{showstats} = 0; $self->{pingint} = 0; @@ -252,7 +260,12 @@ sub normal } # remove all extraneous crap from the origin - just leave the base callsign - $origin = basecall($origin); + my $norigin = basecall($origin); + unless ($norigin) { + dbg("RBN: ERROR '$origin' is an invalid callsign, dumped"); + return; + } + $origin = $norigin; # is this callsign in badspotter list? if ($DXProt::badspotter->in($origin) || $DXProt::badnode->in($origin)) { @@ -261,7 +274,7 @@ sub normal } # is the qrg valid - unless ($qrg =~ /^\d+\.\d{1,2}$/) { + unless ($qrg =~ /^\d+\.\d{1,3}$/) { dbg("RBN: ERROR qrg $qrg from $origin invalid, dumped"); return; } @@ -326,6 +339,32 @@ sub normal my $nqrg = nearest(1, $qrg * 10); # normalised to nearest Khz my $sp = "$call|$nqrg"; # hopefully the skimmers will be calibrated at least this well! + # deal with the unix time + my ($hh,$mm) = $t =~ /(\d\d)(\d\d)Z$/; + my $utz = $hh*3600 + $mm*60 + $main::systime_daystart; # possible issue with late spot from previous day + $utz -= 86400 if $utz > $now+3600; # too far ahead, drag it back one day + + # + # But before we do anything, if this call is in the seeme hash then just send the spot to them + # + if (exists $seeme{$call} && (my $scall = $seeme{basecall($call)})) { + my $uchan = DXChannel::get($call); + if ($uchan) { + if ($uchan->is_user) { + if (isdbg('seeme')) { + dbg("seeme: $line"); + dbg( qq{seemme:decode or:$origin qr:$qrg ca:$call mo:$mode s:$s m:$m sp:$spd u:$u sort:$sort t:$t tx:$tx qra:$qra}); + } + my @s = Spot::prepare($qrg, $call, $utz, sprintf("%-3s %2ddB **SEEME**", $mode, $s), $origin.'-#'); + my $buf = $uchan->format_dx_spot(@s); + dbg("seeme: result '$buf'") if isdbg('seeme'); + $uchan->local_send('S', $buf) if $scall; + } else { + LogDbg("RBN Someone is playing silly persons $call is not a user and cannot do 'seeme', ignored and reset"); + delete $seeme{$call}; + } + } + } # find it? my $cand = $spots->{$sp}; unless ($cand) { @@ -357,7 +396,7 @@ sub normal my $respot = 0; if ($cand && ref $cand) { if (@$cand <= CData) { - if ($self->{minspottime} > 0 && $now - $cand->[CTime] < $self->{minspottime}) { + if ($self->{respottime} > 0 && $now - $cand->[CTime] < $self->{respottime}) { dbg("RBN: key: '$sp' call: $call qrg: $qrg DUPE \@ ". atime(int $cand->[CTime])) if $dbgrbn && isdbg('rbn'); return; } @@ -381,11 +420,6 @@ sub normal return unless $noinrush || $self->{inrushpreventor} < $main::systime; # build up a new record and store it in the buildup - # deal with the unix time - my ($hh,$mm) = $t =~ /(\d\d)(\d\d)Z$/; - my $utz = $hh*3600 + $mm*60 + $main::systime_daystart; # possible issue with late spot from previous day - $utz -= 86400 if $utz > $now+3600; # too far ahead, drag it back one day - # create record and add into the buildup my $r = [$origin, nearest(.1, $qrg), $call, $mode, $s, $t, $utz, $respot, $u]; my @s = Spot::prepare($r->[RQrg], $r->[RCall], $r->[RUtz], '', $r->[ROrigin]); @@ -462,7 +496,6 @@ sub dx_spot my $quality = shift; my $cand = shift; my $call = $dxchan->{call}; - my $seeme = $dxchan->user->rbnseeme(); my $strength = 100; # because it could if we talk about FTx my $saver; my %zone; @@ -490,12 +523,6 @@ sub dx_spot ++$zone{$s->[SZone]}; # save the spotter's zone - # if the 'see me' flag is set, then show all the spots without further adornment (see set/rbnseeme for more info) - if ($seeme) { - send_final($dxchan, $s); - next; - } - # save the lowest strength one if ($r->[RStrength] < $strength) { $strength = $r->[RStrength]; @@ -535,8 +562,9 @@ sub dx_spot unless ($user->qra && is_qra($user->qra)) { $user->qra($qra); dbg("RBN: update qra on $saver->[SCall] to $qra"); - $user->put; } + # update lastseen if nothing else + $user->put; } } } @@ -561,7 +589,7 @@ sub send_final $buf = $dxchan->format_dx_spot(@$saver); $saver->[SOrigin] = $call; } - $dxchan->local_send('N', $buf); + $dxchan->local_send('R', $buf); } # per second @@ -833,7 +861,7 @@ sub per_10_minute next if $k =~ /^O\|/; next if $k =~ /^SKIM\|/; - if ($main::systime - $cand->[CTime] > $minspottime*2) { + if ($main::systime - $cand->[CTime] > $cachetime) { delete $spots->{$k}; ++$removed; } @@ -935,4 +963,15 @@ sub check_cache return undef; } +sub add_seeme +{ + my $call = shift; + $seeme{basecall($call)} = 1; +} + +sub del_seeme +{ + my $call = shift; + delete $seeme{basecall($call)}; +} 1;