The map drew one direction of every path on it: what this receiver decoded. The reverse — which stations are reporting our own transmissions — is the half an operator cannot see from their own radio, and on FT8 it is the half that decides whether calling is worth the cycle. It is the narrowest slice of the PSK Reporter feed there is. The v2 topic is pskr/filter/v2/<band>/<mode>/<tx call>/<rx call>/… so putting the operator's callsign in the TRANSMIT level makes the broker send nothing else. For scale, from internal/pskr's own measured numbers: four bands unfiltered is 83 messages a second, filtered on the receiver's square 0.2 to 1.2 a second — one callsign in the transmit level is a handful per FT8 cycle however open the band is. Both grids are in the payload, so the arc is arithmetic and there is no lookup. internal/pskrme, with its own connection, for the same reason internal/pskrtgt has its own: the three want slices of the feed that cannot be filtered out of one another. It also means this keeps working with the band-opening watch off — hanging it off that feed's lifecycle would have made it fail silently for anyone not chasing openings. Nothing is persisted. One entry per STATION inside a fifteen-minute window, carrying its freshest report: PSK Reporter's uploaders batch, many every five minutes, so a tighter window would show a fraction of who actually heard the last few calls. Stop clears the window, or switching the layer back on would redraw who heard us before it was on. On the map the layer is dashed and single-coloured. Solid is what we decoded, dashed is somebody decoding us; colour alone could not carry that distinction next to fourteen band colours. The receivers are rings rather than filled dots for the same reason. Per profile, since the callsign IS the subscription — a switch resubscribes rather than going on reporting who hears the previous station.
67 lines
2.2 KiB
Go
67 lines
2.2 KiB
Go
package pskrme
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
// One station uploading every five minutes must be ONE pair of ears on the map,
|
|
// showing its freshest report — not four arcs to the same square, and not the
|
|
// oldest of them deciding whether the path still looks open.
|
|
func TestReportsKeepsTheFreshestPerStation(t *testing.T) {
|
|
w := New(Config{MyCall: "F4BPO"})
|
|
now := time.Now()
|
|
w.reports = []Report{
|
|
{Call: "OH5CX", Grid: "KP30", SNR: -18, At: now.Add(-9 * time.Minute)},
|
|
{Call: "W1AW", Grid: "FN31", SNR: -5, At: now.Add(-2 * time.Minute)},
|
|
{Call: "OH5CX", Grid: "KP30", SNR: -11, At: now.Add(-1 * time.Minute)},
|
|
}
|
|
got := w.Reports()
|
|
if len(got) != 2 {
|
|
t.Fatalf("got %d stations, want 2: %+v", len(got), got)
|
|
}
|
|
for _, r := range got {
|
|
if r.Call == "OH5CX" && r.SNR != -11 {
|
|
t.Errorf("OH5CX kept the %d dB report, want the freshest (-11)", r.SNR)
|
|
}
|
|
}
|
|
}
|
|
|
|
// A report older than the window is gone, and gone from the slice too: the map
|
|
// must not show a path that stopped existing a quarter of an hour ago, and the
|
|
// window is what keeps this from growing all evening.
|
|
func TestReportsDropsWhatIsPastTheWindow(t *testing.T) {
|
|
w := New(Config{MyCall: "F4BPO"})
|
|
now := time.Now()
|
|
w.reports = []Report{
|
|
{Call: "OLD", Grid: "JN36", At: now.Add(-Window - time.Minute)},
|
|
{Call: "NEW", Grid: "JN36", At: now.Add(-time.Minute)},
|
|
}
|
|
got := w.Reports()
|
|
if len(got) != 1 || got[0].Call != "NEW" {
|
|
t.Fatalf("got %+v, want only NEW", got)
|
|
}
|
|
if len(w.reports) != 1 {
|
|
t.Errorf("the stale report is still held: %d kept", len(w.reports))
|
|
}
|
|
}
|
|
|
|
// Turning the feed off clears what it collected. Left in place, switching it
|
|
// back on would redraw a map of who heard us before it was on.
|
|
func TestStopForgetsTheReports(t *testing.T) {
|
|
w := New(Config{MyCall: "F4BPO"})
|
|
w.reports = []Report{{Call: "OH5CX", Grid: "KP30", At: time.Now()}}
|
|
w.Stop()
|
|
if got := w.Reports(); len(got) != 0 {
|
|
t.Errorf("got %+v after Stop, want nothing", got)
|
|
}
|
|
}
|
|
|
|
// No callsign, no subscription: the transmit level would be a wildcard, which
|
|
// is the entire feed — the one thing this package exists not to ask for.
|
|
func TestStartRefusesWithoutACallsign(t *testing.T) {
|
|
if err := New(Config{}).Start(); err == nil {
|
|
t.Fatal("started with no callsign")
|
|
}
|
|
}
|