Add the core, contest, storage and format layers

Frequencies, bands, modes, callsigns, grid squares and the country file live in
Nonemm.Core. Nonemm.Contests holds the scoring engine and CQ WW and CQ WPX.
Nonemm.Storage writes N1MM's DXLOG schema, and Nonemm.Formats writes Cabrillo
3.0 and reads and writes ADIF.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Erik
2026-08-27 10:27:51 +00:00
commit 0f84bc8972
68 changed files with 3823 additions and 0 deletions

View File

@@ -0,0 +1,85 @@
using Nonemm.Core;
namespace Nonemm.Contests.Rules;
/// CQ WPX, CW, SSB and RTTY. Serial numbers are exchanged and the multiplier is
/// the prefix, counted once for the whole contest whatever the band.
public sealed class CqWpx : Contest
{
/// The rules split the bands at 14 MHz rather than by band name, so 30, 17
/// and 12 metres fall on the high side even though the contest is not run
/// on them.
private static readonly Frequency LowBandLimit = Frequency.FromKilohertz(14_000);
private readonly ModeCategory mode;
public CqWpx(ModeCategory mode) => this.mode = mode;
public string Name => "CQWPX";
public string DisplayName => $"CQ WPX {ModeLabel()}";
public string CabrilloName => mode switch
{
ModeCategory.Cw => "CQ-WPX-CW",
ModeCategory.Phone => "CQ-WPX-SSB",
_ => "CQ-WPX-RTTY",
};
public IReadOnlyList<ExchangeField> ExchangeFields =>
[
new ExchangeField("RST", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
new ExchangeField("Nr", ExchangeSlot.SerialNumber, ExchangeFieldKind.Number),
];
public IReadOnlyList<string> MultiplierNames => ["Prefixes"];
public DupeScope DupeScope => DupeScope.PerBand;
public bool HasSerialNumbers => true;
public IReadOnlyList<ModeCategory> Modes => [mode];
public string SentExchangeFor(StationInfo me) => DefaultReport();
public int PointsFor(QsoContext qso)
{
bool highBand = qso.Qso.Frequency >= LowBandLimit;
bool rtty = mode == ModeCategory.Digital;
if (qso.IsSameCountry)
{
return rtty ? (highBand ? 1 : 2) : 1;
}
if (!qso.IsSameContinent)
{
return highBand ? 3 : 6;
}
if (rtty || qso.Continent == "NA")
{
return highBand ? 2 : 4;
}
return highBand ? 1 : 2;
}
public IReadOnlyList<Multiplier> MultipliersFor(QsoContext qso)
{
string? prefix = qso.Qso.Call.WpxPrefix();
return prefix is null ? [] : [new Multiplier(1, prefix, "")];
}
public int TotalScore(ScoreTally tally) => tally.Points * tally.TotalMultipliers;
public CabrilloExchange CabrilloExchange(Qso qso, StationInfo me) =>
new(
[new CabrilloField(qso.SentReport, 3), new CabrilloField($"{qso.SentNumber:0000}", 6)],
[new CabrilloField(qso.ReceivedReport, 3), new CabrilloField($"{qso.ReceivedNumber:0000}", 6)]);
private string ModeLabel() => mode switch
{
ModeCategory.Cw => "CW",
ModeCategory.Phone => "SSB",
_ => "RTTY",
};
private string DefaultReport() => mode == ModeCategory.Phone ? "59" : "599";
}