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/UCommDelay.pas

    r302 r407  
    66
    77uses
    8   Classes, SysUtils, UCommPin, UThreading, SyncObjs, SpecializedList, UStreamHelper;
     8  Classes, SysUtils, UCommPin, UThreading, SyncObjs, SpecializedList, UStreamHelper,
     9  UBinarySerializer;
    910
    1011type
     
    1516  TDelayedPacket = class
    1617    ReceiveTime: TDateTime;
    17     Data: TStreamHelper;
     18    Data: TListByte;
    1819    constructor Create;
    1920    destructor Destroy; override;
     
    4041    Thread1: TCommDelayThread;
    4142    Thread2: TCommDelayThread;
    42     procedure ReceiveData1(Sender: TCommPin; AStream: TStream);
    43     procedure ReceiveData2(Sender: TCommPin; AStream: TStream);
     43    procedure ReceiveData1(Sender: TCommPin; AStream: TListByte);
     44    procedure ReceiveData2(Sender: TCommPin; AStream: TListByte);
    4445    procedure SetActive(AValue: Boolean);
    4546  public
     
    6263  I: Integer;
    6364  CurrentTime: TDateTime;
    64   SendData: TStreamHelper;
     65  SendData: TListByte;
    6566  DoSleep: Boolean;
    6667begin
    6768  try
    68     SendData := TStreamHelper.Create;
     69    SendData := TListByte.Create;
    6970    repeat
    7071      DoSleep := True;
     
    7677            if TDelayedPacket(PacketQueue[I]).ReceiveTime < (CurrentTime - Parent.Delay) then begin
    7778              DoSleep := False;
    78               SendData.Clear;
    79               SendData.WriteStream(TDelayedPacket(PacketQueue[I]).Data, TDelayedPacket(PacketQueue[I]).Data.Size);
     79              SendData.Assign(TDelayedPacket(PacketQueue[I]).Data);
    8080              PacketQueue.Delete(I);
    8181              try
    8282                Lock.Release;
    83                 Pin.Send(SendData.Stream);
     83                Pin.Send(SendData);
    8484              finally
    8585                Lock.Acquire;
     
    100100constructor TDelayedPacket.Create;
    101101begin
    102   Data := TStreamHelper.Create;
     102  Data := TListByte.Create;
    103103end;
    104104
     
    111111{ TCommDelay }
    112112
    113 procedure TCommDelay.ReceiveData1(Sender: TCommPin; AStream: TStream);
     113procedure TCommDelay.ReceiveData1(Sender: TCommPin; AStream: TListByte);
    114114begin
    115115  try
     
    119119    with TDelayedPacket(PacketQueue2.AddNew(TDelayedPacket.Create)) do begin
    120120      ReceiveTime := Now;
    121       Data.WriteStream(AStream, AStream.Size);
     121      Data.Assign(AStream);
    122122    end;
    123123  finally
     
    126126end;
    127127
    128 procedure TCommDelay.ReceiveData2(Sender: TCommPin; AStream: TStream);
     128procedure TCommDelay.ReceiveData2(Sender: TCommPin; AStream: TListByte);
    129129begin
    130130  try
     
    134134    with TDelayedPacket(PacketQueue1.AddNew(TDelayedPacket.Create)) do begin
    135135      ReceiveTime := Now;
    136       Data.WriteStream(AStream, AStream.Size);
     136      Data.Assign(AStream);
    137137    end;
    138138  finally
Note: See TracChangeset for help on using the changeset viewer.