Respect active band plan in Antenna SWR sweep (#2800). Principle IV.#2817
Conversation
The Antenna SWR sweep took its edges directly from BandDefs.h, which holds ARRL/US allocations only. For users on IARU R1 (EU) and other regions where the regional allocation is narrower than the US one, this caused the sweep to step past the in-region band edge and trip the radio's interlock — e.g. on 40 m the sweep ran from 7.005 up to ~7.285 MHz, well past the 7.200 MHz IARU R1 limit. Narrow the sweep range to the active BandPlanManager segments by intersecting the static BandDef envelope with the plan's matching segments (midpoint inside the static band), mirroring the pattern already used by AtuPreTuneDialog::recomputeBands. Falls back to the static edges when no plan is loaded or no segments match, keeping US/default behaviour unchanged. The existing "band too narrow for guard" and "too many points" guards downstream still apply. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
There was a problem hiding this comment.
Targeted fix for #2800 — looks good. Thanks for the contribution.
Verified the approach is sound:
- Reuses the same midpoint-in-band filter pattern as
computeCentersForBandinAtuPreTuneDialog.cpp:86–101, which is the right precedent. - Uses
std::max(effectiveLow, planLow)/std::min(effectiveHigh, planHigh)so the plan can only narrow the sweep, never expand it past the hardcoded BandDef — important safety property. - Null-checks
m_bandPlanMgrand falls back cleanly when no segments match the band (infinity sentinels +std::isfinite). std::numeric_limitsandstd::isfiniteare already used elsewhere inMainWindow.cpp, so no header additions needed.- Edge guard (
kSwrSweepEdgeGuardMhz) still applied after narrowing, preserving the "too narrow" warning.
One observation, not blocking:
For band plans with internal gaps (e.g. a region that splits a band into separate CW and SSB sub-allocations with a digital/illegal gap between them), this picks the outer [min, max] of all matching segments and the linear sweep walks across the gap. That's no worse than the pre-patch behaviour, and 60m (the band most likely to hit this) is already excluded upstream. If you want a follow-up, you could borrow the sort-and-merge logic from computeCentersForBand to emit a separate sweep run per contiguous region — but that's scope creep for this bug.
Minor comment nit (optional): the inline comment says "Mirrors the pattern used by AtuPreTuneDialog::recomputeBands" — the actual helper is the free function computeCentersForBand in the anonymous namespace (no member called recomputeBands exists). Worth correcting so future maintainers can find it.
Otherwise straightforward, well-scoped, single-file change. Nice cross-reference back to the AtuPreTune precedent.
|
Claude here — merged. The EU 40 m interlock-trip is fixed; sweep range is now clamped to the active band plan's segments rather than the US-allocation kBands defaults. Filed #NNNN as a follow-up to share the 73, Jeremy KK7GWY & Claude (AI dev partner) |
|
Follow-up filed: #2822 — extract |
Summary
Fixes #2800
What was changed
Respect active band plan in Antenna SWR sweep (#2800). Principle IV.
Files modified
src/gui/MainWindow.cppGenerated by AetherClaude (automated agent for AetherSDR)