Changeset 407 for PinConnection/UCommDelay.pas
- Timestamp:
- Aug 14, 2012, 10:31:30 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
PinConnection/UCommDelay.pas
r302 r407 6 6 7 7 uses 8 Classes, SysUtils, UCommPin, UThreading, SyncObjs, SpecializedList, UStreamHelper; 8 Classes, SysUtils, UCommPin, UThreading, SyncObjs, SpecializedList, UStreamHelper, 9 UBinarySerializer; 9 10 10 11 type … … 15 16 TDelayedPacket = class 16 17 ReceiveTime: TDateTime; 17 Data: T StreamHelper;18 Data: TListByte; 18 19 constructor Create; 19 20 destructor Destroy; override; … … 40 41 Thread1: TCommDelayThread; 41 42 Thread2: TCommDelayThread; 42 procedure ReceiveData1(Sender: TCommPin; AStream: T Stream);43 procedure ReceiveData2(Sender: TCommPin; AStream: T Stream);43 procedure ReceiveData1(Sender: TCommPin; AStream: TListByte); 44 procedure ReceiveData2(Sender: TCommPin; AStream: TListByte); 44 45 procedure SetActive(AValue: Boolean); 45 46 public … … 62 63 I: Integer; 63 64 CurrentTime: TDateTime; 64 SendData: T StreamHelper;65 SendData: TListByte; 65 66 DoSleep: Boolean; 66 67 begin 67 68 try 68 SendData := T StreamHelper.Create;69 SendData := TListByte.Create; 69 70 repeat 70 71 DoSleep := True; … … 76 77 if TDelayedPacket(PacketQueue[I]).ReceiveTime < (CurrentTime - Parent.Delay) then begin 77 78 DoSleep := False; 78 SendData.Clear; 79 SendData.WriteStream(TDelayedPacket(PacketQueue[I]).Data, TDelayedPacket(PacketQueue[I]).Data.Size); 79 SendData.Assign(TDelayedPacket(PacketQueue[I]).Data); 80 80 PacketQueue.Delete(I); 81 81 try 82 82 Lock.Release; 83 Pin.Send(SendData .Stream);83 Pin.Send(SendData); 84 84 finally 85 85 Lock.Acquire; … … 100 100 constructor TDelayedPacket.Create; 101 101 begin 102 Data := T StreamHelper.Create;102 Data := TListByte.Create; 103 103 end; 104 104 … … 111 111 { TCommDelay } 112 112 113 procedure TCommDelay.ReceiveData1(Sender: TCommPin; AStream: T Stream);113 procedure TCommDelay.ReceiveData1(Sender: TCommPin; AStream: TListByte); 114 114 begin 115 115 try … … 119 119 with TDelayedPacket(PacketQueue2.AddNew(TDelayedPacket.Create)) do begin 120 120 ReceiveTime := Now; 121 Data. WriteStream(AStream, AStream.Size);121 Data.Assign(AStream); 122 122 end; 123 123 finally … … 126 126 end; 127 127 128 procedure TCommDelay.ReceiveData2(Sender: TCommPin; AStream: T Stream);128 procedure TCommDelay.ReceiveData2(Sender: TCommPin; AStream: TListByte); 129 129 begin 130 130 try … … 134 134 with TDelayedPacket(PacketQueue1.AddNew(TDelayedPacket.Create)) do begin 135 135 ReceiveTime := Now; 136 Data. WriteStream(AStream, AStream.Size);136 Data.Assign(AStream); 137 137 end; 138 138 finally
Note:
See TracChangeset
for help on using the changeset viewer.