Phase 5: make XVTR enter/exit full controller commands

Move the xvtr wrapper render-extras (wideband view + web push) into the rfXvtr
render handler, and the HF-return (RestoreBand) into core DeactivateXvtr — emitting
rfXvtr *after* RestoreBand so the extras render sees the settled HF state.
MainForm.ActivateXvtrBand/DeactivateXvtr collapse to thin delegates.

ChannelController drops its OnActivateXvtr/OnDeactivateXvtr host callbacks and calls
FRadio.SetXvtrBand directly — no host coupling left, only the OnActiveChanged out-event.

Also fixes a latent regression from the OnAfterTune hook: an intermediate SetVfoA
during channel Apply (xvtr-exit → RestoreBand → retune to the old freq) fired
OnVfoTuned and deactivated the channel mid-apply. Apply is now atomic w.r.t.
channel orchestration via an FApplying guard.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Uladzimir Karpenka
2026-06-09 09:59:20 +03:00
co-authored by Claude Opus 4.8
parent de1f4b772d
commit cc8380ae85
3 changed files with 39 additions and 38 deletions
+15 -21
View File
@@ -756,8 +756,6 @@ begin
// XVTR-вход/выход — через UI-обёртки (wideband/web живут в них).
FChannelController := TChannelController.Create(FController);
FChannelController.OnActiveChanged := OnChannelActiveChanged;
FChannelController.OnActivateXvtr := ActivateXvtrBand;
FChannelController.OnDeactivateXvtr := DeactivateXvtr;
// Канал-оркестрация фаером из контроллера в конце SetVfoA (любой путь тюнинга).
FController.OnAfterTune := FChannelController.OnVfoTuned;
FController.FVfoA := 14200000;
@@ -1218,9 +1216,17 @@ begin
StyleButton(BtnBand[i],
(FController.FCurrentXvtr < 0) and (i = FController.FCurrentBand));
rfXvtr:
for i := 0 to CFG_XVTR_COUNT - 1 do
if BtnXvtrBand[i] <> nil then
StyleButton(BtnXvtrBand[i], i = FController.FCurrentXvtr);
begin
for i := 0 to CFG_XVTR_COUNT - 1 do
if BtnXvtrBand[i] <> nil then
StyleButton(BtnXvtrBand[i], i = FController.FCurrentXvtr);
// Wideband-вид + web-зеркало xvtr (ранее в обёртках Activate/Deactivate).
// rfXvtr эмитят ТОЛЬКО ActivateXvtr/DeactivateXvtr — состояние финальное.
UpdateWidebandFrequencyView;
if PbWideband <> nil then PbWideband.Invalidate;
if PbWidebandRuler <> nil then PbWidebandRuler.Invalidate;
PushXvtrToWeb;
end;
rfBandRestore:
// Явная смена диапазона: сброс порогов водопада (не на каждом тюне).
FSpecView.ResetWfAvgBuf;
@@ -5141,13 +5147,9 @@ end;
// середине [FreqBegin..FreqEnd], применяет network XVTR-режим.
procedure TMainForm.ActivateXvtrBand(Idx: Integer);
begin
// Вход в XVTR-слот (state+DSP+VFO+сеть) — в контроллере; рендер кнопок/частот/
// спектра — через события (rfXvtr/rfBand/rfActiveVfo). Здесь только UI: wideband+web.
// Тонкий делегат: вход в XVTR-слот + рендер кнопок/частот/спектра/wideband/web —
// всё в команде/событиях (rfXvtr/rfBand/rfActiveVfo).
FController.ActivateXvtr(Idx);
UpdateWidebandFrequencyView;
if PbWideband <> nil then PbWideband.Invalidate;
if PbWidebandRuler <> nil then PbWidebandRuler.Invalidate;
PushXvtrToWeb;
end;
// Деактивирует XVTR — возвращает к HF-режиму. FController.FCurrentBand указывает
@@ -5155,17 +5157,9 @@ end;
// VFO/Mode/Filter/AGC/CTUN/Span этого диапазона и обновит подсветку HF band-кнопки.
procedure TMainForm.DeactivateXvtr;
begin
if FController.FCurrentXvtr < 0 then Exit;
// Сохранение слота + выход (+ гашение XVTR-кнопок через rfXvtr) — в контроллере.
// Тонкий делегат: выход в HF (SaveCurrentBand + HF-возврат RestoreBand + рендер
// кнопок/wideband/web) — всё в команде/событиях.
FController.DeactivateXvtr;
// HF-возврат: состояние/DSP из кэша + финальная перестройка активного VFO
// (через UI-путь RestoreBand: ResetWfAvgBuf + controller.RestoreBand + ApplyVfoA/SetVfoB).
if (FController.FCurrentBand >= 0) and (FController.FCurrentBand < CFG_BAND_COUNT) then
RestoreBand(FController.FCurrentBand);
UpdateWidebandFrequencyView;
if PbWideband <> nil then PbWideband.Invalidate;
if PbWidebandRuler <> nil then PbWidebandRuler.Invalidate;
PushXvtrToWeb;
end;
procedure TMainForm.OnXvtrSettingsChange(const X: TXvtrSettings);