implementing DataStream

This commit is contained in:
Michael Schimmel
2025-06-07 23:54:10 +02:00
parent d53742fd12
commit c4152d25cd
2 changed files with 174 additions and 69 deletions
+11 -13
View File
@@ -68,7 +68,7 @@ type
procedure PaintBoxMouseLeave(Sender: TObject);
procedure SymbolComboBoxChange(Sender: TObject); // Event handler for symbol selection change
private
FDataServer: IDataServer<TAskBidItem>;
FDataServer: IAuraDataServer<TAskBidItem>;
FActiveOHLCCache: TOHLC;
FCandleWidthInPixels: Integer;
FCandleSpacing: Integer;
@@ -87,7 +87,7 @@ type
FSymbolFiles: TArray<string>; // Stores full paths from FindOldestFilesPerSymbol
procedure PopulateTimeframeComboBox;
procedure PopulateSymbolComboBox;
procedure SetupDataServer;
procedure EnsureCacheForCurrentTimeframe(ARebuildIfPresent: Boolean = False);
procedure ClearAllCachesInForm;
procedure DrawChart(ACanvas: TCanvas; ARect: TRect);
@@ -260,8 +260,6 @@ var
BuilderNCaptionKey, BuilderVCaptionKey: string; // These will be the unique keys
BuilderNDescription, BuilderVDescription: string;
begin
FDataServer := TAskBidServer.Create;
IsMemoryLow :=
function: Boolean
var
@@ -280,6 +278,9 @@ begin
end;
end;
// Assuming we have a valid default value in the Path-Edit:
SetupDataServer;
FCandleWidthInPixels := InitialCandleWidth;
FCandleSpacing := InitialCandleSpacing;
FDisplayStartIndex := 0;
@@ -323,10 +324,6 @@ begin
FMouseCurrentlyInChartArea := False;
PaintBox.OnMouseLeave := PaintBoxMouseLeave;
FBufferBitmap := TBitmap.Create;
SetLength(FSymbolFiles, 0); // Initialize FSymbolFiles array
// Assuming we have a valid default value in the Path-Edit:
PopulateSymbolComboBox;
end;
procedure TChartForm.FormDestroy(Sender: TObject);
@@ -597,7 +594,7 @@ begin
begin
DataPathEdit.Text := selectedDirectory; // Update the edit box with the selected directory
Memo.Lines.Add(FormatDateTime('yyyy-mm-dd hh:nn:ss', Now) + ' - Data directory selected: ' + selectedDirectory);
PopulateSymbolComboBox;
SetupDataServer;
end
else
begin
@@ -1475,16 +1472,18 @@ begin
Memo.Lines.Add('GoToCurrent: Already showing the latest candles.');
end;
procedure TChartForm.PopulateSymbolComboBox;
procedure TChartForm.SetupDataServer;
var
fileName: string;
pathValue, symbolValue: string;
yearValue, monthValue: Integer;
i: Integer;
begin
FDataServer := TAuraTABFileServer.Create( DataPathEdit.Text );
var currTxt := SymbolComboBox.Text;
FSymbolFiles := FindOldestFilesPerSymbol(DataPathEdit.Text); // Find all relevant symbol files [cite: 238]
FSymbolFiles := FDataServer.EnumerateAssetFiles;
SymbolComboBox.Items.Clear;
SymbolComboBox.ClearSelection; // Ensure no previous selection remains
SymbolComboBox.Text := '';
@@ -1502,8 +1501,7 @@ begin
for i := Low(FSymbolFiles) to High(FSymbolFiles) do
begin
fileName := FSymbolFiles[i];
// TryParseFileName extracts symbol from the filename. [cite: 237]
if TryParseFileName(fileName, pathValue, symbolValue, yearValue, monthValue) then
if TAuraTABFileServer.TryParseFileName(fileName, pathValue, symbolValue, yearValue, monthValue) then
begin
SymbolComboBox.Items.AddObject(
Format('%s %.2d-%.4d', [symbolValue, monthValue, yearValue]),