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