diff --git a/MainForm.pas b/MainForm.pas index 3776e35..bd29769 100644 --- a/MainForm.pas +++ b/MainForm.pas @@ -3054,8 +3054,6 @@ procedure TMainForm.SpectrumTimerTick(Sender: TObject); var NowTick: QWord; ElapsedTick: QWord; - WebStatusText, WebBoardText, WebIPText, WebSupplyText: string; - WebPLLText, WebRXText, WebTXText, WebSeqText: string; begin // Синхронизируем размеры если размер панели изменился (после ресайза). // Важно: проверяем только видимые панели — когда спектр скрыт, @@ -3195,88 +3193,10 @@ begin FSpectrumDirty := False; end; - // Пушим текущее состояние в веб-клиенты (если есть) - if Assigned(FWebServer) then - begin - if FController.FNetwork.Connected then - begin - if FController.FRunning then - WebStatusText := 'Running' - else - WebStatusText := 'Connected'; - WebBoardText := 'Board: ' + BoardTypeName(FController.FNetwork.Device.BoardType); - WebIPText := 'IP: ' + FController.FNetwork.Device.IPAddress; - end - else - begin - WebStatusText := 'Disconnected'; - WebBoardText := 'Board --'; - WebIPText := 'IP --'; - end; - - if not FController.FRunning then - begin - WebSupplyText := 'Supply --'; - WebPLLText := 'PLL --'; - end - else - begin - if FController.FLastPLLLock then - WebPLLText := 'PLL OK' - else - WebPLLText := 'PLL?'; - - if not BoardSupportsSupplyVoltage(FController.FNetwork.Device.BoardType) then - WebSupplyText := 'Supply n/a' - else if FController.FLastSupplyV >= 0 then - begin - if FController.FLastSupplyA >= 0 then - WebSupplyText := Format('Supply %.1fV %.1fA', [FController.FLastSupplyV, FController.FLastSupplyA]) - else - WebSupplyText := Format('Supply %.1fV', [FController.FLastSupplyV]); - end - else - WebSupplyText := 'Supply --'; - end; - - if FController.FRunning then - WebRXText := 'RX running' - else - WebRXText := 'RX idle'; - - if FController.FTuning then - WebTXText := 'TX tune' - else if FController.FTransmitting then - WebTXText := 'TX active' - else - WebTXText := 'TX idle'; - - if FController.FSeqErrorCount > 0 then - WebSeqText := Format('SEQ ERR DDC%d', [FController.FLastSeqErrorDDC]) - else if FController.FRunning then - WebSeqText := 'SEQ OK' - else - WebSeqText := 'SEQ --'; - - FWebServer.PushSpectrum( - FSpectrumBuf, 1024, - FWaterfallBuf, - FController.FLastSMeter, - FController.FVfoA, FController.FMode, FController.FFilterBW, FController.FAGCMode, FController.FAGCTop, - FController.FSpanHz, FController.FVolume, - FController.FWfAGCEnabled, FController.FWfNFEnabled, - FController.FCurrentBand, - FController.FRunning and FController.FNetwork.Connected, - FController.FRunning, FController.FMuted, FController.FCTun, - FController.FNRMode, FController.FNBMode, FController.FSNB, FController.FANF, - FController.FCenterFreq, FController.FFilter, - FController.FVfoB, FController.FActiveVfo, - FController.FTransmitting, FController.FDrivePercent, - FController.FAtten, FController.FTuning, FController.FDisplayDuplex, - FController.FLastFwdW, FController.FLastSWR, FController.FPAMaxPower, - WebStatusText, WebBoardText, WebIPText, WebSupplyText, - WebPLLText, WebRXText, WebTXText, WebSeqText); - end; + // Исходящее зеркало состояния + спектр/водопад в web — в адаптере (читает + // FController; буферы пикселей — у нас). Сервер сам гейтит по FRunning. + if Assigned(FWebAdapter) then + FWebAdapter.PushState(FSpectrumBuf, FWaterfallBuf); end; // =========================================================================== diff --git a/WebAdapter.pas b/WebAdapter.pas index 5508fdb..b34a7ea 100644 --- a/WebAdapter.pas +++ b/WebAdapter.pas @@ -19,7 +19,7 @@ interface uses Classes, SysUtils, - RadioController, WebServer, WDSPEngine; + RadioController, WebServer, WDSPEngine, HPSDRNetwork, HPSDRProtocol, BoardUtils; type // UI/оркестрационные операции, которые адаптер дёргает у хозяина (пока не @@ -91,6 +91,11 @@ type // TX-mic от web-клиента → WDSP. Вызывается из WS-потока; без маршалинга — // подача в движок thread-safe (как OnMicPacket/OnDDCIQ контроллера). procedure OnMic(Samples: PSingle; Count: Integer); + + // Исходящее зеркало: периодический снимок состояния + спектр/водопад в web. + // Зовётся хозяином из GUI-таймера (буферы пикселей — у хозяина, остальное из + // FController). Сервер сам гейтит по FRunning и шлёт активным клиентам. + procedure PushState(const ASpec, AWf: array of Single); end; implementation @@ -290,4 +295,82 @@ begin FController.FDSPEngine.PushTXMicSamplesD(Buf, n); end; +// ── Исходящее зеркало состояния ────────────────────────────────────────────── + +procedure TWebAdapter.PushState(const ASpec, AWf: array of Single); +var + StatusText, BoardText, IPText, SupplyText: string; + PLLText, RXText, TXText, SeqText: string; +begin + if FController.FNetwork.Connected then + begin + if FController.FRunning then StatusText := 'Running' + else StatusText := 'Connected'; + BoardText := 'Board: ' + BoardTypeName(FController.FNetwork.Device.BoardType); + IPText := 'IP: ' + FController.FNetwork.Device.IPAddress; + end + else + begin + StatusText := 'Disconnected'; + BoardText := 'Board --'; + IPText := 'IP --'; + end; + + if not FController.FRunning then + begin + SupplyText := 'Supply --'; + PLLText := 'PLL --'; + end + else + begin + if FController.FLastPLLLock then PLLText := 'PLL OK' + else PLLText := 'PLL?'; + + if not BoardSupportsSupplyVoltage(FController.FNetwork.Device.BoardType) then + SupplyText := 'Supply n/a' + else if FController.FLastSupplyV >= 0 then + begin + if FController.FLastSupplyA >= 0 then + SupplyText := Format('Supply %.1fV %.1fA', [FController.FLastSupplyV, FController.FLastSupplyA]) + else + SupplyText := Format('Supply %.1fV', [FController.FLastSupplyV]); + end + else + SupplyText := 'Supply --'; + end; + + if FController.FRunning then RXText := 'RX running' + else RXText := 'RX idle'; + + if FController.FTuning then TXText := 'TX tune' + else if FController.FTransmitting then TXText := 'TX active' + else TXText := 'TX idle'; + + if FController.FSeqErrorCount > 0 then + SeqText := Format('SEQ ERR DDC%d', [FController.FLastSeqErrorDDC]) + else if FController.FRunning then + SeqText := 'SEQ OK' + else + SeqText := 'SEQ --'; + + FServer.PushSpectrum( + ASpec, 1024, + AWf, + FController.FLastSMeter, + FController.FVfoA, FController.FMode, FController.FFilterBW, FController.FAGCMode, FController.FAGCTop, + FController.FSpanHz, FController.FVolume, + FController.FWfAGCEnabled, FController.FWfNFEnabled, + FController.FCurrentBand, + FController.FRunning and FController.FNetwork.Connected, + FController.FRunning, FController.FMuted, FController.FCTun, + FController.FNRMode, FController.FNBMode, FController.FSNB, FController.FANF, + FController.FCenterFreq, FController.FFilter, + FController.FVfoB, FController.FActiveVfo, + FController.FTransmitting, FController.FDrivePercent, + FController.FAtten, FController.FTuning, FController.FDisplayDuplex, + FController.FLastFwdW, FController.FLastSWR, FController.FPAMaxPower, + StatusText, BoardText, IPText, SupplyText, + PLLText, RXText, TXText, SeqText); +end; + end.