From c7d93c2e46eaca3b7782ca330263d56036d26636 Mon Sep 17 00:00:00 2001 From: Uladzimir Karpenka Date: Fri, 5 Jun 2026 16:55:04 +0300 Subject: [PATCH] Phase 3 (batch 20): unify web/CAT VFO-B onto the SetVfoB command SyncWebFreq (VFO-B branch), SyncWebFreqB and SyncCATVfoB each carried a copy of the pre-SetVfoB inline VFO-B block that pushed the radio via SetRunAndFreq(True,...). That reset the HP sequence counter on every freq change (only correct at Run start), left FIsTransmitting/Alex flags stale, skipped the drive recalc on a band crossing, and forced shift=0 (ignoring CTUN). All three now delegate to FController.SetVfoB, so web, CAT and desktop share one path (ApplyTuneCore + PushNetworkState) with rendering via OnControllerState(rfVfoB/rfBand). ~70 lines removed. Co-Authored-By: Claude Opus 4.8 --- MainForm.pas | 75 ++++++---------------------------------------------- 1 file changed, 8 insertions(+), 67 deletions(-) diff --git a/MainForm.pas b/MainForm.pas index f5f34f4..9f573f1 100644 --- a/MainForm.pas +++ b/MainForm.pas @@ -5611,32 +5611,13 @@ begin end; procedure TMainForm.SyncWebFreq; -var BandIdx: Integer; begin - // Веб шлёт "freq" для активного VFO + // Веб шлёт "freq" для активного VFO — маршрутизируем через те же команды, + // что и десктоп (рендер/сеть/band-detect внутри них и в OnControllerState). if FController.FActiveVfo = 0 then ApplyVfoA(Round(FWebSyncFreq)) else - begin - FController.FVfoB := FWebSyncFreq; - FreqDispB.Frequency := Round(FController.FVfoB); - FController.FCenterFreq := FController.FVfoB; - if FController.FWDSPReady then FController.FDSPEngine.SetShift(0.0); - if FController.FRunning then - FController.FNetwork.SetRunAndFreq(True, XvtrTranslate(FController.FCenterFreq), XvtrTranslate(FController.FCenterFreq), FController.FDriveLevel); - BandIdx := FreqToBandIdx(FController.FVfoB); - if (BandIdx >= 0) and (BandIdx <> FController.FCurrentBand) then - begin - StyleButton(BtnBand[FController.FCurrentBand], False); - FController.FCurrentBand := BandIdx; - StyleButton(BtnBand[FController.FCurrentBand], True); - end; - FSpecView.InvalidateRulerCache; - SyncSpecViewFreq; - FSpecView.DrawSpectrum; PbSpectrum.Invalidate; - if PbRuler <> nil then PbRuler.Invalidate; - UpdateVfoDisplay; - end; + FController.SetVfoB(FWebSyncFreq); end; procedure TMainForm.WebOnMode(Mode: Integer); @@ -5956,30 +5937,10 @@ begin end; procedure TMainForm.SyncWebFreqB; -var BandIdx: Integer; begin - FController.FVfoB := FWebSyncFreq; - FreqDispB.Frequency := Round(FController.FVfoB); - if FController.FActiveVfo = 1 then - begin - FController.FCenterFreq := FController.FVfoB; - if not FController.FCTun then - if FController.FWDSPReady then FController.FDSPEngine.SetShift(0.0); - if FController.FRunning then - FController.FNetwork.SetRunAndFreq(True, XvtrTranslate(FController.FCenterFreq), XvtrTranslate(FController.FCenterFreq), FController.FDriveLevel); - BandIdx := FreqToBandIdx(FController.FVfoB); - if (BandIdx >= 0) and (BandIdx <> FController.FCurrentBand) then - begin - StyleButton(BtnBand[FController.FCurrentBand], False); - FController.FCurrentBand := BandIdx; - StyleButton(BtnBand[FController.FCurrentBand], True); - end; - FSpecView.InvalidateRulerCache; - SyncSpecViewFreq; - FSpecView.DrawSpectrum; PbSpectrum.Invalidate; - if PbRuler <> nil then PbRuler.Invalidate; - end; - UpdateVfoDisplay; + // Унифицировано с десктопом: команда хранит частоту, при активном B + // перестраивает приёмник (CTUN-aware) + сеть; рендер — через rfVfoB/rfBand. + FController.SetVfoB(FWebSyncFreq); end; // ── Активный VFO (из веба) ─────────────────────────────────────────────── @@ -7063,29 +7024,9 @@ begin end; procedure TMainForm.SyncCATVfoB; -var BandIdx: Integer; begin - FController.FVfoB := FCATSyncFreq; - FreqDispB.Frequency := Round(FController.FVfoB); - if FController.FActiveVfo = 1 then - begin - FController.FCenterFreq := FController.FVfoB; - if FController.FWDSPReady then FController.FDSPEngine.SetShift(0.0); - if FController.FRunning then - FController.FNetwork.SetRunAndFreq(True, XvtrTranslate(FController.FCenterFreq), XvtrTranslate(FController.FCenterFreq), FController.FDriveLevel); - BandIdx := FreqToBandIdx(FController.FVfoB); - if (BandIdx >= 0) and (BandIdx <> FController.FCurrentBand) then - begin - StyleButton(BtnBand[FController.FCurrentBand], False); - FController.FCurrentBand := BandIdx; - StyleButton(BtnBand[FController.FCurrentBand], True); - end; - FSpecView.InvalidateRulerCache; - SyncSpecViewFreq; - FSpecView.DrawSpectrum; PbSpectrum.Invalidate; - if PbRuler <> nil then PbRuler.Invalidate; - UpdateVfoDisplay; - end; + // Унифицировано с десктопом/вебом: та же команда SetVfoB. + FController.SetVfoB(FCATSyncFreq); end; procedure TMainForm.SyncCATBandUp;