Get WAE ready: the score split, the Cabrillo layouts and the QTC list
The score summary now splits the way N1MM's does. `ContestLog` keeps a tally per band, and per kind of row where the contest has kinds, and the score window reads those instead of adding the rows up itself. Three things were wrong with the old sum: - The band rows counted a multiplier as one whatever the band. WAE weights it by band — `ScoreRow.AddContact` adds four on 3.5, three on 7 and two on 14, 21 and 28 — so the band rows did not add up to the total. - The band rows counted contacts left out of the claimed score. - There was no split by kind. `CWAE.LogInfo` and `ScoreClass.Description` give WAE a `Q/QTC` column and a row per band and kind, so contacts, traffic sent and traffic received are read apart. The Cabrillo writer now pads the record name to seven characters, which is what `ConvertCabrilloStructStdToString` does and why: `X-QSO:` is six characters and a space, so every record name puts the frequency in the same column. Nonemm wrote five, and the `X-QSO:` lines added last commit did not line up with the rest. WAE's own layouts follow `CWAE.CabrilloString`: three spaces after the sent serial rather than the one every other column gets, and the transmitter column only for a multi-operator entry. `QtcTraffic.ToSend` no longer offers a contact marked as a dupe, which is what `DBSupport.QTCRecordsetCount` leaves out with `Trim(ContactType) = ''`. Checked by running the program against a WAE SSB log of six contacts and a series of ten received: the band rows read 4, 3, 2 and 2 and add up to the 11 in the total row. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015NZkFxHde1iifAQemFTHxf
This commit is contained in:
@@ -8,6 +8,7 @@ namespace Nonemm.App.Windows;
|
||||
public sealed partial class ScoreWindow : RefreshableWindow
|
||||
{
|
||||
private readonly AppSession session;
|
||||
private int columnCount = 4;
|
||||
|
||||
public ScoreWindow(AppSession session)
|
||||
{
|
||||
@@ -28,33 +29,37 @@ public sealed partial class ScoreWindow : RefreshableWindow
|
||||
return;
|
||||
}
|
||||
|
||||
List<Band> bands = session.Logging.Log.Qsos
|
||||
.Select(q => q.Band)
|
||||
.OfType<Band>()
|
||||
.Distinct()
|
||||
.OrderBy(b => b.MegahertzLabel)
|
||||
// the log keeps the same split N1MM's score window shows, so the band
|
||||
// rows carry the weighted multipliers and leave out what is not in the
|
||||
// claimed score
|
||||
List<KeyValuePair<ScoreKey, ScoreTally>> lines = session.Logging.Log.Rows
|
||||
.OrderBy(r => Bands.Named(r.Key.Band)?.MegahertzLabel ?? double.MaxValue)
|
||||
.ThenBy(r => r.Key.Kind, StringComparer.Ordinal)
|
||||
.ToList();
|
||||
bool hasKinds = session.Logging.Contest.HasQtcTraffic;
|
||||
|
||||
foreach (string _ in new[] { "band", "qsos", "points", "mults" })
|
||||
columnCount = hasKinds ? 5 : 4;
|
||||
for (int column = 0; column < columnCount; column++)
|
||||
{
|
||||
Table.ColumnDefinitions.Add(new ColumnDefinition(GridLength.Star));
|
||||
}
|
||||
AddRow(0, "Band", "QSOs", "Points", "Mults", header: true);
|
||||
AddRow(0, "Band", "Q/QTC", "QSOs", "Points", "Mults", header: true);
|
||||
|
||||
int row = 1;
|
||||
foreach (Band band in bands)
|
||||
foreach ((ScoreKey key, ScoreTally line) in lines)
|
||||
{
|
||||
IReadOnlyList<Qso> onBand = session.Logging.Log.Qsos.Where(q => q.Band == band).ToList();
|
||||
AddRow(
|
||||
row++,
|
||||
band.Name,
|
||||
onBand.Count.ToString(),
|
||||
onBand.Sum(q => q.Points).ToString(),
|
||||
onBand.Sum(MultiplierCount).ToString());
|
||||
key.Band,
|
||||
key.Kind,
|
||||
line.Qsos.ToString(),
|
||||
line.Points.ToString(),
|
||||
line.TotalMultipliers.ToString());
|
||||
}
|
||||
AddRow(
|
||||
row,
|
||||
"Total",
|
||||
hasKinds ? "All" : "",
|
||||
session.Logging.Log.Tally.Qsos.ToString(),
|
||||
session.Logging.Log.Tally.Points.ToString(),
|
||||
session.Logging.Log.Tally.TotalMultipliers.ToString(),
|
||||
@@ -86,13 +91,19 @@ public sealed partial class ScoreWindow : RefreshableWindow
|
||||
private static string Hours(TimeSpan time) =>
|
||||
$"{(int)time.TotalHours}:{time.Minutes:00}";
|
||||
|
||||
private static int MultiplierCount(Qso qso) =>
|
||||
(qso.IsMultiplier1 ? 1 : 0) + (qso.IsMultiplier2 ? 1 : 0) + (qso.IsMultiplier3 ? 1 : 0);
|
||||
|
||||
private void AddRow(int row, string band, string qsos, string points, string mults, bool header = false)
|
||||
private void AddRow(
|
||||
int row,
|
||||
string band,
|
||||
string kind,
|
||||
string qsos,
|
||||
string points,
|
||||
string mults,
|
||||
bool header = false)
|
||||
{
|
||||
Table.RowDefinitions.Add(new RowDefinition(GridLength.Auto));
|
||||
string[] cells = [band, qsos, points, mults];
|
||||
string[] cells = columnCount == 5
|
||||
? [band, kind, qsos, points, mults]
|
||||
: [band, qsos, points, mults];
|
||||
for (int column = 0; column < cells.Length; column++)
|
||||
{
|
||||
TextBlock text = new()
|
||||
|
||||
@@ -106,6 +106,12 @@ public interface Contest
|
||||
/// The log window then shows the series they belong to.
|
||||
bool HasQtcTraffic => false;
|
||||
|
||||
/// Which kind of row this is, for a contest whose score is broken out by
|
||||
/// kind. WAE separates contacts from the traffic sent and received, and
|
||||
/// N1MM's score window gives each kind a row of its own on every band.
|
||||
/// Every other contest has one kind and the column is not shown.
|
||||
string RowKindFor(Qso qso) => "";
|
||||
|
||||
string SentExchangeFor(StationInfo me);
|
||||
|
||||
int PointsFor(QsoContext qso);
|
||||
|
||||
@@ -14,6 +14,7 @@ public sealed class ContestLog
|
||||
private readonly List<Qso> qsos = [];
|
||||
private readonly Dictionary<string, DateTime> workedKeys = new(StringComparer.Ordinal);
|
||||
private readonly HashSet<string> claimedMultipliers = new(StringComparer.Ordinal);
|
||||
private readonly Dictionary<ScoreKey, ScoreTally> rows = [];
|
||||
private ScoreTally tally = new();
|
||||
|
||||
public ContestLog(
|
||||
@@ -42,6 +43,11 @@ public sealed class ContestLog
|
||||
|
||||
public ScoreTally Tally => tally;
|
||||
|
||||
/// The same score split the way N1MM's score window splits it: a row per
|
||||
/// band, and per kind of row as well where the contest has kinds. The
|
||||
/// rows add up to `Tally`.
|
||||
public IReadOnlyDictionary<ScoreKey, ScoreTally> Rows => rows;
|
||||
|
||||
public int TotalScore => contest.TotalScore(tally, Entry);
|
||||
|
||||
/// What logging this contact right now would do, without logging it.
|
||||
@@ -181,9 +187,11 @@ public sealed class ContestLog
|
||||
return;
|
||||
}
|
||||
bool counts = qso.IsInScore;
|
||||
ScoreTally row = RowFor(qso);
|
||||
if (counts)
|
||||
{
|
||||
tally.AddQso(verdict.Points);
|
||||
row.AddQso(verdict.Points);
|
||||
}
|
||||
if (!contest.IsContact(qso))
|
||||
{
|
||||
@@ -196,6 +204,7 @@ public sealed class ContestLog
|
||||
if (counts)
|
||||
{
|
||||
tally.AddMultiplier(multiplier);
|
||||
row.AddMultiplier(multiplier);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -208,10 +217,22 @@ public sealed class ContestLog
|
||||
|
||||
/// Rescores the whole log. A removed or edited contact can hand its
|
||||
/// multiplier to a later one, which only a full pass gets right.
|
||||
private ScoreTally RowFor(Qso qso)
|
||||
{
|
||||
ScoreKey key = new(qso.Band?.Name ?? "", contest.RowKindFor(qso));
|
||||
if (!rows.TryGetValue(key, out ScoreTally? row))
|
||||
{
|
||||
row = new ScoreTally();
|
||||
rows[key] = row;
|
||||
}
|
||||
return row;
|
||||
}
|
||||
|
||||
private void Rebuild()
|
||||
{
|
||||
workedKeys.Clear();
|
||||
claimedMultipliers.Clear();
|
||||
rows.Clear();
|
||||
tally = new ScoreTally();
|
||||
List<Qso> ordered = qsos.OrderBy(q => q.TimestampUtc).ToList();
|
||||
qsos.Clear();
|
||||
|
||||
@@ -65,6 +65,12 @@ public sealed class Wae : Contest
|
||||
|
||||
public bool HasQtcTraffic => true;
|
||||
|
||||
/// N1MM's score window gives contacts, traffic sent and traffic received a
|
||||
/// row each on every band, under the heading `Q/QTC`. The value is what the
|
||||
/// `Exchange1` column holds.
|
||||
public string RowKindFor(Qso qso) =>
|
||||
WaeQtc.From(qso) is { } qtc ? (qtc.IsSent ? WaeQtc.Sent : WaeQtc.Received) : WaeQtc.Contact;
|
||||
|
||||
public string SentExchangeFor(StationInfo me) => "001";
|
||||
|
||||
/// A QTC line counts, and so does every contact on a contest band. The
|
||||
@@ -106,13 +112,20 @@ public sealed class Wae : Contest
|
||||
[
|
||||
new CabrilloField(me.Callsign, 13),
|
||||
new CabrilloField(qso.SentReport, 3),
|
||||
new CabrilloField($"{qso.SentNumber:0000}", 4),
|
||||
// N1MM leaves three spaces after the sent serial rather
|
||||
// than the one every other column gets
|
||||
new CabrilloField($"{qso.SentNumber:0000}", 6),
|
||||
],
|
||||
[
|
||||
new CabrilloField(qso.Call.Text, 13),
|
||||
new CabrilloField(qso.ReceivedReport, 3),
|
||||
new CabrilloField($"{qso.ReceivedNumber:0000}", 4),
|
||||
]);
|
||||
])
|
||||
{
|
||||
// N1MM writes the transmitter column for a multi-operator
|
||||
// entry and nothing at all for a single operator
|
||||
AddsTransmitter = entry.OperatorCategory == "MULTI-OP",
|
||||
};
|
||||
}
|
||||
string receiver = qtc.IsSent ? qtc.Station.Text : me.Callsign;
|
||||
string sender = qtc.IsSent ? me.Callsign : qtc.Station.Text;
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Nonemm.Contests;
|
||||
|
||||
/// Which row of the score window a contact belongs to. `Kind` is empty for
|
||||
/// every contest but WAE, which gives contacts, traffic sent and traffic
|
||||
/// received a row each on every band.
|
||||
public readonly record struct ScoreKey(string Band, string Kind);
|
||||
@@ -62,6 +62,8 @@ public sealed class CabrilloWriter
|
||||
return text.ToString();
|
||||
}
|
||||
|
||||
private const int TagWidth = 7;
|
||||
|
||||
public string QsoLine(Qso qso)
|
||||
{
|
||||
CabrilloExchange exchange = contest.CabrilloExchange(qso, me, entry);
|
||||
@@ -82,13 +84,17 @@ public sealed class CabrilloWriter
|
||||
/// A contact the operator has excluded from the claimed score is still
|
||||
/// written, under `X-QSO:` rather than `QSO:`. That is what N1MM writes,
|
||||
/// and the sponsors read it as a contact the entrant is not claiming.
|
||||
///
|
||||
/// The tag is padded to seven so that the columns after it line up whichever
|
||||
/// tag the row carries. That is the width N1MM pads it to, and `X-QSO:` is
|
||||
/// why: six characters and one space.
|
||||
private string RecordName(Qso qso)
|
||||
{
|
||||
if (!contest.IsContact(qso))
|
||||
{
|
||||
return "QTC: ";
|
||||
return "QTC:".PadRight(TagWidth);
|
||||
}
|
||||
return qso.IsClaimed ? "QSO: " : "X-QSO: ";
|
||||
return (qso.IsClaimed ? "QSO:" : "X-QSO:").PadRight(TagWidth);
|
||||
}
|
||||
|
||||
/// Every column is the width the sponsor asks for and one space, and a
|
||||
|
||||
@@ -245,9 +245,10 @@ public sealed class QsoEditor
|
||||
}
|
||||
if (contest.HasQtcTraffic)
|
||||
{
|
||||
// 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
|
||||
// N1MM's two headers for WAE, which do not read the way they
|
||||
// sound: `Series` is the exchange column and says whether the row
|
||||
// is a contact or QTC traffic — `QSO`, `SQTC` or `RQTC` — and
|
||||
// `QTC?` is the misc column and holds the series, such as `3/10`
|
||||
columns.Add(new QsoColumn("Series", QsoField.Exchange1, 6));
|
||||
columns.Add(new QsoColumn("QTC?", QsoField.MiscText, 6));
|
||||
}
|
||||
|
||||
@@ -102,7 +102,8 @@ public sealed class QtcTraffic
|
||||
/// The contacts to report to this station: the ones not reported to anybody
|
||||
/// yet, oldest first, and never the station itself. Ten at a time unless
|
||||
/// the operator asks for a shorter series, and fewer when the station has
|
||||
/// already had some.
|
||||
/// already had some. A contact marked as a dupe is not offered, which is
|
||||
/// what N1MM's `QTCRecordsetCount` leaves out.
|
||||
public IReadOnlyList<WaeQtc> ToSend(Callsign other, int mostPerSeries = WaeQtc.MostPerSeries)
|
||||
{
|
||||
int room = Math.Min(Math.Clamp(mostPerSeries, 1, WaeQtc.MostPerSeries), Remaining(other));
|
||||
@@ -116,6 +117,7 @@ public sealed class QtcTraffic
|
||||
.ToHashSet(StringComparer.OrdinalIgnoreCase);
|
||||
List<Qso> worth = position.Log.Qsos
|
||||
.Where(q => !WaeQtc.IsQtc(q))
|
||||
.Where(q => q.ContactType.Length == 0)
|
||||
.Where(q => !q.Call.Text.Equals(other.Text, StringComparison.OrdinalIgnoreCase))
|
||||
.Where(q => !reported.Contains(ReportedKey(q.Call.Text, q.SentNumber)))
|
||||
.OrderBy(q => q.TimestampUtc)
|
||||
|
||||
Reference in New Issue
Block a user