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 <noreply@anthropic.com>
This commit is contained in:
Uladzimir Karpenka
2026-06-05 16:55:04 +03:00
co-authored by Claude Opus 4.8
parent 492b29bea1
commit c7d93c2e46
+8 -67
View File
@@ -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;