Changeset 407 for PinConnection/UCommThread.pas
- Timestamp:
- Aug 14, 2012, 10:31:30 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
PinConnection/UCommThread.pas
r384 r407 7 7 uses 8 8 Classes, SysUtils, blcksock, UCommPin, SyncObjs, UStreamHelper, UCommon, 9 DateUtils, UThreading ;9 DateUtils, UThreading, SpecializedList, UBinarySerializer; 10 10 11 11 type … … 19 19 public 20 20 Parent: TCommThread; 21 Stream: T StreamHelper;21 Stream: TBinarySerializer; 22 22 procedure Execute; override; 23 23 constructor Create(CreateSuspended: Boolean; … … 33 33 FOnReceiveData: TReceiveDataEvent; 34 34 FReceiveThread: TCommThreadReceiveThread; 35 FInputBuffer: T MemoryStream;35 FInputBuffer: TBinarySerializer; 36 36 FInputBufferLock: TCriticalSection; 37 37 FDataAvailable: TEvent; 38 38 FStatusEvent: TEvent; 39 39 FStatusValue: Integer; 40 procedure PinReceiveData(Sender: TCommPin; Stream: T Stream);40 procedure PinReceiveData(Sender: TCommPin; Stream: TListByte); 41 41 procedure PinSetStatus(Sender: TCommPin; Status: Integer); 42 procedure ExtReceiveData(Sender: TCommPin; Stream: T Stream);42 procedure ExtReceiveData(Sender: TCommPin; Stream: TListByte); 43 43 procedure ExtSetStatus(Sender: TCommPin; AStatus: Integer); 44 44 procedure SetActive(const AValue: Boolean); … … 55 55 { TCommThread } 56 56 57 procedure TCommThread.PinReceiveData(Sender: TCommPin; Stream: TStream);57 procedure TCommThread.PinReceiveData(Sender: TCommPin; Stream: TListByte); 58 58 begin 59 59 if FActive then Ext.Send(Stream); … … 65 65 end; 66 66 67 procedure TCommThread.ExtReceiveData(Sender: TCommPin; Stream: TStream); 68 var 69 StreamHelper: TStreamHelper; 67 procedure TCommThread.ExtReceiveData(Sender: TCommPin; Stream: TListByte); 70 68 begin 71 69 try 72 StreamHelper := TStreamHelper.Create(FInputBuffer);73 70 FInputBufferLock.Acquire; 74 StreamHelper.WriteStream(Stream, Stream.Size);71 FInputBuffer.WriteList(Stream, 0, Stream.Count); 75 72 FDataAvailable.SetEvent; 76 73 finally 77 74 FInputBufferLock.Release; 78 StreamHelper.Free;79 75 end; 80 76 end; … … 110 106 begin 111 107 inherited Create; 112 FInputBuffer := TMemoryStream.Create; 108 FInputBuffer := TBinarySerializer.Create; 109 FInputBuffer.List := TListByte.Create; 110 FInputBuffer.OwnsList := True; 113 111 FInputBufferLock := TCriticalSection.Create; 114 112 Ext := TCommPin.Create; … … 150 148 try 151 149 FInputBufferLock.Acquire; 152 Stream.Size := 0; 153 Stream.WriteStream(FInputBuffer, FInputBuffer.Size); 150 Stream.List.Assign(FInputBuffer.List); 154 151 FDataAvailable.ResetEvent; 155 152 FInputBuffer.Clear; … … 157 154 FInputBufferLock.Release; 158 155 end; // else Yield; 159 Pin.Send(Stream );156 Pin.Send(Stream.List); 160 157 end; 161 158 … … 182 179 begin 183 180 inherited; 184 Stream := TStreamHelper.Create; 181 Stream := TBinarySerializer.Create; 182 Stream.List := TListByte.Create; 183 Stream.OwnsList := True; 185 184 end; 186 185
Note:
See TracChangeset
for help on using the changeset viewer.