procedure DoReadBytes(Buffer: Pointer = Nil; SPS: Integer = 1; Size: Integer = 1024);
procedure DoWriteBytes(Buffer: Pointer = Nil; SPS: Integer = 1);
//Read the PLC-data into the buffer.
//~param Area Requested PLC-area.
//~param DB Number of requested datablock. Only used, if reading from Datablocks in the PLC.
//~param Start Start-address of the requested data within the address-range of the PLC.
//~param Size Length of the requested PLC-data in bytes.
//~param Buffer Pointer to the buffer. The internal buffer of the instance is used, if Nil (default).
procedure TNoDave.DoReadBytes(Area: TNoDaveArea; DB, Start, Size: Integer; Buffer: Pointer);
var
Index, Length, MaxLen: Integer;
StartTime: Cardinal;
begin
Index:=0;
StartTime:=GetTickCount;
MaxLen:=MaxPDUData;
While (Index < Size) and (MaxLen > 0) do
begin
Length:=(Size - Index);
If Length > MaxLen then Length:=MaxLen;
try
LockNoDave.Enter;
FLastError:=daveReadBytes(DaveConn, AreaCode(Area), DB, Index+Start, Size, Pointer(Integer(Buffer) + Index));
except
On E: Exception do DoOnError('Error in function TNoDave.DoReadBytes: ' + E.Message);
end;
LockNoDave.Leave;
Inc(Index, Length);
end;
try
FCycleTime:=GetTickCount - StartTime;
except
end;
end;
//Write the Buffer-data into the PLC.
//~param Area Requested PLC-area.
//~param DB Number of requested datablock. Only used, if reading from Datablocks in the PLC.
//~param Start Start-address of the requested data within the address-range of the PLC.
//~param Size Length of the requested PLC-data in bytes.
//~param Buffer Pointer to the buffer. The internal buffer of the instance is used, if Nil (default).
procedure TNoDave.DoWriteBytes(Area: TNoDaveArea; DB, Start, Size: Integer; Buffer: Pointer);
var
Index, Length, MaxLen: Integer;
begin
Index:=0;
MaxLen:=MaxPDUData-4;
While (Index < Size) and (MaxLen > 0) do
begin
Length:=(Size - Index);
If Length > MaxLen then Length:=MaxLen;
try
LockNoDave.Enter;
FLastError:=daveWriteBytes(DaveConn, AreaCode(Area), DB, Index+Start, Size, Pointer(Integer(Buffer) + Index));
except
On E: Exception do DoOnError('Error in function TNoDave.DoWriteBytes: ' + E.Message);
end;
LockNoDave.Leave;
Inc(Index, Length);
end;
end;