Ignore:
Timestamp:
Aug 14, 2012, 10:31:30 AM (12 years ago)
Author:
chronos
Message:
  • Modified: PinConnection package now use for data parameters TListByte instead of TStream class contained in TemplateGenerics package. TStream have Position property which has no meaning for forwarding plain byte memory block. There is TBinarySerializer class used for serializing data instead of TStreamHelper class.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • PinConnection/UCommThread.pas

    r384 r407  
    77uses
    88  Classes, SysUtils, blcksock, UCommPin, SyncObjs, UStreamHelper, UCommon,
    9   DateUtils, UThreading;
     9  DateUtils, UThreading, SpecializedList, UBinarySerializer;
    1010
    1111type
     
    1919  public
    2020    Parent: TCommThread;
    21     Stream: TStreamHelper;
     21    Stream: TBinarySerializer;
    2222    procedure Execute; override;
    2323    constructor Create(CreateSuspended: Boolean;
     
    3333    FOnReceiveData: TReceiveDataEvent;
    3434    FReceiveThread: TCommThreadReceiveThread;
    35     FInputBuffer: TMemoryStream;
     35    FInputBuffer: TBinarySerializer;
    3636    FInputBufferLock: TCriticalSection;
    3737    FDataAvailable: TEvent;
    3838    FStatusEvent: TEvent;
    3939    FStatusValue: Integer;
    40     procedure PinReceiveData(Sender: TCommPin; Stream: TStream);
     40    procedure PinReceiveData(Sender: TCommPin; Stream: TListByte);
    4141    procedure PinSetStatus(Sender: TCommPin; Status: Integer);
    42     procedure ExtReceiveData(Sender: TCommPin; Stream: TStream);
     42    procedure ExtReceiveData(Sender: TCommPin; Stream: TListByte);
    4343    procedure ExtSetStatus(Sender: TCommPin; AStatus: Integer);
    4444    procedure SetActive(const AValue: Boolean);
     
    5555{ TCommThread }
    5656
    57 procedure TCommThread.PinReceiveData(Sender: TCommPin; Stream:TStream);
     57procedure TCommThread.PinReceiveData(Sender: TCommPin; Stream: TListByte);
    5858begin
    5959  if FActive then Ext.Send(Stream);
     
    6565end;
    6666
    67 procedure TCommThread.ExtReceiveData(Sender: TCommPin; Stream: TStream);
    68 var
    69   StreamHelper: TStreamHelper;
     67procedure TCommThread.ExtReceiveData(Sender: TCommPin; Stream: TListByte);
    7068begin
    7169  try
    72     StreamHelper := TStreamHelper.Create(FInputBuffer);
    7370    FInputBufferLock.Acquire;
    74     StreamHelper.WriteStream(Stream, Stream.Size);
     71    FInputBuffer.WriteList(Stream, 0, Stream.Count);
    7572    FDataAvailable.SetEvent;
    7673  finally
    7774    FInputBufferLock.Release;
    78     StreamHelper.Free;
    7975  end;
    8076end;
     
    110106begin
    111107  inherited Create;
    112   FInputBuffer := TMemoryStream.Create;
     108  FInputBuffer := TBinarySerializer.Create;
     109  FInputBuffer.List := TListByte.Create;
     110  FInputBuffer.OwnsList := True;
    113111  FInputBufferLock := TCriticalSection.Create;
    114112  Ext := TCommPin.Create;
     
    150148      try
    151149        FInputBufferLock.Acquire;
    152         Stream.Size := 0;
    153         Stream.WriteStream(FInputBuffer, FInputBuffer.Size);
     150        Stream.List.Assign(FInputBuffer.List);
    154151        FDataAvailable.ResetEvent;
    155152        FInputBuffer.Clear;
     
    157154        FInputBufferLock.Release;
    158155      end; // else Yield;
    159       Pin.Send(Stream);
     156      Pin.Send(Stream.List);
    160157    end;
    161158
     
    182179begin
    183180  inherited;
    184   Stream := TStreamHelper.Create;
     181  Stream := TBinarySerializer.Create;
     182  Stream.List := TListByte.Create;
     183  Stream.OwnsList := True;
    185184end;
    186185
Note: See TracChangeset for help on using the changeset viewer.