Ignore:
Timestamp:
Oct 24, 2011, 9:01:08 AM (13 years ago)
Author:
george
Message:
  • Added: TCommPin now support state number forwarding. State value is designed mainly for simulating parity bit and possibly other state bits.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • PinConnection/UCommPin.pas

    r247 r288  
    1414  TOnLogDataEvent = procedure (Stream: TStream; Direction: TDataDiretion) of object;
    1515  TOnStreamEvent = procedure (Sender: TCommPin; Stream: TStream) of object;
     16  TOnSetStatus = procedure (Sender: TCommPin; Status: Integer) of object;
    1617
    1718  { TCommPin }
     
    2526    FFrameTxCount: Integer;
    2627    FFrameRxCount: Integer;
     28    FOnSetStatus: TOnSetStatus;
     29    FStatus: Integer;
    2730    function GetConnected: Boolean;
     31    procedure SetStatus(AValue: Integer);
     32  protected
     33    procedure Receive(Stream: TStream);
     34    procedure ReceiveStatus(AValue: Integer);
    2835  public
    2936    RemotePin: TCommPin;
     
    3340    procedure Disconnect;
    3441    procedure Send(Stream: TStream);
    35     procedure Receive(Stream: TStream);
    3642    procedure ResetCounters;
    37     property OnReceive: TOnStreamEvent read FOnReceive write FOnReceive;
    3843    property Connected: Boolean read GetConnected;
    3944    property OnLogData: TOnLogDataEvent read FOnLogData write FOnLogData;
     
    4247    property FrameTxCount: Integer read FFrameTxCount;
    4348    property FrameRxCount: Integer read FFrameRxCount;
     49    property Status: Integer read FStatus write SetStatus; // Used for general status bits such as parity bit
     50    property OnReceive: TOnStreamEvent read FOnReceive write FOnReceive;
     51    property OnSetSatus: TOnSetStatus read FOnSetStatus write FOnSetStatus;
    4452  end;
    4553
     
    5563    Disconnect;
    5664    Self.RemotePin := Pin;
    57     Pin.RemotePin := Self;
     65    if Assigned(Pin) then begin
     66      Pin.RemotePin := Self;
     67      RemotePin.ReceiveStatus(FStatus);
     68    end;
    5869  end;
    5970end;
     
    7889end;
    7990
     91procedure TCommPin.SetStatus(AValue: Integer);
     92begin
     93  FStatus := AValue;
     94  if Assigned(RemotePin) then RemotePin.ReceiveStatus(AValue);
     95end;
     96
    8097constructor TCommPin.Create;
    8198begin
     
    90107  Stream.Position := 0;
    91108  if Assigned(FOnReceive) then FOnReceive(Self, Stream);
     109end;
     110
     111procedure TCommPin.ReceiveStatus(AValue: Integer);
     112begin
     113  if Assigned(FOnSetStatus) then FOnSetStatus(Self, AValue);
    92114end;
    93115
Note: See TracChangeset for help on using the changeset viewer.