Changeset 407 for PinConnection/UPacketBurst.pas
- Timestamp:
- Aug 14, 2012, 10:31:30 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
PinConnection/UPacketBurst.pas
r231 r407 6 6 7 7 uses 8 Classes, UCommPin, SyncObjs, UStreamHelper, UCommon, SysUtils, 9 DateUtils ;8 Classes, UCommPin, SyncObjs, UStreamHelper, UCommon, SysUtils, SpecializedList, 9 DateUtils, UBinarySerializer; 10 10 11 11 type … … 25 25 SendThread: TPacketBurstSendThread; 26 26 SendStreamLock: TCriticalSection; 27 SendStream: T StreamHelper;28 ReceiveStream: T StreamHelper;29 procedure PacketSingleReceive(Sender: TCommPin; Stream: T Stream);30 procedure PacketBurstReceive(Sender: TCommPin; Stream: T Stream);27 SendStream: TBinarySerializer; 28 ReceiveStream: TBinarySerializer; 29 procedure PacketSingleReceive(Sender: TCommPin; Stream: TListByte); 30 procedure PacketBurstReceive(Sender: TCommPin; Stream: TListByte); 31 31 procedure SetActive(const AValue: Boolean); 32 32 public … … 63 63 end; 64 64 65 procedure TPacketBurst.PacketBurstReceive(Sender: TCommPin; Stream: T Stream);65 procedure TPacketBurst.PacketBurstReceive(Sender: TCommPin; Stream: TListByte); 66 66 var 67 PacketStream: T StreamHelper;67 PacketStream: TListByte; 68 68 Size: Word; 69 69 begin 70 70 try 71 PacketStream := T StreamHelper.Create;72 ReceiveStream. Seek(0, soFromEnd);73 ReceiveStream.Write Stream(Stream, Stream.Size);71 PacketStream := TListByte.Create; 72 ReceiveStream.Position := ReceiveStream.List.Count; 73 ReceiveStream.WriteList(Stream, 0, Stream.Count); 74 74 ReceiveStream.Position := 0; 75 75 Size := ReceiveStream.ReadWord; 76 while Size < ReceiveStream. Sizedo begin77 PacketStream. Stream.Size := 0;78 PacketStream.ReadStream(TStream(ReceiveStream), Size);76 while Size < ReceiveStream.List.Count do begin 77 PacketStream.Count := Size; 78 ReceiveStream.ReadList(PacketStream, 0, Size); 79 79 PacketSinglePin.Send(PacketStream); 80 80 Size := ReceiveStream.ReadWord; … … 100 100 end; 101 101 102 procedure TPacketBurst.PacketSingleReceive(Sender: TCommPin; Stream: T Stream);102 procedure TPacketBurst.PacketSingleReceive(Sender: TCommPin; Stream: TListByte); 103 103 var 104 104 SignalEvent: Boolean; … … 106 106 try 107 107 SendStreamLock.Acquire; 108 SendStream.WriteWord(Stream.Size); 109 Stream.Position := 0; 110 SendStream.WriteStream(Stream, Stream.Size); 111 SignalEvent := SendStream.Size > SendBurstSize; 108 SendStream.WriteWord(Stream.Count); 109 SendStream.WriteList(Stream, 0, Stream.Count); 110 SignalEvent := SendStream.List.Count > SendBurstSize; 112 111 finally 113 112 SendStreamLock.Release; … … 120 119 procedure TPacketBurstSendThread.Execute; 121 120 var 122 Stream: T StreamHelper;121 Stream: TListByte; 123 122 begin 124 123 try 125 Stream := T StreamHelper.Create;124 Stream := TListByte.Create; 126 125 with PacketBurst do 127 126 repeat … … 130 129 SendStreamLock.Acquire; 131 130 SendStream.Position := 0; 132 if SendStream. Size< SendBurstSize then begin133 PacketBurstPin.Send(SendStream );134 SendStream. Stream.Size:= 0;131 if SendStream.List.Count < SendBurstSize then begin 132 PacketBurstPin.Send(SendStream.List); 133 SendStream.List.Count := 0; 135 134 end else 136 while (SendStream. Size- SendStream.Position) > SendBurstSize do begin137 Stream. Stream.Size:= 0;135 while (SendStream.List.Count - SendStream.Position) > SendBurstSize do begin 136 Stream.Count := 0; 138 137 SendStream.ReadStream(TStream(Stream), SendBurstSize); 139 138 PacketBurstPin.Send(Stream);
Note:
See TracChangeset
for help on using the changeset viewer.