Phase 3 (batch 31a): shared TDeviceStore for saved+discovered devices

Introduce DeviceStore.pas (TDeviceStore) as the single source of truth for
saved devices (hpsdr_devices.ini CRUD + autostart) and the current discovery
list. The controller owns one instance (created/freed in its ctor/dtor);
desktop and (later) web frontends edit/render through it so the lists never
diverge.

Refactor TDeviceDialog to use a TDeviceStore reference instead of its own
arrays + ini code. MainForm wires FDeviceDialog.Store to the controller's
store, routes discovery results (DoAddDevice) and the preload-rate lookup
through it (TDiscoveredDevice now carries the MAC), and drops the now-unused
FDevices/TDeviceItem. Behavior-preserving for the desktop dialog.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Uladzimir Karpenka
2026-06-08 12:36:43 +03:00
co-authored by Claude Opus 4.8
parent 783c8976c9
commit 7f7f429515
4 changed files with 368 additions and 212 deletions
+4 -1
View File
@@ -50,7 +50,7 @@ uses
Classes, SysUtils, Math,
HPSDRProtocol, HPSDRNetwork,
WDSPEngine, AudioOutput, AudioInput,
Settings, ChannelStore, FMRepeater, BoardUtils;
Settings, ChannelStore, FMRepeater, BoardUtils, DeviceStore;
type
// Поле, которое изменилось — для гранулярных уведомлений наружу.
@@ -128,6 +128,7 @@ type
FAudioIn: TAudioInput;
FSettings: TSettingsManager;
FChannelStore: TChannelStore;
FDeviceStore: TDeviceStore; // общий список устройств (saved+discovered)
FWDSPReady: Boolean;
// ---- Частоты / режим / фильтр / AGC ----
@@ -413,6 +414,7 @@ constructor TRadioController.Create;
begin
inherited Create;
FSettings := TSettingsManager.Create; // владелец настроек (GUI и демон)
FDeviceStore := TDeviceStore.Create; // общий список устройств (desktop+web)
// Дефолты (дублируют TMainForm.FormCreate; в GUI перезапишутся, в демоне нужны).
FVfoA := 14200000; FVfoB := 7100000; FActiveVfo := 0;
FMode := 1; FFilter := 5; FFilterBW := 2700;
@@ -459,6 +461,7 @@ end;
destructor TRadioController.Destroy;
begin
FreeEngines;
FreeAndNil(FDeviceStore);
FreeAndNil(FSettings);
inherited Destroy;
end;