mirror of
https://git.vladimir.cc/vladimir/ewsdr.git
synced 2026-08-25 19:45:09 +00:00
- BoardUtils: BoardTypeName (removes duplication with DeviceForm) - WisdomBuilder: TWisdomBuildThread + TWisdomProgressDialog - UISync: TDeviceFoundSync/TStatusUISync/TDDCSeqSync via callbacks (avoids circular dependency, removes TObject casts) - PlatformUtils: HasOpenGLSpectrumSwitch + CurrentScreenDPI Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
130 lines
2.9 KiB
ObjectPascal
130 lines
2.9 KiB
ObjectPascal
unit WisdomBuilder;
|
|
|
|
{$IFDEF FPC}
|
|
{$MODE Delphi}
|
|
{$ENDIF}
|
|
|
|
interface
|
|
|
|
uses
|
|
Classes, SysUtils, Forms, Controls, ExtCtrls, StdCtrls,
|
|
WDSP, AppTheme, FlatProgressBar;
|
|
|
|
type
|
|
TWisdomBuildThread = class(TThread)
|
|
private
|
|
FDirectory: string;
|
|
FError: string;
|
|
protected
|
|
procedure Execute; override;
|
|
public
|
|
constructor Create(const ADirectory: string);
|
|
property ErrorText: string read FError;
|
|
end;
|
|
|
|
TWisdomProgressDialog = class(TForm)
|
|
private
|
|
FInfoLabel: TLabel;
|
|
FProgress: TFlatProgressBar;
|
|
FTimer: TTimer;
|
|
FThread: TWisdomBuildThread;
|
|
FPhase: Integer;
|
|
procedure TimerTick(Sender: TObject);
|
|
public
|
|
constructor Create(AOwner: TComponent; AThread: TWisdomBuildThread;
|
|
const ATheme: TAppTheme); reintroduce;
|
|
end;
|
|
|
|
implementation
|
|
|
|
constructor TWisdomBuildThread.Create(const ADirectory: string);
|
|
begin
|
|
inherited Create(False);
|
|
FreeOnTerminate := False;
|
|
FDirectory := ADirectory;
|
|
FError := '';
|
|
end;
|
|
|
|
procedure TWisdomBuildThread.Execute;
|
|
var
|
|
DirA: AnsiString;
|
|
begin
|
|
try
|
|
if not Assigned(@WDSPwisdom) then Exit;
|
|
DirA := AnsiString(FDirectory);
|
|
WDSPwisdom(PAnsiChar(DirA));
|
|
except
|
|
on E: Exception do
|
|
FError := E.ClassName + ': ' + E.Message;
|
|
end;
|
|
end;
|
|
|
|
constructor TWisdomProgressDialog.Create(AOwner: TComponent;
|
|
AThread: TWisdomBuildThread; const ATheme: TAppTheme);
|
|
begin
|
|
inherited CreateNew(AOwner);
|
|
FThread := AThread;
|
|
FPhase := 0;
|
|
|
|
Caption := 'WDSP Wisdom';
|
|
Width := 520;
|
|
Height := 140;
|
|
Position := poScreenCenter;
|
|
BorderStyle := bsDialog;
|
|
BorderIcons := [];
|
|
Color := ATheme.BG;
|
|
Font.Name := 'Courier New';
|
|
Font.Size := 9;
|
|
Font.Color := ATheme.Text;
|
|
|
|
FInfoLabel := TLabel.Create(Self);
|
|
FInfoLabel.Parent := Self;
|
|
FInfoLabel.SetBounds(16, 16, 480, 40);
|
|
FInfoLabel.AutoSize := False;
|
|
FInfoLabel.WordWrap := True;
|
|
FInfoLabel.Font.Color := ATheme.Text;
|
|
FInfoLabel.Caption :=
|
|
'Creating FFTW wisdom for WDSP. This is done once and may take a while on the first run.';
|
|
|
|
FProgress := TFlatProgressBar.Create(Self);
|
|
FProgress.Parent := Self;
|
|
FProgress.SetBounds(16, 72, 480, 22);
|
|
FProgress.Min := 0;
|
|
FProgress.Max := 100;
|
|
FProgress.Position := 0;
|
|
FProgress.SetAppTheme(ATheme);
|
|
|
|
FTimer := TTimer.Create(Self);
|
|
FTimer.Interval := 250;
|
|
FTimer.OnTimer := TimerTick;
|
|
FTimer.Enabled := True;
|
|
end;
|
|
|
|
procedure TWisdomProgressDialog.TimerTick(Sender: TObject);
|
|
var
|
|
P: PAnsiChar;
|
|
S: string;
|
|
begin
|
|
FPhase := (FPhase + 7) mod 101;
|
|
FProgress.Position := FPhase;
|
|
|
|
if Assigned(@wisdom_get_status) then
|
|
begin
|
|
P := wisdom_get_status;
|
|
if P <> nil then
|
|
begin
|
|
S := Trim(string(AnsiString(P)));
|
|
if S <> '' then
|
|
FInfoLabel.Caption := S;
|
|
end;
|
|
end;
|
|
|
|
if Assigned(FThread) and FThread.Finished then
|
|
begin
|
|
FTimer.Enabled := False;
|
|
ModalResult := mrOk;
|
|
end;
|
|
end;
|
|
|
|
end.
|