W
wl_5545831
Unregistered / Unconfirmed
GUEST, unregistred user!
代码:
procedure TForm_Main.Timer1Timer(Sender: TObject);
var
FileName,DirectoryName,Tag:String;
Tof:TFileStream;
BufferTime:array[0..7] of string;
i:integer;
begin
Tag:=UpperCase(Grid_Setting.Cells[2,1]);
NodaveList[1].ReadBytes(@Buffer1);
for i := 0 to 7do
BufferTime:=IntToHex(Buffer1,2);
DirectoryName:=ExtractFilePath(Application.ExeName)+BufferTime[6]+'_'+BufferTime[5]+'_'+BufferTime[4];
if DirectoryExists(DirectoryName)<>true then
CreateDir(DirectoryName);
FileName:=DirectoryName+'/'+Tag+'_'+BufferTime[3]+'.dat';
if FileExists(FileName)<>true then
Tof:=TFileStream.Create(FileName,fmCreate or fmShareDenyNone)
else
Tof:=TFileStream.Create(FileName,fmOpenReadWrite or fmShareDenyNone);
Tof.Seek(0,soFromEnd);
Tof.WriteBuffer(Buffer1,462);
Tof.Free;
end;
上面的代码是定时从设备中读取一个512长度的字节,现在的问题是采用定时器的话,时间间隔不能设置的太短,我们这里有个老外,他好像是同时从三个端口读取数据,然后写入到一个文件中,从我的方法上来说,每次读取512字节,如果100MS读取一次的话,一天的数据会达到上G,而他不知道采用什么方法,数据量非常的小,如何能够做到呢?可能我描述的不够清晰,希望大家给予解答
procedure TForm_Main.Timer1Timer(Sender: TObject);
var
FileName,DirectoryName,Tag:String;
Tof:TFileStream;
BufferTime:array[0..7] of string;
i:integer;
begin
Tag:=UpperCase(Grid_Setting.Cells[2,1]);
NodaveList[1].ReadBytes(@Buffer1);
for i := 0 to 7do
BufferTime:=IntToHex(Buffer1,2);
DirectoryName:=ExtractFilePath(Application.ExeName)+BufferTime[6]+'_'+BufferTime[5]+'_'+BufferTime[4];
if DirectoryExists(DirectoryName)<>true then
CreateDir(DirectoryName);
FileName:=DirectoryName+'/'+Tag+'_'+BufferTime[3]+'.dat';
if FileExists(FileName)<>true then
Tof:=TFileStream.Create(FileName,fmCreate or fmShareDenyNone)
else
Tof:=TFileStream.Create(FileName,fmOpenReadWrite or fmShareDenyNone);
Tof.Seek(0,soFromEnd);
Tof.WriteBuffer(Buffer1,462);
Tof.Free;
end;
上面的代码是定时从设备中读取一个512长度的字节,现在的问题是采用定时器的话,时间间隔不能设置的太短,我们这里有个老外,他好像是同时从三个端口读取数据,然后写入到一个文件中,从我的方法上来说,每次读取512字节,如果100MS读取一次的话,一天的数据会达到上G,而他不知道采用什么方法,数据量非常的小,如何能够做到呢?可能我描述的不够清晰,希望大家给予解答