Check the signal report before it goes in the log

The log window took any text in the two report columns. It now checks the
report the same way it checks the zone or the section: RST on most modes,
and a signal-to-noise ratio in decibels on FT8, FT4, JT65, Q65 and MSK144.
A WAE QTC row is skipped, because it keeps the time sent and the other
station's call in those two columns.

The grid column is checked on every contest now, not only when the contest
asks for a locator, and the value is stored as JN88dd.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015NZkFxHde1iifAQemFTHxf
This commit is contained in:
2026-09-10 11:07:09 +00:00
co-authored by Claude Opus 5
parent 7ca2c5cd52
commit 95e1405be1
8 changed files with 198 additions and 16 deletions
+37
View File
@@ -0,0 +1,37 @@
using System.Globalization;
namespace Nonemm.Core;
/// Checks a signal report before it goes in the log. Most modes exchange RST;
/// the weak-signal modes exchange a signal-to-noise ratio in decibels instead.
public static class SignalReport
{
private const int Weakest = -50;
private const int Strongest = 50;
public static bool IsPlausible(string text, Mode mode)
{
string report = text.Trim();
return mode.ReportsDecibels ? IsDecibels(report) : IsRst(report);
}
/// What to type, for an error message.
public static string Example(Mode mode) => mode.ReportsDecibels
? "-12"
: mode.Category == ModeCategory.Phone ? "59" : "599";
/// Readability 1 to 5, strength 1 to 9 and, on CW and the digital modes,
/// tone 1 to 9. Two figures pass on every mode: phone sends two, and an
/// operator on CW may drop the tone.
private static bool IsRst(string report) =>
report.Length is 2 or 3
&& report[0] is >= '1' and <= '5'
&& report[1] is >= '1' and <= '9'
&& (report.Length == 2 || report[2] is >= '1' and <= '9');
private static bool IsDecibels(string report) =>
int.TryParse(report, NumberStyles.AllowLeadingSign,
CultureInfo.InvariantCulture, out int decibels)
&& decibels >= Weakest
&& decibels <= Strongest;
}