Take serial numbers from a pool the whole entry shares
Each station worked out its next number as the highest in its log plus one, so two operators typing at the same moment both sent the same number and one of the two contacts was wrong in the sponsor's log. SerialNumberPool holds the highest number taken per band, which is N1MM's QSONumbers array. A number is taken at the first character of the callsign, as N1MM takes it, and ReserveNr tells the other stations before the contact is worked. A number at or below one this station has used is answered with the whole pool, N1MM's QSONRS, and the station that is behind counts on from there. The pool also goes out when a contest is opened and when the numbers are started again. Contest.NumbersByBand says whether the numbers run per band or as one sequence for the station. CQ WPX runs one per band for a multi-two and a multi-multi; every other contest here runs one sequence. The band index in the message is N1MM's, so the array lines up with theirs. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015NZkFxHde1iifAQemFTHxf
This commit is contained in:
@@ -611,4 +611,50 @@ public class StationLinkTests
|
||||
SentNumber = 41,
|
||||
StationName = "RUN-PC",
|
||||
};
|
||||
|
||||
/// The number one station has taken for the contact it is working reaches
|
||||
/// the other, with the band it was taken on.
|
||||
[Fact]
|
||||
public async Task AReservedSerialNumberReachesTheOtherStation()
|
||||
{
|
||||
(int onePort, int twoPort) = SparePorts();
|
||||
using StationLink one = new("RUN-PC", Version, stationNumber: 1, port: onePort);
|
||||
using StationLink two = new("MULT-PC", Version, stationNumber: 2, port: twoPort);
|
||||
one.Start();
|
||||
two.Start();
|
||||
ReservedNumberMessage? taken = null;
|
||||
two.NumberReserved += (_, number) => taken = number;
|
||||
one.AddStation("MULT-PC", "127.0.0.1", twoPort);
|
||||
await WaitForAsync(() => one.Stations.Any(s => s is { IsMine: false, IsConnected: true }));
|
||||
|
||||
await one.SendReservedNumberAsync(41, Frequency.FromKilohertz(14_025));
|
||||
|
||||
await WaitForAsync(() => taken is not null);
|
||||
Assert.Equal(41, taken!.Number);
|
||||
Assert.Equal(Bands.Band20M, Bands.ForFrequency(taken.Frequency));
|
||||
}
|
||||
|
||||
/// The answer to a number that clashes: the whole pool, one number per
|
||||
/// band, so the station that is behind catches up.
|
||||
[Fact]
|
||||
public async Task TheWholeSerialNumberPoolCanBeSent()
|
||||
{
|
||||
(int onePort, int twoPort) = SparePorts();
|
||||
using StationLink one = new("RUN-PC", Version, stationNumber: 1, port: onePort);
|
||||
using StationLink two = new("MULT-PC", Version, stationNumber: 2, port: twoPort);
|
||||
one.Start();
|
||||
two.Start();
|
||||
IReadOnlyList<int>? numbers = null;
|
||||
two.SerialNumbersArrived += (_, sent) => numbers = sent;
|
||||
one.AddStation("MULT-PC", "127.0.0.1", twoPort);
|
||||
await WaitForAsync(() => one.Stations.Any(s => s is { IsMine: false, IsConnected: true }));
|
||||
int[] pool = new int[N1mmBandIndex.Slots];
|
||||
pool[N1mmBandIndex.Of(Bands.Band20M)] = 12;
|
||||
|
||||
await one.SendSerialNumbersAsync(pool);
|
||||
|
||||
await WaitForAsync(() => numbers is not null);
|
||||
Assert.Equal(12, numbers![N1mmBandIndex.Of(Bands.Band20M)]);
|
||||
Assert.Equal(N1mmBandIndex.Slots, numbers.Count);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user