1st Aura Project Layout

This commit is contained in:
Michael Schimmel
2025-06-28 12:43:19 +02:00
parent 9802c8c924
commit b453236b1e
10 changed files with 891 additions and 189 deletions
+59 -28
View File
@@ -34,25 +34,30 @@ uses
Myc.Signals.FMX,
Myc.TaskManager,
FMX.ListBox,
FMX.Layouts;
FMX.Layouts,
FMX.MultiView,
FMX.TreeView;
type
TForm1 = class(TForm)
LogMemo: TMemo;
Panel1: TPanel;
RandomButton: TButton;
Path1: TPath;
Layout: TFlowLayout;
SymbolsComboBox: TComboBox;
RandomBox: TCheckBox;
LoadButton: TButton;
FlowLayout: TFlowLayout;
RandomButton: TButton;
ChartButton: TButton;
StopButton: TButton;
TreeView1: TTreeView;
Splitter1: TSplitter;
procedure RandomButtonClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure LoadButtonClick(Sender: TObject);
procedure ChartButtonClick(Sender: TObject);
procedure StopButtonClick(Sender: TObject);
procedure LayoutResized(Sender: TObject);
private
const
cnt = 20;
@@ -70,6 +75,8 @@ type
FRandom: TList<TRndItem>;
FTerminate: TEvent;
FLoadDone: TState;
function SelectedSymbol: String;
function SelectedStream: IDataStream<TAskBidItem>;
public
{ Public declarations }
published
@@ -102,7 +109,7 @@ begin
FSymbols := FServer.EnumerateSymbols;
SymbolsComboBox.AddIdleHandler(
SymbolsComboBox.ProcessSignal(
FSymbols.Done.Signal,
procedure
begin
@@ -130,10 +137,14 @@ begin
FSymbols.WaitFor;
FTerminate.Notify;
TaskManager.WaitFor(FLoadDone);
Application.OnIdle := nil;
FRandom.Free;
end;
procedure TForm1.LayoutResized(Sender: TObject);
begin
LogMemo.Lines.Add('resize');
end;
procedure TForm1.LoadButtonClick(Sender: TObject);
begin
if SymbolsComboBox.ItemIndex < 0 then
@@ -142,7 +153,11 @@ begin
var Stream := FServer.CreateStream(FSymbols.WaitFor[SymbolsComboBox.ItemIndex]);
var Data := TDataStreamProvider.Create<TAskBidItem>(30000, 10000, Stream);
Path1.AddIdleHandler(
var path := TPath.Create(Self);
path.Parent := Layout;
path.Align := TAlignLayout.None;
path.ProcessSignal(
Data.Changed,
procedure
begin
@@ -150,14 +165,14 @@ begin
if Prices.Count > 0 then
begin
Path1.BeginUpdate;
path.BeginUpdate;
try
Path1.Data.Clear;
Path1.Data.MoveTo(PointF(Path1.Width - 1, Prices[0].Data.Ask));
path.Data.Clear;
path.Data.MoveTo(PointF(path.Width - 1, Prices[0].Data.Ask));
for var i := 1 to Prices.Count - 1 do
Path1.Data.LineTo(PointF(Path1.Width - i - 1, Prices[i].Data.Ask));
path.Data.LineTo(PointF(path.Width - i - 1, Prices[i].Data.Ask));
finally
Path1.EndUpdate;
path.EndUpdate;
end;
end;
end
@@ -168,12 +183,11 @@ procedure TForm1.RandomButtonClick(Sender: TObject);
begin
var rnd: TRndItem;
var ass := FSymbols.WaitFor;
rnd.Stream := FServer.CreateStream(ass[Random(Length(FSymbols.WaitFor))]);
rnd.Stream := FServer.CreateStream(FSymbols.WaitFor[Random(Length(FSymbols.WaitFor))]);
rnd.Data := TDataStreamProvider.Create<TAskBidItem>(3000, 1000, rnd.Stream);
rnd.Labl := TLabel.Create(Self);
rnd.Labl.Parent := FlowLayout;
rnd.Labl.Parent := Layout;
rnd.Labl.Align := TAlignLayout.None;
rnd.Labl.WordWrap := false;
rnd.Labl.Width := 300;
@@ -185,7 +199,7 @@ begin
begin
FRandom[idx]
.Labl
.AddIdleHandler(
.ProcessSignal(
FRandom[idx].Data.Changed,
procedure
begin
@@ -209,15 +223,14 @@ end;
procedure TForm1.ChartButtonClick(Sender: TObject);
begin
if SymbolsComboBox.ItemIndex < 0 then
var Symbol := SelectedSymbol;
if Symbol = '' then
exit;
var Symbol := FSymbols.WaitFor[SymbolsComboBox.ItemIndex];
var currPathData := TWriteable<IObjectRef<TPathData>>.CreateWriteable.Protect;
var currLog := TWriteable<String>.CreateWriteable.Protect;
var currPathData := TMutable<IObjectRef<TPathData>>.CreateWriteable.Protect;
var currLog := TMutable<String>.CreateWriteable.Protect;
const width = 3000;
const width = 300;
var done :=
TaskManager.RunTask(
@@ -255,18 +268,36 @@ begin
FLoadDone := TState.All([FLoadDone, done]);
LogMemo.AddIdleHandler(currLog.Changed, procedure begin LogMemo.Lines.Add(Symbol + ': ' + currLog.Value); end);
var path := TPath.Create(Self);
path.Parent := Layout;
path.Align := TAlignLayout.None;
Path1.AddIdleHandler(
path.ProcessSignal(
currPathData.Changed,
procedure
procedure(out IsDone: Boolean)
begin
if currPathData.Value <> nil then
begin
Path1.Data.Assign(currPathData.Value.Obj);
end;
path.Data.Assign(currPathData.Value.Obj);
IsDone := done.IsSet;
end
);
end;
function TForm1.SelectedStream: IDataStream<TAskBidItem>;
begin
var sym := SelectedSymbol;
if sym = '' then
exit(nil);
Result := FServer.CreateStream(sym);
end;
function TForm1.SelectedSymbol: String;
begin
Result := '';
if RandomBox.IsChecked then
Result := FSymbols.WaitFor[Random(Length(FSymbols.WaitFor))]
else if SymbolsComboBox.ItemIndex >= 0 then
Result := FSymbols.WaitFor[SymbolsComboBox.ItemIndex];
end;
end.