constructor TDevValue.Create(aRow:
string; aFS: TFormatSettings);
var
myRow: TStringList;
begin
inherited Create;
Self.Init;
if aRow.Length > 20
then
begin
myRow := TStringList.Create;
try
myRow.Delimiter := '
;';
myRow.StrictDelimiter := True;
myRow.DelimitedText := aRow;
fTimeOffset := StrToFloatDef(myRow[keyTimeOffset], 0, aFS);
fQUALITY1 := myRow[keyQUALITY1];
fQUALITY2 := myRow[keyQUALITY2];
fQUALITY3 := myRow[keyQUALITY3];
fMQUALITY := myRow[keyMQUALITY];
fTime := UnixToDateTime(Floor(StrToFloatDef(myRow[keyTime], 0, aFS)), False);
fMOVEMENT := myRow[keyMOVEMENT] = '
1';
finally
myRow.Free;
end;
end;
end;
destructor TDevValue.Destroy;
begin
// Der vermutlich klägliche Versuch UniCodeString Memoryleaks zu beseitigen
fQUALITY1 := '
';
fQUALITY2 := '
';
fQUALITY3 := '
';
fMQUALITY := '
';
inherited;
end;
procedure TDevValue.Init;
begin
fTimeOffset := -1;
fQUALITY1 := '
';
fQUALITY2 := '
';
fQUALITY3 := '
';
fMQUALITY := '
';
fTime := NaN;
fMOVEMENT := False;
end;
/////// Jetzt die Liste //////
function TValueList.Add(aRow:
string): Integer;
var
found : Boolean;
i : Integer;
myDevValue: TDevValue;
begin
found := False;
i := 0;
myDevValue := TDevValue.Create(aRow, fs);
if fDevValueList.Count > 0
then
begin
repeat
if myDevValue.TimeOffset = fDevValueList[i].TimeOffset
then
found := True
else
Inc(i);
until found
or (i > fDevValueList.Count - 1);
end;
if not found
then
begin
Result := fDevValueList.Add(myDevValue);
if myDevValue.TimeOffset > fLastTimeStamp
then
fLastTimeStamp := myDevValue.TimeOffset;
end
else
begin // Was ich nich brauche, kann gleich wieder weg
myDevValue.Free;
Result := i;
end;
end;
constructor TValueList.Create;
begin
fDevValueList := TList<TDevValue>.Create;
// Die csv-Datei liefert numerische Werte mit Punkt als Dezimaltrenner
fs := TFormatSettings.Create;
fs.DecimalSeparator := '
.';
fLastTimeStamp := 0;
end;
destructor TValueList.Destroy;
begin
// Was ist hier zu tun, um wirklich die einzelnen Listenelemente freizugeben?
fDevValueList.DeleteRange(0, fDevValueList.Count - 1);
fDevValueList.Free;
inherited;
end;
function TValueList.Get(aIndex: Integer): TDevValue;
begin
if (aIndex >= 0)
and (aIndex < fDevValueList.Count)
then
Result := fDevValueList[aIndex]
else
Result :=
nil;
end;
function TValueList.GetItemCount: Integer;
begin
Result := fDevValueList.Count;
end;