Changeset 171 for PinConnection


Ignore:
Timestamp:
Feb 21, 2011, 2:02:53 PM (14 years ago)
Author:
george
Message:
Location:
PinConnection
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • PinConnection/UCommProtocol.pas

    r163 r171  
    4646
    4747  TDeviceProtocolSessionList = class(TListObject)
     48  private
     49    function GetSequenceNumber: Integer;
     50  public
    4851    SequenceNumber: integer;
    4952    Parent: TCommProtocol;
     
    5457    constructor Create;
    5558    destructor Destroy; override;
    56     function GetSequenceNumber: Integer;
    5759  end;
    5860
     
    124126  TempStream: TMemoryStream;
    125127begin
    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
    130133    try
    131134      ReadFromStream(Stream);
     
    174177  finally
    175178    TempStream.Free;
    176     Free;
     179    Request.Free;
    177180  end;
    178181end;
     
    277280    with Session do begin
    278281      try
    279         Session.Lock.Acquire;
    280         Session.SequenceNumber := Sessions.GetSequenceNumber;
     282        Lock.Acquire;
    281283        CommandIndex.Clear;
    282284        CommandIndex.AddArray(Command);
     
    309311          Sessions.Lock.Release;
    310312        end;
    311         while MTWaitForEvent(ReceiveEvent, 10 * OneMillisecond) = wrTimeout do begin
     313        while ReceiveEvent.WaitFor(10 * OneMillisecond) = wrTimeout do begin
    312314          if Timeouted then
    313315            raise ECommTimeout.Create(SResponseTimeout);
     
    389391  try
    390392    Lock.Acquire;
     393    Session.SequenceNumber := GetSequenceNumber;
    391394    while Count >= Parent.MaxSessionCount do
    392395    begin
     
    439442  // instead of freeing in inherited Destroy in TListObject
    440443  try
    441     Lock.Acquire;
     444//    Lock.Acquire;
    442445    Clear;
    443446  finally
    444     Lock.Release;
     447//    Lock.Release;
    445448  end;
    446449
     
    451454function TDeviceProtocolSessionList.GetSequenceNumber: Integer;
    452455begin
    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;
    462460end;
    463461
  • PinConnection/UCommSerialPort.pas

    r163 r171  
    5959      Lock.Release;
    6060    end;
    61     MTSleep(1 * OneMillisecond);
     61    if Stream.Position <> Stream.Size then
     62      MTSleep(1 * OneMillisecond);
    6263  until Stream.Position = Stream.Size;
    6364end;
  • PinConnection/UCommThread.pas

    r163 r171  
    8080    FReceiveThread.FreeOnTerminate := False;
    8181    FReceiveThread.Parent := Self;
     82    FReceiveThread.Name := 'CommThread';
    8283    FReceiveThread.Start;
    8384  end else begin
  • PinConnection/UPacketBurst.pas

    r163 r171  
    5050  PacketBurstPin := TCommPin.Create;
    5151  PacketBurstPin.OnReceive := PacketBurstReceive;
    52   SendThread := TMicroThreadEvent.Create;
     52  SendThreadEvent := TMicroThreadEvent.Create;
    5353  SendPeriod := OneMillisecond;
    5454end;
Note: See TracChangeset for help on using the changeset viewer.