fix(rst): a change of mode changes the notation
An operator with a callsign in the field, switching FT8 to SSB, kept "+00" as the report. The edited flag protects a report the operator chose — 57 rather than 59 — and it was holding across a change of mode as well, where it protects nothing: a decibel figure is not a weak SSB report, it is not a report at all. Worse, anything that fills the field from the rig sets that flag too (the S-meter readouts in the rig consoles), so the field could be stuck in the wrong notation for the rest of the QSO. The flag now holds only while the report still belongs to the mode's family. When it does not, the operator's own judgement is carried across where it can be — 57 becomes 579, 599 becomes 59 — and the mode's preset answers where it cannot.
This commit is contained in:
@@ -86,3 +86,35 @@ export function stepRST(value: string, dir: number, mode: string): string {
|
||||
}
|
||||
return head + String(sUnit) + tone + (over > 0 ? '+' + over : '');
|
||||
}
|
||||
|
||||
// rstFitsMode says whether a report belongs to the family a mode reports in.
|
||||
//
|
||||
// The three families are written differently and are not interchangeable: a
|
||||
// signed decibel figure ("+00"), a three-figure RST ("599"), a two-figure RS
|
||||
// ("59", with an optional "+20" above S9). "+00" on SSB is not a weak report,
|
||||
// it is not a report at all.
|
||||
export function rstFitsMode(value: string, mode: string): boolean {
|
||||
const v = (value || '').trim();
|
||||
if (v === '') return false;
|
||||
switch (rstCategory(mode)) {
|
||||
case 'digital': return /^[+-]\d{1,2}$/.test(v);
|
||||
case 'cw': return /^\d{3}(\+\d+)?$/.test(v);
|
||||
default: return /^\d{2}(\+\d+)?$/.test(v);
|
||||
}
|
||||
}
|
||||
|
||||
// convertRST carries a report across the CW/phone divide, keeping the operator's
|
||||
// own judgement of the signal: 57 becomes 579, 599 becomes 59.
|
||||
//
|
||||
// Only between those two — a decibel figure says nothing about readability and
|
||||
// an RST says nothing in decibels, so there the preset is the honest answer.
|
||||
// Returns '' when it cannot be done.
|
||||
export function convertRST(value: string, toMode: string): string {
|
||||
const v = (value || '').trim();
|
||||
const to = rstCategory(toMode);
|
||||
if (to === 'digital') return '';
|
||||
const m = /^(\d)(\d)(\d?)((?:\+\d+)?)$/.exec(v);
|
||||
if (!m) return '';
|
||||
if (to === 'cw') return m[1] + m[2] + '9' + m[4]; // RS → RST, tone 9
|
||||
return m[1] + m[2] + m[4]; // RST → RS, tone dropped
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user