mirror of
https://git.vladimir.cc/vladimir/ewsdr.git
synced 2026-08-25 17:27:32 +00:00
Phase 3 (WA2b): move web Drive handler into the web adapter
Now that SetDrive is a complete command, the web/CAT Drive handler moves into TWebAdapter.OnDrive (the one handler WA1 left behind). CAT context SetDriveLevel repointed to it too. Makes the channel-power-clear reactive: ChannelController.OnDriveChanged fires on the rfDrive event and clears FPreChannelPower for any external drive change (slider/web/encoder), guarded by FRestoringDrive for the unit's own apply/restore. This removes the imperative ClearPreChannelPower coupling so SetDrive callers need no channel knowledge. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
03f7359184
commit
e5a13096dc
+23
-6
@@ -37,10 +37,12 @@ type
|
||||
FRadio: TRadioController;
|
||||
FActiveIdx: Integer; // -1 = нет активного канала
|
||||
FPreChannelPower: Integer; // drive % до применения канала (-1 = не сохранён)
|
||||
FRestoringDrive: Boolean; // True пока юнит сам ставит drive (apply/restore)
|
||||
FOnActiveChanged: TChannelActiveEvent;
|
||||
FOnActivateXvtr: TChannelXvtrEvent;
|
||||
FOnDeactivateXvtr: TChannelNotifyEvent;
|
||||
procedure EmitActive(Active: Boolean; const Name: string);
|
||||
procedure SetDriveGuarded(V: Integer); // SetDrive, не сбрасывающий память канала
|
||||
public
|
||||
constructor Create(ARadio: TRadioController);
|
||||
|
||||
@@ -48,7 +50,7 @@ type
|
||||
procedure Apply(const Ch: TChannel); // применить канал к радио
|
||||
procedure CheckActive; // деактивировать при уходе с частоты
|
||||
procedure OnVfoTuned; // канальная оркестрация после SetVfoA
|
||||
procedure ClearPreChannelPower; // ручное изменение drive снимает память
|
||||
procedure OnDriveChanged; // реакция на rfDrive: внешнее изменение снимает память
|
||||
|
||||
property ActiveIdx: Integer read FActiveIdx write FActiveIdx;
|
||||
property OnActiveChanged: TChannelActiveEvent read FOnActiveChanged write FOnActiveChanged;
|
||||
@@ -71,9 +73,24 @@ begin
|
||||
if Assigned(FOnActiveChanged) then FOnActiveChanged(FActiveIdx, Name, Active);
|
||||
end;
|
||||
|
||||
procedure TChannelController.ClearPreChannelPower;
|
||||
procedure TChannelController.SetDriveGuarded(V: Integer);
|
||||
// Drive, выставляемый самим юнитом (применение мощности канала / восстановление):
|
||||
// rfDrive прилетит, но OnDriveChanged НЕ должен трактовать его как ручной → не
|
||||
// сбрасывать FPreChannelPower.
|
||||
begin
|
||||
FPreChannelPower := -1;
|
||||
FRestoringDrive := True;
|
||||
try
|
||||
FRadio.SetDrive(V);
|
||||
finally
|
||||
FRestoringDrive := False;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TChannelController.OnDriveChanged;
|
||||
// Вызывается из OnControllerState(rfDrive). Любое ВНЕШНЕЕ изменение drive
|
||||
// (слайдер/web/энкодер) снимает сохранённую «до канала» мощность.
|
||||
begin
|
||||
if not FRestoringDrive then FPreChannelPower := -1;
|
||||
end;
|
||||
|
||||
procedure TChannelController.Select(Idx: Integer);
|
||||
@@ -144,7 +161,7 @@ begin
|
||||
begin
|
||||
if FPreChannelPower < 0 then
|
||||
FPreChannelPower := FRadio.FDrivePercent;
|
||||
FRadio.SetDrive(EnsureRange(Ch.Power, 0, 100));
|
||||
SetDriveGuarded(EnsureRange(Ch.Power, 0, 100));
|
||||
end;
|
||||
|
||||
// Частота VFO A (XVTR-клэмп, CTUN, band-detect, сеть — всё в SetVfoA)
|
||||
@@ -189,7 +206,7 @@ begin
|
||||
// Восстанавливаем мощность которая была до применения канала
|
||||
if FPreChannelPower >= 0 then
|
||||
begin
|
||||
FRadio.SetDrive(FPreChannelPower);
|
||||
SetDriveGuarded(FPreChannelPower);
|
||||
FPreChannelPower := -1;
|
||||
end;
|
||||
end;
|
||||
@@ -209,7 +226,7 @@ begin
|
||||
end;
|
||||
if FPreChannelPower >= 0 then
|
||||
begin
|
||||
FRadio.SetDrive(FPreChannelPower); // восстановить + push + рендер слайдера
|
||||
SetDriveGuarded(FPreChannelPower); // восстановить + push + рендер слайдера
|
||||
FPreChannelPower := -1;
|
||||
end;
|
||||
end;
|
||||
|
||||
Reference in New Issue
Block a user