Act on the .udc session, off-time and band-change settings
Four settings were read by nothing. MultipleSessions = 0000/30 runs the contest in half-hour sessions from 00:00 UTC. The session is part of the dupe key, so a station worked in an earlier one may be worked again, and ResetMultsEverySession and ResetSNEverySession start the multipliers and the serial numbers over. DupeQSOMinutesAgo is the other way back to a station: after so many minutes rather than in the next session. The log holds the time of the last contact per dupe key instead of only the key, and the setting's IgnoreBand and ThisMode decide the scope, because a file that uses it turns DupeType off. MinimumOffTime drives the time on and time off the score summary now shows under the score, and beside them are the band changes made against the allowance for a contest that limits them. N1MM's countdown for the minutes you have to stay on a new band needs its info window and is not here. UdcFile.Flag now takes 1 and 0 as well as True and False, which is what these settings are written as and what N1MM reads. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoGtneMQaz4M9w7Kk49AVD
This commit is contained in:
48
src/Nonemm.Contests/BandChangeRules.cs
Normal file
48
src/Nonemm.Contests/BandChangeRules.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using Nonemm.Core;
|
||||
|
||||
namespace Nonemm.Contests;
|
||||
|
||||
/// What a contest allows a station in the way of band changes, and how to
|
||||
/// count the ones already made. N1MM shows the same count in its info window.
|
||||
///
|
||||
/// `Max` is how many changes the entry is allowed. The window the count is
|
||||
/// taken over is the clock hour, unless `PerContest` counts the whole contest
|
||||
/// or `PerPeriod` counts the hour up to now.
|
||||
public sealed record BandChangeRules(
|
||||
int Max,
|
||||
bool PerContest = false,
|
||||
bool PerPeriod = false,
|
||||
bool CountsModeChanges = false,
|
||||
TimeSpan MinimumStay = default)
|
||||
{
|
||||
/// A contest that does not limit band changes at all.
|
||||
public static readonly BandChangeRules None = new(0);
|
||||
|
||||
public bool IsCounted => Max > 0;
|
||||
|
||||
/// How many band changes fall in the window that ends at `now`. The first
|
||||
/// contact of the log is not a change.
|
||||
public int CountedIn(IEnumerable<Qso> qsos, DateTime now)
|
||||
{
|
||||
List<Qso> ordered = qsos.OrderBy(q => q.TimestampUtc).ToList();
|
||||
int changes = 0;
|
||||
for (int at = 1; at < ordered.Count; at++)
|
||||
{
|
||||
if (IsChange(ordered[at - 1], ordered[at]) && IsInWindow(ordered[at].TimestampUtc, now))
|
||||
{
|
||||
changes++;
|
||||
}
|
||||
}
|
||||
return changes;
|
||||
}
|
||||
|
||||
private bool IsChange(Qso before, Qso after) =>
|
||||
before.Band != after.Band
|
||||
|| (CountsModeChanges && before.Mode.Category != after.Mode.Category);
|
||||
|
||||
private bool IsInWindow(DateTime when, DateTime now) =>
|
||||
PerContest
|
||||
|| (PerPeriod
|
||||
? when <= now && now - when < TimeSpan.FromHours(1)
|
||||
: when.Date == now.Date && when.Hour == now.Hour);
|
||||
}
|
||||
Reference in New Issue
Block a user