fix(bandopen): honour the operator's band selection
The chips in Settings only ever shaped the PSK Reporter SUBSCRIPTION. Neither feed path checked them: both asked bandopen.Watched, which says which bands the detector is capable of and knows nothing about the selection. So the cluster path announced every watched band regardless, and widening the subscription to "+" for grid chasing let PSK Reporter do the same — a station with only 6 m ticked got 10 m and 2 m badges. The selection is now cached beside the on/off flag and checked on both paths, and unticking a band puts its badge out: badges fade on a timer fed by spots the detector no longer looks at, so it would otherwise stay lit until a restart.
This commit is contained in:
@@ -63,3 +63,56 @@ func TestClearBandOpeningsPutsTheBadgesOut(t *testing.T) {
|
||||
t.Error("the remembered openings were thrown away")
|
||||
}
|
||||
}
|
||||
|
||||
// Unticking a band in Settings must actually stop its announcements.
|
||||
//
|
||||
// Nothing checked the operator's selection on either feed path: bandopen.Watched
|
||||
// only says which bands the detector is CAPABLE of. So a station with just 6 m
|
||||
// ticked still got 10 m and 2 m badges, from the cluster path and — once grid
|
||||
// chasing widened the subscription to every band — from PSK Reporter too.
|
||||
func TestBandOpenHonoursTheSelectedBands(t *testing.T) {
|
||||
a := &App{opSet: true, opLat: 48, opLon: 2}
|
||||
a.bandOpen.on.Store(true)
|
||||
a.setBandOpenBands([]string{"6m"})
|
||||
|
||||
if !a.bandOpenWanted("6m") {
|
||||
t.Error("6m is ticked and was refused")
|
||||
}
|
||||
for _, b := range []string{"10m", "2m", "4m"} {
|
||||
if a.bandOpenWanted(b) {
|
||||
t.Errorf("%s is not ticked and was accepted", b)
|
||||
}
|
||||
}
|
||||
// A band the detector cannot watch at all stays out whatever is stored.
|
||||
if a.bandOpenWanted("20m") {
|
||||
t.Error("20m is not a watched band and was accepted")
|
||||
}
|
||||
|
||||
// And the cluster path must obey it too.
|
||||
a.detectBandOpening(cluster.Spot{
|
||||
DXCall: "K1ABC", Band: "10m", DistanceKm: 6000, ShortPath: 280, ReceivedAt: time.Now(),
|
||||
})
|
||||
if a.bandOpen.det != nil {
|
||||
t.Error("a spot on an unticked band reached the detector")
|
||||
}
|
||||
}
|
||||
|
||||
// Unticking a band puts its badge out. They fade on a timer fed by spots the
|
||||
// detector no longer looks at, so it would otherwise stay lit until a restart.
|
||||
func TestUntickingABandClearsItsBadge(t *testing.T) {
|
||||
a := &App{}
|
||||
a.bandOpen.live = map[string]bandopen.Opening{
|
||||
"6m": {Band: "6m", Calls: 9},
|
||||
"10m": {Band: "10m", Calls: 5},
|
||||
}
|
||||
a.bandOpen.aliveUntil = map[string]time.Time{
|
||||
"6m": time.Now().Add(time.Hour),
|
||||
"10m": time.Now().Add(time.Hour),
|
||||
}
|
||||
a.setBandOpenBands([]string{"6m"})
|
||||
|
||||
live := a.GetLiveOpenings()
|
||||
if len(live) != 1 || live[0].Band != "6m" {
|
||||
t.Errorf("live openings = %v, want only 6m", live)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user