Changeset 119 for Comm/UCommPin.pas


Ignore:
Timestamp:
Jan 5, 2011, 1:16:30 PM (14 years ago)
Author:
george
Message:
  • Created: New Lazarus package as container for few classes with bidirectional pin interconnection system .
Location:
Comm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • Comm

    • Property svn:ignore set to
      lib
  • Comm/UCommPin.pas

    r26 r119  
    99
    1010type
     11  TCommPin = class;
     12
    1113  TDataDiretion = (ddReceive, ddSend);
    1214  TOnLogDataEvent = procedure (Stream: TStream; Direction: TDataDiretion) of object;
    13   TOnStreamEvent = procedure (Stream: TStream) of object;
     15  TOnStreamEvent = procedure (Sender: TCommPin; Stream: TStream) of object;
    1416
    1517  { TCommPin }
     
    1921    FOnLogData: TOnLogDataEvent;
    2022    FOnReceive: TOnStreamEvent;
     23    FDataTxCount: Integer;
     24    FDataRxCount: Integer;
     25    FFrameTxCount: Integer;
     26    FFrameRxCount: Integer;
    2127    function GetConnected: Boolean;
    2228  public
    2329    RemotePin: TCommPin;
     30    constructor Create;
    2431    destructor Destroy; override;
    2532    procedure Connect(Pin: TCommPin);
     
    2734    procedure Send(Stream: TStream);
    2835    procedure Receive(Stream: TStream);
     36    procedure ResetCounters;
    2937    property OnReceive: TOnStreamEvent read FOnReceive write FOnReceive;
    3038    property Connected: Boolean read GetConnected;
    3139    property OnLogData: TOnLogDataEvent read FOnLogData write FOnLogData;
     40    property DataTxCount: Integer read FDataTxCount;
     41    property DataRxCount: Integer read FDataRxCount;
     42    property FrameTxCount: Integer read FFrameTxCount;
     43    property FrameRxCount: Integer read FFrameRxCount;
    3244  end;
    3345
     
    6375end;
    6476
     77constructor TCommPin.Create;
     78begin
     79  RemotePin := nil;
     80end;
     81
    6582procedure TCommPin.Receive(Stream: TStream);
    6683begin
     84  Inc(FDataRxCount, Stream.Size);
     85  Inc(FFrameRxCount);
    6786  if Assigned(FOnLogData) then FOnLogData(Stream, ddReceive);
    6887  Stream.Position := 0;
    69   if Assigned(FOnReceive) then FOnReceive(Stream);
     88  if Assigned(FOnReceive) then FOnReceive(Self, Stream);
     89end;
     90
     91procedure TCommPin.ResetCounters;
     92begin
     93  FDataTxCount := 0;
     94  FDataRxCount := 0;
     95  FFrameTxCount := 0;
     96  FFrameRxCount := 0;
    7097end;
    7198
    7299procedure TCommPin.Send(Stream: TStream);
    73100begin
     101  Inc(FDataTxCount, Stream.Size);
     102  Inc(FFrameTxCount);
    74103  if Assigned(FOnLogData) then FOnLogData(Stream, ddSend);
    75104  if Assigned(RemotePin) then RemotePin.Receive(Stream);
Note: See TracChangeset for help on using the changeset viewer.