Phase 4: extract CAT into its own adapter (CATAdapter.pas)

CAT becomes a peer adapter over the controller, alongside WebAdapter. TCATAdapter
owns the CAT engine + serial/TCP transports and builds the TCATContext: getters
read FController directly (CAT thread), setters/commands call controller commands
marshaled via FController.Invoke. No MainForm or WebAdapter dependency — the
historical CAT->WebAdapter.OnXxx coupling (Mode/AGC/Band/etc.) is gone; CAT talks
only to the controller.

MainForm keeps CAT *settings* (FCATLastGlobal + OnCATSettingsChange + SettingsForm
wiring), now calling FCATAdapter.ApplySettings on change/connect. Removed
InitCATEngine, CATApplySettings, all CATGet*/CATSet*/CATDo*/SyncCAT* and the
FCATEngine/FCATSerial/FCATTcp/FCATSyncFreq fields.

Fixes a latent bug: CATSetFilterIdx routed a filter index through the web BW handler
as a negative-encoded value, but that branch was dead since batch 21 — CAT now calls
FController.SetFilterIdx directly. Adds StoreVfoA (store VFO A without retune when B
is active) and uses the now-real SetBand/BandUp/BandDown/TuneActiveBy commands.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Uladzimir Karpenka
2026-06-09 14:29:56 +03:00
co-authored by Claude Opus 4.8
parent daee5672a9
commit 682025e99b
3 changed files with 355 additions and 234 deletions
+22
View File
@@ -350,6 +350,7 @@ type
// Частоты / VFO
procedure SetVfoA(Hz: Double);
procedure StoreVfoA(Hz: Double); // сохранить частоту A без перестройки (когда активен B)
procedure SetVfoB(Hz: Double);
procedure SetActiveVfo(Idx: Integer);
procedure TuneActiveBy(DeltaHz: Double); // энкодер VFO
@@ -1249,6 +1250,27 @@ begin
if Assigned(FOnAfterTune) then FOnAfterTune;
end;
procedure TRadioController.StoreVfoA(Hz: Double);
// Сохранить частоту VFO A БЕЗ перестройки приёмника (когда активен B — слушаем B,
// A только хранится/отображается). Симметрично «неактивной» ветке SetVfoB.
// Рендер FreqDispA — через rfVfoA (спектр он не трогает, т.к. SyncSpecViewFreq
// держит активный VFO B); смена band-кнопки — через rfBand.
var BandIdx: Integer;
begin
FVfoA := Hz;
if FCurrentXvtr < 0 then
begin
BandIdx := FreqToBandIdx(FVfoA);
if (BandIdx >= 0) and (BandIdx <> FCurrentBand) then
begin
FCurrentBand := BandIdx;
FDriveLevel := CalcDriveByte;
Changed(rfBand);
end;
end;
Changed(rfVfoA);
end;
procedure TRadioController.SetVfoB(Hz: Double);
// VFO B всегда сохраняется. Если B активен — перестраиваем приёмник через
// ApplyTuneCore (с учётом CTUN), детектим диапазон и толкаем в сеть. Если B