Write the numbered Cabrillo lines a .udc file asks for

CabrilloFormat 2, 3, 4 and 5 name the NAQP, NA Sprint, Sweepstakes and
section-and-serial lines. A file asking for one of those got the default
line; it now gets the layout, ported from CabrilloString2 and
CabrilloString4 in N1MM's Contact.cs, in N1MM's columns.

The exchange the layouts split into columns is built from the boxes the
file defines, in the order it defines them. N1MM builds it from the
section box alone, which writes only half of a two-box exchange such as
NAQP's name and state.

Format 6, the ARRL RTTY Roundup line, is still not read. No published
.udc file asks for it, because the Roundup has a contest class of its
own.

ExchangeSlots.ValueOf moves to Nonemm.Contests as QsoExchange.ValueOf,
so the contest code can read a contact through its exchange boxes
without a second copy of that switch.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RoGtneMQaz4M9w7Kk49AVD
This commit is contained in:
2026-08-31 12:27:49 +00:00
parent cf5bdd6082
commit a07b181ee1
7 changed files with 251 additions and 28 deletions

View File

@@ -15,6 +15,7 @@ public sealed class UserDefinedContest : Contest
private readonly IReadOnlyList<ExchangeField> exchangeFields;
private readonly IReadOnlyList<string> workableStations;
private readonly UdcCabrillo cabrillo;
private readonly UdcCabrilloFormat cabrilloFormat;
public UserDefinedContest(UdcFile file)
{
@@ -26,6 +27,7 @@ public sealed class UserDefinedContest : Contest
exchangeFields = ReadExchangeFields(file);
workableStations = file.List("IsWorkable");
cabrillo = new UdcCabrillo(file.Text("CabrilloString"));
cabrilloFormat = new UdcCabrilloFormat(file.Number("CabrilloFormat", 1));
}
public static UserDefinedContest Load(string path) =>
@@ -103,6 +105,17 @@ public sealed class UserDefinedContest : Contest
private string SentExchange(QsoContext qso) =>
qso.Entry.SentExchange.Length > 0 ? qso.Entry.SentExchange : SentExchangeFor(qso.Me);
/// The exchange values of one contact, in the order the file lists the
/// entry boxes. The report is left out because no numbered layout has a
/// column for it.
private string ReceivedExchange(Qso qso) =>
string.Join(
' ',
exchangeFields
.Where(field => field.Slot != ExchangeSlot.ReceivedReport)
.Select(field => QsoExchange.ValueOf(qso, field.Slot))
.Where(value => value.Length > 0));
public IReadOnlyList<Multiplier> MultipliersFor(QsoContext qso) =>
IsWorkable(qso)
? multipliers.Select(m => m.For(qso)).OfType<Multiplier>().ToList()
@@ -119,15 +132,22 @@ public sealed class UserDefinedContest : Contest
return (int)Math.Round(total * pointsMultiplier.ForEntry(entry));
}
/// `CabrilloString` lays out the whole line, which is how a contest whose
/// sponsor asks for its own columns is written. Without it the line is the
/// usual one: each station, its report and its exchange.
/// A sponsor who asks for columns of their own gets them two ways:
/// `CabrilloString` names every column, and a numbered `CabrilloFormat`
/// names one of the four layouts N1MM has built in. A file with neither
/// gets the usual line: each station, its report and its exchange.
public CabrilloExchange CabrilloExchange(Qso qso, StationInfo me, ContestEntry entry) =>
cabrillo.IsDefined
? new CabrilloExchange(cabrillo.Fields(qso, me, entry), [])
{
AddsTransmitter = cabrillo.HasTransmitter,
}
: cabrilloFormat.IsNumbered
? cabrilloFormat.Line(
qso,
me,
entry.SentExchange.Length > 0 ? entry.SentExchange : SentExchangeFor(me),
ReceivedExchange(qso))
: new CabrilloExchange(
[
new CabrilloField(me.Callsign, 13),