Changeset 171 for PinConnection
- Timestamp:
- Feb 21, 2011, 2:02:53 PM (14 years ago)
- Location:
- PinConnection
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
PinConnection/UCommProtocol.pas
r163 r171 46 46 47 47 TDeviceProtocolSessionList = class(TListObject) 48 private 49 function GetSequenceNumber: Integer; 50 public 48 51 SequenceNumber: integer; 49 52 Parent: TCommProtocol; … … 54 57 constructor Create; 55 58 destructor Destroy; override; 56 function GetSequenceNumber: Integer;57 59 end; 58 60 … … 124 126 TempStream: TMemoryStream; 125 127 begin 126 TempStream := TMemoryStream.Create; 127 Request := TVarBlockIndexed.Create; 128 Request.Enclose := False; 129 with Request do try 128 try 129 TempStream := TMemoryStream.Create; 130 Request := TVarBlockIndexed.Create; 131 Request.Enclose := False; 132 with Request do 130 133 try 131 134 ReadFromStream(Stream); … … 174 177 finally 175 178 TempStream.Free; 176 Free;179 Request.Free; 177 180 end; 178 181 end; … … 277 280 with Session do begin 278 281 try 279 Session.Lock.Acquire; 280 Session.SequenceNumber := Sessions.GetSequenceNumber; 282 Lock.Acquire; 281 283 CommandIndex.Clear; 282 284 CommandIndex.AddArray(Command); … … 309 311 Sessions.Lock.Release; 310 312 end; 311 while MTWaitForEvent(ReceiveEvent,10 * OneMillisecond) = wrTimeout do begin313 while ReceiveEvent.WaitFor(10 * OneMillisecond) = wrTimeout do begin 312 314 if Timeouted then 313 315 raise ECommTimeout.Create(SResponseTimeout); … … 389 391 try 390 392 Lock.Acquire; 393 Session.SequenceNumber := GetSequenceNumber; 391 394 while Count >= Parent.MaxSessionCount do 392 395 begin … … 439 442 // instead of freeing in inherited Destroy in TListObject 440 443 try 441 Lock.Acquire;444 // Lock.Acquire; 442 445 Clear; 443 446 finally 444 Lock.Release;447 // Lock.Release; 445 448 end; 446 449 … … 451 454 function TDeviceProtocolSessionList.GetSequenceNumber: Integer; 452 455 begin 453 try 454 Lock.Acquire; 455 Inc(SequenceNumber); 456 if SequenceNumber > Parent.MaxSequenceNumber then 457 SequenceNumber := 0; 458 Result := SequenceNumber; 459 finally 460 Lock.Release; 461 end; 456 Inc(SequenceNumber); 457 if SequenceNumber > Parent.MaxSequenceNumber then 458 SequenceNumber := 0; 459 Result := SequenceNumber; 462 460 end; 463 461 -
PinConnection/UCommSerialPort.pas
r163 r171 59 59 Lock.Release; 60 60 end; 61 MTSleep(1 * OneMillisecond); 61 if Stream.Position <> Stream.Size then 62 MTSleep(1 * OneMillisecond); 62 63 until Stream.Position = Stream.Size; 63 64 end; -
PinConnection/UCommThread.pas
r163 r171 80 80 FReceiveThread.FreeOnTerminate := False; 81 81 FReceiveThread.Parent := Self; 82 FReceiveThread.Name := 'CommThread'; 82 83 FReceiveThread.Start; 83 84 end else begin -
PinConnection/UPacketBurst.pas
r163 r171 50 50 PacketBurstPin := TCommPin.Create; 51 51 PacketBurstPin.OnReceive := PacketBurstReceive; 52 SendThread := TMicroThreadEvent.Create;52 SendThreadEvent := TMicroThreadEvent.Create; 53 53 SendPeriod := OneMillisecond; 54 54 end;
Note:
See TracChangeset
for help on using the changeset viewer.