The window was one flat table of columns this program made up. N1MM's has tabs and a fixed set of columns, and an operator who knows one has to be able to read the other. **The window** now has Stations, Actions and Messages. Stations is a grid with N1MM's headers in N1MM's order — Computer, IP Address, Pass, Run, 10, 100, Freq, Op, Msg, Send, Receive, Band, R/M, Mode — and a row per station, this computer included. Right-click a row to pass the contact being worked to that station, to talk, to show the connection log, or to close and open its connection. Actions holds the talk line, the pass frequency, the echo and the networking switch; Messages holds the chat, the connection failures, the echo round trips and a trace of every message that arrives. **`STATUS`** is what fills those columns. N1MM sends it every few seconds whether anything has changed or not — the pass frequency, the frequency, run or search and pounce, the operator, the rates over the last ten and the last hundred contacts, the mode, the categories and the version — so a station sitting on one frequency for an hour still has a current row. `BANDMAP` only says a station moved. The five transmit-interlock flags are sent as false: this program does not block a transmitter. **`Rates.PerHour`** reads the two rate columns out of the log. Count back over the last N contacts, stop at a gap longer than the contest's minimum off time, and treat a span under a minute as a minute, so three contacts in five seconds read as 180 an hour rather than 2160. A connection closed by hand stays closed. Without that flag the next beacon opens it again within ten seconds, which makes the menu item look broken. Left out, because there is nothing behind them: N1MM's Resynchronize and Rescore tabs, the transmit interlocks of its Options tab, the Master column and the call-stacking target tab. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PdAYHcdRktqKry7nk414TU
55 lines
1.7 KiB
C#
55 lines
1.7 KiB
C#
using Nonemm.Core;
|
|
|
|
namespace Nonemm.Contests;
|
|
|
|
/// How fast contacts are being made, in contacts an hour. The network status
|
|
/// window shows two of these per station — over the last ten contacts and over
|
|
/// the last hundred — and the score window shows the same numbers for this
|
|
/// station.
|
|
public static class Rates
|
|
{
|
|
/// Where N1MM stops dividing by a very short span. Under ten contacts the
|
|
/// span counts as at least a minute, so three contacts in five seconds
|
|
/// reads as 180 an hour rather than 2160.
|
|
private const int ShortRun = 10;
|
|
|
|
private static readonly TimeSpan Floor = TimeSpan.FromMinutes(1);
|
|
|
|
/// The rate over the last `count` contacts before `nowUtc`.
|
|
///
|
|
/// Counting stops at the first gap longer than `minimumOff`, so a rate
|
|
/// after a night's rest is the rate since the operator came back rather
|
|
/// than a hundred contacts spread over twelve hours. A log with no contact
|
|
/// inside that gap is a rate of nothing.
|
|
public static int PerHour(
|
|
IEnumerable<Qso> qsos,
|
|
int count,
|
|
DateTime nowUtc,
|
|
TimeSpan minimumOff)
|
|
{
|
|
DateTime oldest = nowUtc;
|
|
int counted = 0;
|
|
foreach (Qso qso in qsos.OrderByDescending(q => q.TimestampUtc).Take(count))
|
|
{
|
|
if (oldest - qso.TimestampUtc > minimumOff)
|
|
{
|
|
break;
|
|
}
|
|
oldest = qso.TimestampUtc;
|
|
counted++;
|
|
}
|
|
if (counted == 0)
|
|
{
|
|
return 0;
|
|
}
|
|
TimeSpan span = nowUtc - oldest;
|
|
if (counted < ShortRun && span < Floor)
|
|
{
|
|
span = Floor;
|
|
}
|
|
return span > TimeSpan.Zero
|
|
? (int)Math.Round(counted / span.TotalHours)
|
|
: 0;
|
|
}
|
|
}
|