ProtectedMutable
This commit is contained in:
+33
-55
@@ -45,8 +45,8 @@ type
|
||||
SymbolsComboBox: TComboBox;
|
||||
LoadButton: TButton;
|
||||
FlowLayout: TFlowLayout;
|
||||
ChartButton: TButton;
|
||||
StopButton: TButton;
|
||||
ChartButton: TButton;
|
||||
StopButton: TButton;
|
||||
procedure RandomButtonClick(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormDestroy(Sender: TObject);
|
||||
@@ -214,36 +214,41 @@ begin
|
||||
|
||||
var Symbol := FSymbols.WaitFor[SymbolsComboBox.ItemIndex];
|
||||
|
||||
var currPathData := TMutable<IObjectRef<TPathData>>.CreateProtected;
|
||||
var currLog := TMutable<String>.CreateProtected;
|
||||
var currPathData := TMutable<IObjectRef<TPathData>>.CreateWriteable.Protect;
|
||||
var currLog := TMutable<String>.CreateWriteable.Protect;
|
||||
|
||||
const width = 1000;
|
||||
const incsize = 100;
|
||||
begin
|
||||
var arr := TDataSeries<TAskBidItem>.CreateWriteable(width);
|
||||
var done :=
|
||||
FServer.ProcessData(
|
||||
Symbol,
|
||||
FTerminate.Signal,
|
||||
procedure(const Values: TArray<TDataPoint<TAskBidItem>>; const Terminated: TState)
|
||||
begin
|
||||
arr.Add(Values);
|
||||
currLog.Value := arr.TotalCount.ToString;
|
||||
|
||||
var PathData := TPathData.Create;
|
||||
var Prices := arr;
|
||||
if Prices.Count > 0 then
|
||||
TaskManager.RunTask(
|
||||
nil,
|
||||
procedure
|
||||
begin
|
||||
var arr := TDataSeries<TAskBidItem>.CreateWriteable(width);
|
||||
var done :=
|
||||
FServer.ProcessData(
|
||||
Symbol,
|
||||
FTerminate.Signal,
|
||||
procedure(const Values: TArray<TDataPoint<TAskBidItem>>; const Terminated: TState)
|
||||
begin
|
||||
PathData.MoveTo(PointF(Prices.Count - 1, Prices[0].Data.Ask));
|
||||
for var i := 1 to Prices.Count - 1 do
|
||||
PathData.LineTo(PointF(Prices.Count - i - 1, Prices[i].Data.Ask));
|
||||
end;
|
||||
arr.Add(Values);
|
||||
currLog.Value := arr.TotalCount.ToString;
|
||||
|
||||
currPathData.Value := TObjectRef<TPathData>.Create(PathData);
|
||||
end
|
||||
);
|
||||
FLoadDone := TState.All([FLoadDone, done]);
|
||||
end;
|
||||
var PathData := TPathData.Create;
|
||||
var Prices := arr;
|
||||
if Prices.Count > 0 then
|
||||
begin
|
||||
PathData.MoveTo(PointF(Prices.Count - 1, Prices[0].Data.Ask));
|
||||
for var i := 1 to Prices.Count - 1 do
|
||||
PathData.LineTo(PointF(Prices.Count - i - 1, Prices[i].Data.Ask));
|
||||
end;
|
||||
|
||||
currPathData.Value := TObjectRef<TPathData>.Create(PathData);
|
||||
end
|
||||
);
|
||||
FLoadDone := TState.All([FLoadDone, done]);
|
||||
end
|
||||
);
|
||||
|
||||
LogMemo.AddIdleHandler(currLog.Changed, procedure begin LogMemo.Lines.Add(Symbol + ': ' + currLog.Value); end);
|
||||
|
||||
@@ -251,39 +256,12 @@ begin
|
||||
currPathData.Changed,
|
||||
procedure
|
||||
begin
|
||||
if currPathData.Value<>nil then
|
||||
if currPathData.Value <> nil then
|
||||
begin
|
||||
Path1.Data.Assign( currPathData.Value.Obj );
|
||||
end;
|
||||
end );
|
||||
|
||||
|
||||
(*
|
||||
FLoadDone := TState.All([FLoadDone, done]);
|
||||
|
||||
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
|
||||
begin
|
||||
Path1.Data.LineTo(PointF(Path1.Width - i - 1, Prices[i].Data.Ask));
|
||||
end;
|
||||
finally
|
||||
Path1.EndUpdate;
|
||||
end;
|
||||
Path1.Data.Assign(currPathData.Value.Obj);
|
||||
end;
|
||||
end
|
||||
);
|
||||
*)
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
Reference in New Issue
Block a user