Files
OpsLog/motor_trackmode_test.go
T
rouggy 65bbaa85f3 feat(antenna): three tracking modes for Ultrabeam and SteppIR
The follow loop only ever had one behaviour — re-tune once the rig moved
further than a fixed step. The SteppIR's own controller software offers three,
and operators arrive with that mental model: every frequency change, past a
threshold, or only on a band change. They are real operating trade-offs, not
preferences: "always" keeps resonance perfect at the cost of motors running
constantly (and on a SteppIR every move inhibits transmit while the elements
travel), "band" moves them a handful of times a day.

"Always" is implemented as the threshold mode with a 1 kHz threshold rather
than as a separate branch, so all modes keep the one deadband reference that
matters: the rig frequency last commanded for, NOT the antenna's own reported
frequency — a SteppIR flips its reported frequency between the commanded value
and its home value, which would re-issue a SET on nearly every poll and leave
the operator permanently unable to transmit.

Band mode compares against the band last COMMANDED for, not the rig's previous
band, so the first move after startup and any move made by hand still get
reconciled. It applies to the immediate spot-click path too: a click inside the
band the antenna is already resonant in moves nothing.

An unset or unrecognised mode resolves to the step mode, so every config
written before this option behaves exactly as it did.

Also routes the antenna settings block through t() — it was hardcoded English.
2026-08-12 08:31:44 +02:00

49 lines
2.0 KiB
Go

package main
import "testing"
// The tracking mode decides how often a motorized antenna's elements run, so a
// value that fails to parse must not silently become the most aggressive
// setting. Anything unrecognised — including the empty string every config
// written before this option existed contains — has to land on the threshold
// mode, which is exactly what those configs already did.
func TestNormMotorTrackMode(t *testing.T) {
for _, tc := range []struct{ in, want string }{
{"always", motorTrackAlways},
{"ALWAYS", motorTrackAlways},
{" band ", motorTrackBand},
{"step", motorTrackStep},
{"", motorTrackStep}, // never configured — behaves as before
{"everytime", motorTrackStep}, // near-miss, not "always"
{"per-band", motorTrackStep}, // near-miss, not "band"
{"25", motorTrackStep}, // a step value fed in by mistake
} {
if got := normMotorTrackMode(tc.in); got != tc.want {
t.Errorf("normMotorTrackMode(%q) = %q, want %q", tc.in, got, tc.want)
}
}
}
// Band mode compares the band the rig is on against the band the antenna was
// last commanded for. That comparison is bandForHz, and the property it has to
// have is that two frequencies far apart within one band agree while two
// frequencies close together across a band edge do not — otherwise the antenna
// either never moves or moves on every QSY.
func TestBandForHzDrivesBandTracking(t *testing.T) {
same := [][2]int64{
{14000000, 14350000}, // both ends of 20 m — one band, no move
{7000000, 7200000}, // 40 m
{50000000, 52000000}, // 6 m, a wide one
}
for _, p := range same {
if a, b := bandForHz(p[0]), bandForHz(p[1]); a != b || a == "" {
t.Errorf("%.3f MHz is %q but %.3f MHz is %q — band mode would re-tune inside one band",
float64(p[0])/1e6, a, float64(p[1])/1e6, b)
}
}
// A small QSY that crosses from 30 m into 20 m has to read as a band change.
if a, b := bandForHz(10150000), bandForHz(14000000); a == b {
t.Errorf("30 m and 20 m both read %q — band mode would never re-tune between them", a)
}
}