- dbg "RBN:ADMIN,rbn cache: $removed removed $count remain" if isdbg('rbn');
- $count = $removed = 0;
- while (my ($k,$v) = each %{$spot}) {
- if ($tim-$v > $self->{minspottime}*2) {
- delete $spot->{$k};
- ++$removed;
+ $r->[RSpotData] = \@s;
+
+ push @{$self->{queue}}, $sp if @$spot == 1; # queue the KEY (not the record)
+
+ dbg("RBN: key: '$sp' ADD RECORD call: $call qrg: $qrg origin: $origin") if isdbg('rbn');
+
+ push @$spot, $r;
+
+ # At this point we run the queue to see if anything can be sent onwards to the punter
+ my $now = $main::systime;
+
+ # now run the waiting queue which just contains KEYS ($call|$qrg)
+ foreach $sp (@{$self->{queue}}) {
+ my $cand = $spots->{$sp};
+ unless ($cand && $cand->[0]) {
+ dbg "RBN Cand " . ($cand ? 'def' : 'undef') . " [0] " . ($cand->[0] ? 'def' : 'undef') . " dwell $dwelltime";
+ next;
+ }
+ if ($now >= $cand->[0] + $dwelltime ) {
+ # we have a candidate, create qualitee value(s);
+ unless (@$cand > 1) {
+ dbg "RBN: QUEUE key '$sp' MISSING RECORDS " . dd($cand) if isdbg 'rbn';
+ shift @{$self->{queue}};
+ next;
+ }
+ my $savedtime = shift @$cand; # save the start time
+ my $r = $cand->[0];
+ my $quality = @$cand;
+ $quality = 9 if $quality > 9;
+ $quality = "Q:$quality";
+ if (isdbg('progress')) {
+ my $s = "RBN: SPOT key: '$sp' = $r->[RCall] on $r->[RQrg] by $r->[ROrigin] \@ $r->[RTime] $quality";
+ $s .= " route: $self->{call}";
+ dbg($s);
+ }
+
+ send_dx_spot($self, $quality, $cand);
+
+ # clear out the data and make this now just "spotted", but no further action required until respot time
+ dbg "RBN: QUEUE key '$sp' cleared" if isdbg 'rbn';
+
+ $spots->{$sp} = [$savedtime];
+ shift @{$self->{queue}};