Purge Input drain now has wait time

This commit is contained in:
mysticbbs 2013-02-24 23:28:11 -05:00
parent acb6449d46
commit 228f4b446a
1 changed files with 12 additions and 4 deletions

View File

@ -16,10 +16,11 @@ Type
FInBufEnd : LongInt;
FOutBuf : TIOBuffer;
FOutBufPos : LongInt;
Connected : Boolean;
Constructor Create; Virtual;
Destructor Destroy; Override;
Procedure PurgeInputData (Drain: Boolean);
Procedure PurgeInputData (DrainWait: LongInt);
Procedure PurgeOutputData;
Function DataWaiting : Boolean; Virtual;
Function WriteBuf (Var Buf; Len: LongInt) : LongInt; Virtual;
@ -37,6 +38,9 @@ Type
Implementation
Uses
m_DateTime;
Constructor TIOBase.Create;
Begin
Inherited Create;
@ -44,6 +48,7 @@ Begin
FInBufPos := 0;
FInBufEnd := 0;
FOutBufPos := 0;
Connected := True;
End;
Destructor TIOBase.Destroy;
@ -56,18 +61,21 @@ Begin
FOutBufPos := 0;
End;
Procedure TIOBase.PurgeInputData (Drain: Boolean);
Procedure TIOBase.PurgeInputData (DrainWait: LongInt);
Var
Buf : Array[1..2048] of Char;
Begin
FInBufPos := 0;
FInBufEnd := 0;
If Drain Then
While DataWaiting Do Begin
If DrainWait > 0 Then Begin
DrainWait := TimerSet(DrainWait);
While DataWaiting And Not TimerUp(DrainWait) Do Begin
ReadBuf(Buf, SizeOf(Buf));
If FInBufEnd <= 0 Then Break;
End;
End;
End;
Function TIOBase.DataWaiting : Boolean;