Show the boxes N1MM shows for each contest

The entry window had a fixed set of boxes with a Name and Comment box beside
the exchange. N1MM lays out one row of boxes per contest and nothing else, so
this does the same: general logging keeps Name and Comment, and a contest gets
the boxes it exchanges.

Two new members on `Contest` carry the cases where the boxes and the log
columns are not the same list:

- `FromExchange1` spreads what was typed in one box across the log columns.
  Where the other station sends a serial or a district code depending on where
  it is, N1MM gives it one box and sorts the value into the number, section or
  zone column from there, so the score and the Cabrillo file read it from the
  same column N1MM does.
- `LogFieldsFor` gives the log window its own column list. Sweepstakes takes
  the whole exchange in one box and logs it in four columns; `SweepstakesExchange`
  parses `72 A 74 SCV` in any order, reading from the last word back as N1MM
  does.

The sent serial is now marked as not required and space steps over it along
with the two report boxes, because nobody types the number going out.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015NZkFxHde1iifAQemFTHxf
This commit is contained in:
2026-09-09 20:12:37 +00:00
co-authored by Claude Opus 5
parent 6e24e00ec8
commit bae40bb04e
47 changed files with 702 additions and 277 deletions
+2 -1
View File
@@ -75,6 +75,7 @@ public sealed class AvailableStations
return ExchangeSlots.ApplyHistory(
CountryFields.Apply(qso, position.Session.Countries),
position.Session.History,
position.Entry.Exchange);
position.Contest,
position.Me);
}
}
+7 -4
View File
@@ -65,9 +65,9 @@ public sealed class EntryFields
public void FocusOn(int field) => Focus = Math.Clamp(field, 0, FieldCount - 1);
/// What space and tab do: move to the next box the operator types in, and
/// round to the callsign again from the last one. The report boxes are
/// stepped over, because nobody types 599 — N1MM steps over them too, and
/// fills them in instead.
/// round to the callsign again from the last one. The report boxes and the
/// sent serial are stepped over, because nobody types 599 or the number
/// they are sending — N1MM steps over the same three and fills them in.
public void Advance() => Focus = Next(1);
public void Retreat() => Focus = Next(-1);
@@ -78,7 +78,7 @@ public sealed class EntryFields
for (int step = 0; step < FieldCount; step++)
{
at = (at + by + FieldCount) % FieldCount;
if (at == 0 || Exchange[at - 1].Kind != ExchangeFieldKind.Report)
if (at == 0 || !IsFilledIn(Exchange[at - 1]))
{
return at;
}
@@ -86,6 +86,9 @@ public sealed class EntryFields
return Focus;
}
private static bool IsFilledIn(ExchangeField field) =>
field.IsSent || field.Kind == ExchangeFieldKind.Report;
/// True when everything the contest asks for has been typed.
public bool IsComplete =>
Call.Trim().Length > 0 &&
+27 -6
View File
@@ -10,6 +10,9 @@ public static class ExchangeSlots
{
public static Qso Apply(Qso qso, ExchangeSlot slot, string value) => slot switch
{
// an empty sent box leaves what the contest filled in
ExchangeSlot.SentReport => value.Length == 0 ? qso : qso with { SentReport = value },
ExchangeSlot.SentNumber => Number(value) == 0 ? qso : qso with { SentNumber = Number(value) },
ExchangeSlot.ReceivedReport => qso with { ReceivedReport = value },
ExchangeSlot.SerialNumber => qso with { ReceivedNumber = Number(value) },
ExchangeSlot.Zone => qso with { Zone = Number(value) },
@@ -28,7 +31,12 @@ public static class ExchangeSlots
/// What the call history file says this station sends in one exchange box,
/// or an empty string when the file holds nothing for it.
public static string ValueFrom(CallHistoryEntry known, ExchangeField field) => field.Slot switch
public static string ValueFrom(CallHistoryEntry known, ExchangeField field) =>
field.Kind == ExchangeFieldKind.SweepstakesExchange
? SweepstakesText(known)
: FromSlot(known, field);
private static string FromSlot(CallHistoryEntry known, ExchangeField field) => field.Slot switch
{
ExchangeSlot.Name => known.Name,
// a file for a section contest often carries the state instead
@@ -45,25 +53,38 @@ public static class ExchangeSlots
_ => "",
};
/// What the file holds for a Sweepstakes station, put together the way
/// N1MM puts it: one box takes the whole exchange, and a file carries the
/// check and the section of it. The number and the precedence are left for
/// the operator to copy.
private static string SweepstakesText(CallHistoryEntry known)
{
string section = known.Section.Length > 0 ? known.Section : known.State;
return section.Length == 0 ? "" : $"{known.Check:00}{section}";
}
/// Fills the exchange the call history file published for this station into
/// a contact. Used where nobody has copied the exchange yet: a spotted
/// station the operator has not worked.
public static Qso ApplyHistory(Qso qso, CallHistory history, IReadOnlyList<ExchangeField> exchange)
public static Qso ApplyHistory(Qso qso, CallHistory history, Contest contest, StationInfo me)
{
CallHistoryEntry? known = history.Find(qso.Call.Text);
if (known is null)
{
return qso;
}
foreach (ExchangeField field in exchange)
string exchange1 = "";
foreach (ExchangeField field in contest.ExchangeFieldsFor(me))
{
string value = ValueFrom(known, field);
if (value.Length > 0)
if (value.Length == 0)
{
qso = Apply(qso, field.Slot, value);
continue;
}
qso = Apply(qso, field.Slot, value);
exchange1 = field.Slot == ExchangeSlot.Exchange1 ? value : exchange1;
}
return qso;
return exchange1.Length > 0 ? contest.FromExchange1(qso, exchange1) : qso;
}
private static string Digits(int value) => value > 0 ? value.ToString() : "";
+31 -3
View File
@@ -16,6 +16,11 @@ public sealed class OperatingPosition
Session = session;
RadioNumber = radioNumber;
Entry = new EntryFields(session.Contest.ExchangeFieldsFor(session.Me));
FillSentExchange();
// N1MM fills the sent serial in again on every entry window when a
// contact is logged, so the other radio is not left showing the number
// that has just gone
Session.Logged += (_, _) => FillSentExchange();
}
public ContestSession Session { get; }
@@ -38,8 +43,9 @@ public sealed class OperatingPosition
public bool IsRunning { get; set; }
/// The other operator's name and a note about the contact. Neither is part
/// of any exchange — N1MM keeps both beside the exchange boxes and writes
/// them into the log — so neither counts towards a complete exchange.
/// of any exchange: the name is what a contact being quick edited already
/// held, and the note is what Ctrl+N asks for. Neither counts towards a
/// complete exchange.
public string OtherName { get; set; } = "";
public string Comment { get; set; } = "";
@@ -62,8 +68,13 @@ public sealed class OperatingPosition
public void Tune(Frequency frequency, Mode? mode = null, Frequency? transmitFrequency = null)
{
bool modeChanged = mode is not null && mode.Category != Mode.Category;
Frequency = frequency;
Mode = mode ?? Mode;
if (modeChanged)
{
FillSentExchange();
}
TransmitFrequency = transmitFrequency ?? TransmitFrequency;
Session.NotifyChanged();
}
@@ -209,6 +220,7 @@ public sealed class OperatingPosition
StampSentTime();
Qso stored = Session.Add(Noted(BuildQso(Entry.Call.Trim())));
Entry.Clear();
FillSentExchange();
OtherName = "";
Comment = "";
SentTime = "";
@@ -228,6 +240,19 @@ public sealed class OperatingPosition
}
}
/// Puts what this station sends into the boxes that show it: the report
/// and the serial number. N1MM keeps both filled in and steps over them,
/// so the number going out is on the screen without being typed.
public void FillSentExchange()
{
foreach (ExchangeField field in Entry.Exchange.Where(f => f.IsSent))
{
Entry.Set(
field.Slot,
field.Slot == ExchangeSlot.SentReport ? DefaultReport() : SentNumber.ToString());
}
}
/// Puts the report the operator would send anyway into the report boxes
/// that are empty: 599 on CW and digital modes, 59 on phone. N1MM does the
/// same when the callsign box is left, which is why neither program stops
@@ -406,6 +431,7 @@ public sealed class OperatingPosition
Editing = null;
held = null;
Entry.Clear();
FillSentExchange();
OtherName = "";
Comment = "";
SentTime = "";
@@ -458,6 +484,8 @@ public sealed class OperatingPosition
{
qso = ExchangeSlots.Apply(qso, field.Slot, Entry.ValueOf(field.Slot).Trim());
}
return qso;
return Entry.Exchange.Any(f => f.Slot == ExchangeSlot.Exchange1)
? Contest.FromExchange1(qso, Entry.ValueOf(ExchangeSlot.Exchange1).Trim())
: qso;
}
}
+5 -3
View File
@@ -237,7 +237,7 @@ public sealed class QsoEditor
{
columns.Add(new QsoColumn("SntNr", QsoField.SentNumber, 5));
}
foreach (ExchangeField field in contest.ExchangeFieldsFor(me))
foreach (ExchangeField field in contest.LogFieldsFor(me).Where(f => !f.IsSent))
{
QsoField mapped = FieldFor(field.Slot);
kinds[mapped] = field.Kind;
@@ -245,8 +245,10 @@ public sealed class QsoEditor
}
if (contest.HasQtcTraffic)
{
// N1MM's header for the misc column in WAE, where it holds the
// series a QTC row belongs to
// N1MM's two headers for WAE: the exchange column says whether the
// row is a contact or QTC traffic — `QSO`, `SQTC` or `RQTC` — and
// the misc column holds the series a QTC row belongs to
columns.Add(new QsoColumn("Series", QsoField.Exchange1, 6));
columns.Add(new QsoColumn("QTC?", QsoField.MiscText, 6));
}
columns.Add(new QsoColumn("Op", QsoField.Operator, 8));