mirror of
https://git.vladimir.cc/vladimir/ewsdr.git
synced 2026-08-25 18:43:51 +00:00
Phase 5 (batch 25a): de-dup telemetry fields + push web-client-active to core
Prep for moving the HP-status callback into the controller:
- Remove the duplicate FLast{SMeter,FwdW,SWR,SupplyV,SupplyA,PLLLock}
fields from MainForm; the controller (which already declared them) is
now the sole owner. The UI-only S-meter ballistics (FSMeterPeak/Min/Avg)
stay in MainForm.
- TWebServer gains an OnClientActiveChanged event (fired via a
SetClientActive setter at the three client connect/disconnect points);
MainForm mirrors it into FController.FWebClientActive. The lazy mirror
in ApplyMOX/ApplyTUN is removed, so the flag is always current — needed
for the HWPTT->SetMOX path that moves into the controller next.
Behaviour-preserving (the flag held the same value at MOX time before).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
239ff54942
commit
9d2324cc6c
+23
-5
@@ -151,6 +151,9 @@ type
|
||||
// XVTR-band: web клиент кликнул кнопку трансвертера (Idx 0..CFG_XVTR_COUNT-1).
|
||||
// Idx=-1 — выход в HF.
|
||||
TWebCmdXvtrBand = procedure(Idx: Integer) of object;
|
||||
// Активность web-клиента изменилась (подключился/отключился последний клиент).
|
||||
// Хозяин зеркалит это в ядро (FController.FWebClientActive) для выбора mic-source.
|
||||
TWebClientActiveEvent = procedure(Active: Boolean) of object;
|
||||
// Один XVTR-слот для статуса (для отображения в web-bandSel).
|
||||
TWebXvtrInfo = record
|
||||
Idx: Integer;
|
||||
@@ -294,6 +297,11 @@ type
|
||||
FSeqText: string;
|
||||
|
||||
FWebClientActive: Boolean;
|
||||
FOnClientActiveChanged: TWebClientActiveEvent;
|
||||
|
||||
// Обновляет FWebClientActive и при изменении уведомляет хозяина. Вызывать
|
||||
// под уже взятой блокировкой поля (FStateLock/FClientLock) — сам не лочит.
|
||||
procedure SetClientActive(Value: Boolean);
|
||||
|
||||
// ── Внутренние методы ──
|
||||
function LoadOpus: Boolean;
|
||||
@@ -346,6 +354,8 @@ type
|
||||
RXText, TXText, SeqText: string);
|
||||
|
||||
property WebClientActive: Boolean read FWebClientActive;
|
||||
property OnClientActiveChanged: TWebClientActiveEvent
|
||||
read FOnClientActiveChanged write FOnClientActiveChanged;
|
||||
property FreqMhzDigits: Integer read FFreqMhzDigits write FFreqMhzDigits;
|
||||
property FMStepIdx: Integer read FFMStepIdx write FFMStepIdx;
|
||||
|
||||
@@ -980,7 +990,7 @@ begin
|
||||
Client.State := wsOpen;
|
||||
|
||||
FStateLock.Enter;
|
||||
FWebClientActive := True;
|
||||
SetClientActive(True);
|
||||
FStateLock.Leave;
|
||||
|
||||
Client.SendText(BuildStateJson);
|
||||
@@ -1114,14 +1124,21 @@ begin
|
||||
end;
|
||||
|
||||
FStateLock.Enter;
|
||||
FWebClientActive := (FClientCount > 1);
|
||||
SetClientActive(FClientCount > 1);
|
||||
FStateLock.Leave;
|
||||
|
||||
RemoveClient(Client);
|
||||
end;
|
||||
|
||||
procedure TWebServer.SetClientActive(Value: Boolean);
|
||||
begin
|
||||
if FWebClientActive = Value then Exit;
|
||||
FWebClientActive := Value;
|
||||
if Assigned(FOnClientActiveChanged) then FOnClientActiveChanged(Value);
|
||||
end;
|
||||
|
||||
procedure TWebServer.RemoveClient(Client: TWsClient);
|
||||
var i, j: Integer;
|
||||
var i, j: Integer; NewActive: Boolean;
|
||||
begin
|
||||
FClientLock.Enter;
|
||||
try
|
||||
@@ -1134,10 +1151,11 @@ begin
|
||||
Dec(FClientCount);
|
||||
Break;
|
||||
end;
|
||||
FWebClientActive := False;
|
||||
NewActive := False;
|
||||
for i := 0 to FClientCount - 1 do
|
||||
if (FClients[i] <> nil) and (FClients[i].State = wsOpen) then
|
||||
begin FWebClientActive := True; Break; end;
|
||||
begin NewActive := True; Break; end;
|
||||
SetClientActive(NewActive);
|
||||
finally
|
||||
FClientLock.Leave;
|
||||
end;
|
||||
|
||||
Reference in New Issue
Block a user