Phase 3 (WA2d): move web Band/XvtrBand handlers into the adapter

Now that RestoreBand and XVTR enter/exit are full controller commands, the web
Band and XvtrBand handlers carry no MainForm orchestration — move them to
TWebAdapter.OnBand/OnXvtrBand (validation + SaveCurrentBand/persist + command).
CAT Ctx.DoBandByIndex and CAT band up/down repointed to FWebAdapter.OnBand.

Remaining host-coupled web handlers: Freq/FreqA (ApplyVfoA channel orchestration),
Run/Connect/device CRUD (daemon entry).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Uladzimir Karpenka
2026-06-09 10:09:06 +03:00
co-authored by Claude Opus 4.8
parent cc8380ae85
commit 7630172e50
2 changed files with 44 additions and 54 deletions
+5 -53
View File
@@ -437,10 +437,8 @@ type
// WfAGC/WfNF/Mute/NR/NB/SNB/ANF/FreqB/Center/Attn/ActiveVfo/Ctun/MOX/Tun/FMStep/
// ClientActive). Здесь только то, что дёргает UI-обёртки MainForm.
procedure WebOnFreq(Hz: Double);
procedure WebOnBand(Idx: Integer);
procedure WebOnRun(On_: Boolean);
procedure WebOnFreqA(Hz: Double);
procedure WebOnXvtrBand(Idx: Integer);
// Discovery / connect / saved-CRUD из web (маршалятся в UI)
procedure WebOnConnect(const IP: string);
procedure WebOnDiscover;
@@ -457,8 +455,6 @@ type
procedure PushDeviceListToWeb; // store → FWebServer.SetDeviceList
// Synchronize-обёртки (выполняются в UI-потоке) — только host-зависимые
procedure SyncWebFreq;
procedure SyncWebBand;
procedure SyncWebXvtrBand;
procedure SyncWebRun;
procedure SyncWebFreqA;
// --- CAT callbacks -------------------------------------------------------
@@ -885,13 +881,13 @@ begin
FWebServer.OnFMStep := FWebAdapter.OnFMStep;
// Host-зависимые (UI-обёртки) — пока на MainForm:
FWebServer.OnFreq := WebOnFreq;
FWebServer.OnBand := WebOnBand;
FWebServer.OnBand := FWebAdapter.OnBand;
FWebServer.OnSpan := FWebAdapter.OnSpan;
FWebServer.OnRun := WebOnRun;
FWebServer.OnDrive := FWebAdapter.OnDrive;
FWebServer.OnFreqA := WebOnFreqA;
FWebServer.OnWebMic := FWebAdapter.OnMic;
FWebServer.OnXvtrBand := WebOnXvtrBand;
FWebServer.OnXvtrBand := FWebAdapter.OnXvtrBand;
FWebServer.OnConnect := WebOnConnect;
FWebServer.OnDiscoverDev := WebOnDiscover;
FWebServer.OnDisconnectDev := WebOnDisconnect;
@@ -4681,50 +4677,6 @@ end;
// Mode/Filter/AGC/AGCTop/Volume/WfAGC/WfNF/Mute/NR/NB/SNB/ANF/FreqB/Center/Attn +
// ClientActiveChanged перенесены в TWebAdapter (чистые команды контроллера).
procedure TMainForm.WebOnBand(Idx: Integer);
begin
FWebSyncInt := Idx;
FWebSyncM := SyncWebBand;
TThread.Synchronize(nil, FWebSyncM);
end;
procedure TMainForm.SyncWebBand;
begin
if (FWebSyncInt < 0) or (FWebSyncInt >= BAND_COUNT) then Exit;
// Выйти из XVTR при переходе на HF из web. DeactivateXvtr вернёт HF-состояние.
if FController.FCurrentXvtr >= 0 then
begin
DeactivateXvtr;
if FWebSyncInt = FController.FCurrentBand then Exit;
end
else if FWebSyncInt = FController.FCurrentBand then
Exit;
if FController.FDevConnected then begin SaveCurrentBand; FController.FSettings.Save; end;
FController.FCurrentBand := FWebSyncInt;
RestoreBand(FController.FCurrentBand);
end;
procedure TMainForm.WebOnXvtrBand(Idx: Integer);
begin
FWebSyncInt := Idx;
FWebSyncM := SyncWebXvtrBand;
TThread.Synchronize(nil, FWebSyncM);
end;
procedure TMainForm.SyncWebXvtrBand;
begin
if FWebSyncInt < 0 then
begin
DeactivateXvtr;
Exit;
end;
if (FWebSyncInt >= CFG_XVTR_COUNT) then Exit;
if not FController.FXvtrSettings.Entries[FWebSyncInt].Enabled then Exit;
if FWebSyncInt = FController.FCurrentXvtr then Exit;
if FController.FDevConnected then begin SaveCurrentBand; FController.FSettings.Save; end;
ActivateXvtrBand(FWebSyncInt);
end;
// ── Run ────────────────────────────────────────────────────────────────────
procedure TMainForm.WebOnRun(On_: Boolean);
@@ -5661,7 +5613,7 @@ begin
Ctx.DoBandDown := CATDoBandDown;
Ctx.DoTuneUp := CATDoTuneUp;
Ctx.DoTuneDown := CATDoTuneDown;
Ctx.DoBandByIndex := WebOnBand;
Ctx.DoBandByIndex := FWebAdapter.OnBand;
FCATEngine := TCATEngine.Create(Ctx);
FCATSerial := TCATSerialManager.Create(FCATEngine);
FCATTcp := TCATTcpServer.Create(FCATEngine);
@@ -5813,13 +5765,13 @@ end;
procedure TMainForm.SyncCATBandUp;
begin
if FController.FCurrentBand < BAND_COUNT - 1 then
WebOnBand(FController.FCurrentBand + 1);
FWebAdapter.OnBand(FController.FCurrentBand + 1);
end;
procedure TMainForm.SyncCATBandDown;
begin
if FController.FCurrentBand > 0 then
WebOnBand(FController.FCurrentBand - 1);
FWebAdapter.OnBand(FController.FCurrentBand - 1);
end;
procedure TMainForm.SyncCATTuneUp;