Backend groundwork; the columns and filters that consume it come next. GRIDS. A CQ is the one WSJT-X message that carries a locator, and wsjtSender was throwing that token away. It is now returned, validated as a real field+square, and remembered per callsign. This is the ONLY grid source available: a DX-cluster line carries the spotter's grid at best and never the DX's, and a per-callsign QRZ lookup under an RBN firehose is not a trade worth making. So grids are known for the stations this receiver decoded - which is exactly the FT8/FT4 watering hole an operator is looking at while grid chasing. RR73 is why the grid is validated rather than pattern-matched. R is inside A-R and 73 inside 00-99, so a sign-off satisfies the Maidenhead shape exactly and would have planted a grid that does not exist into the index, silently. NEW GRID keys on "GRID|MODE" with the mode put through the same normMode as everything else, so the "group digital modes" option decides whether a grid worked on FT8 is still new on FT4 - one rule, no branch. Grids are truncated to four characters: a log holds a mix of JN36 and JN36QU, and without that the same square is new forever, once per subsquare. On cost, which was the condition: one more DISTINCT scan when the status snapshot is rebuilt, then map lookups per spot. The same shape as the county and POTA sets it sits beside, and the snapshot exists precisely so a spot batch never touches the logbook. Spotter continent and the LoTW flag come from tables already in memory - the DXCC prefix table and ARRL's user list - so they cost a lookup each. The spotter continent answers a different question from the DX's: whether anyone near you is hearing this at all.
41 lines
1.7 KiB
Go
41 lines
1.7 KiB
Go
package udp
|
|
|
|
import "testing"
|
|
|
|
func TestWSJTSender(t *testing.T) {
|
|
cases := []struct {
|
|
msg string
|
|
wantCall string
|
|
wantCQ bool
|
|
wantGrid string
|
|
}{
|
|
{"CQ K1ABC FN42", "K1ABC", true, "FN42"},
|
|
{"CQ DX W2XYZ EM12", "W2XYZ", true, "EM12"}, // modifier "DX" skipped
|
|
{"CQ NA VE3ABC FN03", "VE3ABC", true, "FN03"}, // region modifier skipped
|
|
{"CQ 020 JA1XYZ PM95", "JA1XYZ", true, "PM95"}, // zone modifier skipped
|
|
{"W2XYZ K1ABC -10", "K1ABC", false, ""}, // exchange → sender is 2nd call
|
|
{"W2XYZ K1ABC R-10", "K1ABC", false, ""},
|
|
{"W2XYZ K1ABC RR73", "K1ABC", false, ""},
|
|
{"F4BPO K1ABC/P 73", "K1ABC/P", false, ""}, // portable call kept
|
|
{"CQ F/DL1ABC JO31", "F/DL1ABC", true, "JO31"}, // compound prefix, grid still valid
|
|
{"CQ K1ABC", "K1ABC", true, ""}, // CQ without a grid
|
|
{"CQ K1ABC RR73", "K1ABC", true, ""}, // RR73 is a sign-off, NOT grid RR73
|
|
{"CQ K1ABC FN4", "K1ABC", true, ""}, // 3 chars is not a field+square
|
|
{"CQ K1ABC FN42AB", "K1ABC", true, ""}, // 6-char: WSJT-X never sends it here
|
|
{"CQ K1ABC 73", "K1ABC", true, ""}, // bare sign-off
|
|
{"CQ K1ABC SS42", "K1ABC", true, ""}, // S is past R — no such field
|
|
// Non-callsign / free text → no sender.
|
|
{"TNX 73 GL", "", false, ""},
|
|
{"K1ABC RR73", "", false, ""}, // only one call + a token → 2nd token not a call
|
|
{"", "", false, ""},
|
|
{"CQ CQ CQ", "", true, ""}, // CQ but no resolvable call
|
|
}
|
|
for _, c := range cases {
|
|
call, cq, grid := wsjtSender(c.msg)
|
|
if call != c.wantCall || cq != c.wantCQ || grid != c.wantGrid {
|
|
t.Errorf("wsjtSender(%q) = (%q,%v,%q), want (%q,%v,%q)",
|
|
c.msg, call, cq, grid, c.wantCall, c.wantCQ, c.wantGrid)
|
|
}
|
|
}
|
|
}
|