Ignore:
Timestamp:
Nov 16, 2011, 7:24:09 AM (13 years ago)
Author:
george
Message:
  • Added: New TCommDelay interconnection block for creating time delay in route.
  • Fixed: In TCommThread do not obtain lock during sending data in thread.
  • Modified: TCommFrame have ability to change special control symbols.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • PinConnection/UCommFrame.pas

    r288 r296  
    88  Classes, UStreamHelper, Dialogs, SysUtils,
    99  UCommPin;
    10 
    11 const
    12   SpecialChar = $fe;
    13   ControlCodeFrameStart = $fd;
    14   ControlCodeFrameEnd = $fc;
    15   ControlCodeSpecialChar = $fb;
    16   TimeoutRepeatCount = 3;
    1710
    1811type
     
    3326    FrameDataPin: TCommPin;
    3427    PacketLoss: Real;
     28    SpecialChar: Byte;
     29    ControlCodeFrameStart: Byte;
     30    ControlCodeFrameEnd: Byte;
     31    ControlCodeSpecialChar: Byte;
    3532    procedure RawDataReceive(Sender: TCommPin; Stream: TStream);
    3633    procedure RawSetStatus(Sender: TCommPin; Status: Integer);
    3734    procedure FrameDataReceive(Sender: TCommPin; Stream: TStream);
    3835    procedure FrameSetStatus(Sender: TCommPin; Status: Integer);
     36    function ComputeRawSize(DataStream: TStream): Integer;
    3937    constructor Create;
    4038    destructor Destroy; override;
     
    5654  FrameDataPin.OnReceive := FrameDataReceive;
    5755  PacketLoss := 0.005;
     56  SpecialChar := $fe;
     57  ControlCodeFrameStart := $fd;
     58  ControlCodeFrameEnd := $fc;
     59  ControlCodeSpecialChar := $fb;
    5860end;
    5961
     
    99101    RawData.WriteByte(SpecialChar);
    100102    RawData.WriteByte(ControlCodeFrameEnd);
    101     //if Random >= PacketLoss then
     103    if Random >= PacketLoss then
    102104      RawDataPin.Send(RawData);
    103105
     
    110112begin
    111113  RawDataPin.Status := Status;
     114end;
     115
     116function TCommFrame.ComputeRawSize(DataStream: TStream): Integer;
     117begin
     118  Result := 5; // FrameStart + CRC + FrameEnd
     119  DataStream.Position := 0;
     120  while DataStream.Position < DataStream.Size do
     121    if DataStream.ReadByte = SpecialChar then Inc(Result, 2)
     122      else Inc(Result, 1);
    112123end;
    113124
     
    170181  Polynom: Byte = $18;
    171182begin
     183  Pom := 0;
    172184  Stream.Position := 0;
    173185  Result := 0;
Note: See TracChangeset for help on using the changeset viewer.