Relay automatic control and the band-change outbound rows both hang off the rig state, which is right when there IS a rig: changing Band in the entry strip pushes a QSY, the new state comes back through the CAT callback, and the relays follow from there — which is why this works for anyone with rig control. Without a CAT connection nothing is pushed and nothing comes back, so a station whose rig OpsLog does not control changed band and the antenna switch sat exactly where it was. Reported as automatic control not working; it was never told the band had changed. The entry selector now says so itself, but only when the CAT push did not happen, and never when the band or frequency lock is on: a lock means the entry is deliberately decoupled from the rig, and moving an antenna to match a contact logged from last year is worse than doing nothing. The frequency is passed as unknown on that path — a band selector gives a band and nothing else, and rules written on a frequency RANGE are left alone rather than evaluated against a made-up dial reading. The de-duplication of "is this a new band" is now shared by both sources, so a station that has both does not command its switch twice for one QSY. Also: the same credit line as the QSL e-mail now closes the default recording e-mail body, on the same terms — a default in the template, so a stored one is untouched.
37 lines
1.4 KiB
Go
37 lines
1.4 KiB
Go
package main
|
|
|
|
import "testing"
|
|
|
|
// A band change now has two sources: the rig, and the entry strip on a station
|
|
// whose rig OpsLog does not control. They share one memory of the last band, so
|
|
// a station that has both commands its antenna switch once per QSY rather than
|
|
// twice — the entry selector pushes a QSY, the rig reports the same band back,
|
|
// and only the first of the two is a change.
|
|
func TestBandChangeIsNotedOncePerBand(t *testing.T) {
|
|
lastTriggerBandMu.Lock()
|
|
lastTriggerBand = ""
|
|
lastTriggerBandMu.Unlock()
|
|
|
|
if b, changed := noteBandChange("20m"); !changed || b != "20m" {
|
|
t.Fatalf("first 20m = (%q,%v), want (\"20m\",true)", b, changed)
|
|
}
|
|
// The same band from the other source — the rig echoing the QSY back.
|
|
if _, changed := noteBandChange("20M"); changed {
|
|
t.Error("the rig echoing the band back counted as a second change — the switch would be commanded twice")
|
|
}
|
|
if _, changed := noteBandChange(" 20m "); changed {
|
|
t.Error("whitespace made the same band look new")
|
|
}
|
|
if b, changed := noteBandChange("40m"); !changed || b != "40m" {
|
|
t.Errorf("40m = (%q,%v), want (\"40m\",true)", b, changed)
|
|
}
|
|
// An unknown band must not be recorded, or the next real one would look
|
|
// unchanged against it.
|
|
if _, changed := noteBandChange(""); changed {
|
|
t.Error("an empty band was treated as a change")
|
|
}
|
|
if _, changed := noteBandChange("40m"); changed {
|
|
t.Error("the empty band overwrote the last one")
|
|
}
|
|
}
|