Bugfix in TEvent, DataServer Push-Mode
This commit is contained in:
@@ -5,7 +5,8 @@ uses
|
||||
System.StartUpCopy,
|
||||
FMX.Forms,
|
||||
MainForm in 'MainForm.pas' {Form1},
|
||||
Myc.Trade.Core.DataPoint in '..\Src\Myc.Trade.Core.DataPoint.pas';
|
||||
Myc.Trade.Core.DataPoint in '..\Src\Myc.Trade.Core.DataPoint.pas',
|
||||
Myc.Trade.Ticker in '..\Src\Myc.Trade.Ticker.pas';
|
||||
|
||||
{$R *.res}
|
||||
|
||||
|
||||
@@ -134,6 +134,7 @@
|
||||
<Form>Form1</Form>
|
||||
</DCCReference>
|
||||
<DCCReference Include="..\Src\Myc.Trade.Core.DataPoint.pas"/>
|
||||
<DCCReference Include="..\Src\Myc.Trade.Ticker.pas"/>
|
||||
<BuildConfiguration Include="Base">
|
||||
<Key>Base</Key>
|
||||
</BuildConfiguration>
|
||||
@@ -177,9 +178,9 @@
|
||||
<Overwrite>true</Overwrite>
|
||||
</Platform>
|
||||
</DeployFile>
|
||||
<DeployFile LocalName="Win64\Debug\AuraTrader.rsm" Configuration="Debug" Class="DebugSymbols">
|
||||
<DeployFile LocalName="Win64\Release\AuraTrader.exe" Configuration="Release" Class="ProjectOutput">
|
||||
<Platform Name="Win64">
|
||||
<RemoteName>AuraTrader.rsm</RemoteName>
|
||||
<RemoteName>AuraTrader.exe</RemoteName>
|
||||
<Overwrite>true</Overwrite>
|
||||
</Platform>
|
||||
</DeployFile>
|
||||
|
||||
@@ -64,6 +64,22 @@ object Form1: TForm1
|
||||
JustifyLastLine = Left
|
||||
FlowDirection = LeftToRight
|
||||
end
|
||||
object Button1: TButton
|
||||
Position.X = 712.00000000000000000
|
||||
Position.Y = 72.00000000000000000
|
||||
TabOrder = 6
|
||||
Text = 'Button1'
|
||||
TextSettings.Trimming = None
|
||||
OnClick = Button1Click
|
||||
end
|
||||
object Button2: TButton
|
||||
Position.X = 720.00000000000000000
|
||||
Position.Y = 96.00000000000000000
|
||||
TabOrder = 8
|
||||
Text = 'Button2'
|
||||
TextSettings.Trimming = None
|
||||
OnClick = Button2Click
|
||||
end
|
||||
end
|
||||
object LogMemo: TMemo
|
||||
Touch.InteractiveGestures = [Pan, LongTap, DoubleTap]
|
||||
|
||||
@@ -32,6 +32,7 @@ uses
|
||||
Myc.Signals,
|
||||
Myc.Lazy,
|
||||
Myc.Signals.FMX,
|
||||
Myc.TaskManager,
|
||||
FMX.ListBox,
|
||||
FMX.Layouts;
|
||||
|
||||
@@ -44,10 +45,14 @@ type
|
||||
SymbolsComboBox: TComboBox;
|
||||
LoadButton: TButton;
|
||||
FlowLayout: TFlowLayout;
|
||||
Button1: TButton;
|
||||
Button2: TButton;
|
||||
procedure RandomButtonClick(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormDestroy(Sender: TObject);
|
||||
procedure LoadButtonClick(Sender: TObject);
|
||||
procedure Button1Click(Sender: TObject);
|
||||
procedure Button2Click(Sender: TObject);
|
||||
private
|
||||
const
|
||||
cnt = 20;
|
||||
@@ -63,6 +68,8 @@ type
|
||||
FServer: IDataServer<TAskBidItem>;
|
||||
FSymbols: TFuture<TArray<String>>;
|
||||
FRandom: TList<TRndItem>;
|
||||
FTerminate: TEvent;
|
||||
FLoadDone: TState;
|
||||
public
|
||||
{ Public declarations }
|
||||
published
|
||||
@@ -76,8 +83,61 @@ implementation
|
||||
|
||||
{$R *.fmx}
|
||||
|
||||
procedure TForm1.Button1Click(Sender: TObject);
|
||||
begin
|
||||
if SymbolsComboBox.ItemIndex < 0 then
|
||||
exit;
|
||||
|
||||
var arr := TDataSeries<TAskBidItem>.CreateArray(3000);
|
||||
var curr := TMutable<TDataSeries<TAskBidItem>>.CreateProtected;
|
||||
var Symbol := FSymbols.WaitFor[SymbolsComboBox.ItemIndex];
|
||||
|
||||
var done :=
|
||||
TAuraFileLoader<TAskBidItem>.LoadData(
|
||||
FServer as TAuraTABFileServer,
|
||||
Symbol,
|
||||
FTerminate.Signal,
|
||||
procedure(const Values: TArray<TDataPoint<TAskBidItem>>)
|
||||
begin
|
||||
arr.Add(Values);
|
||||
curr.Value := arr.Copy;
|
||||
end
|
||||
);
|
||||
|
||||
FLoadDone := TState.All([FLoadDone, done]);
|
||||
|
||||
LogMemo.AddIdleHandler(curr.Changed, procedure begin LogMemo.Lines.Add(Symbol + ': ' + curr.Value.TotalCount.ToString); end);
|
||||
|
||||
Path1.AddIdleHandler(
|
||||
curr.Changed,
|
||||
procedure
|
||||
begin
|
||||
var Prices := curr.Value;
|
||||
|
||||
if Prices.Count > 0 then
|
||||
begin
|
||||
Path1.BeginUpdate;
|
||||
try
|
||||
Path1.Data.Clear;
|
||||
Path1.Data.MoveTo(PointF(Path1.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));
|
||||
finally
|
||||
Path1.EndUpdate;
|
||||
end;
|
||||
end;
|
||||
end
|
||||
);
|
||||
end;
|
||||
|
||||
procedure TForm1.Button2Click(Sender: TObject);
|
||||
begin
|
||||
FTerminate.Notify;
|
||||
end;
|
||||
|
||||
procedure TForm1.FormCreate(Sender: TObject);
|
||||
begin
|
||||
FTerminate := TEvent.CreateEvent;
|
||||
FRandom := TList<TRndItem>.Create;
|
||||
|
||||
// Create an instance of the TAuraTABFileServer. The server can be reused for multiple stream creations. [364]
|
||||
@@ -110,6 +170,8 @@ end;
|
||||
|
||||
procedure TForm1.FormDestroy(Sender: TObject);
|
||||
begin
|
||||
FTerminate.Notify;
|
||||
TaskManager.WaitFor(FLoadDone);
|
||||
Application.OnIdle := nil;
|
||||
FRandom.Free;
|
||||
end;
|
||||
|
||||
Reference in New Issue
Block a user