Changeset 576 for PinConnection


Ignore:
Timestamp:
Jun 25, 2024, 12:00:00 PM (5 months ago)
Author:
chronos
Message:
  • Modified: RemotePin in TCommPin made as property.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • PinConnection/CommPin.pas

    r575 r576  
    2626    FFrameRxCount: Integer;
    2727    FOnSetStatus: TOnSetStatus;
     28    FRemotePin: TCommPin;
    2829    FStatus: Integer;
    2930    function GetConnected: Boolean;
     31    procedure SetRemotePin(AValue: TCommPin);
    3032    procedure SetStatus(AValue: Integer);
    3133  protected
     
    3335    procedure ReceiveStatus(AValue: Integer);
    3436  public
    35     RemotePin: TCommPin;
    3637    Node: TCommNode;
    3738    constructor Create;
     
    4142    procedure Send(Stream: TListByte);
    4243    procedure ResetCounters;
     44    property RemotePin: TCommPin read FRemotePin write SetRemotePin;
    4345    property Connected: Boolean read GetConnected;
    4446    property OnLogData: TOnLogDataEvent read FOnLogData write FOnLogData;
     
    6365  end;
    6466
     67  { TCommNodeSimple }
     68
     69  TCommNodeSimple = class(TCommNode)
     70  public
     71    Pin: TCommPin;
     72    constructor Create(AOwner: TComponent); override;
     73    destructor Destroy; override;
     74  end;
     75
    6576
    6677implementation
     78
     79{ TCommNodeSimple }
     80
     81constructor TCommNodeSimple.Create(AOwner: TComponent);
     82begin
     83  inherited;
     84  Pin := TCommPin.Create;
     85end;
     86
     87destructor TCommNodeSimple.Destroy;
     88begin
     89  Pin.Free;
     90  inherited;
     91end;
    6792
    6893{ TCommNode }
     
    78103procedure TCommPin.Connect(Pin: TCommPin);
    79104begin
    80   if Pin <> RemotePin then begin
    81     Pin.Disconnect;
    82     Disconnect;
    83     Self.RemotePin := Pin;
    84     if Assigned(Pin) then begin
    85       Pin.RemotePin := Self;
    86       RemotePin.ReceiveStatus(FStatus);
    87     end;
    88   end;
     105  RemotePin := Pin;
    89106end;
    90107
     
    97114procedure TCommPin.Disconnect;
    98115begin
    99   if Assigned(RemotePin) then begin
    100     RemotePin.RemotePin := nil;
    101     RemotePin := nil;
    102   end;
     116  RemotePin := nil;
    103117end;
    104118
     
    106120begin
    107121  Result := Assigned(RemotePin);
     122end;
     123
     124procedure TCommPin.SetRemotePin(AValue: TCommPin);
     125begin
     126  if FRemotePin = AValue then Exit;
     127  if Assigned(FRemotePin) then
     128    FRemotePin.FRemotePin := nil;
     129  FRemotePin := AValue;
     130  if Assigned(FRemotePin) then begin
     131    FRemotePin.RemotePin := Self;
     132    FRemotePin.ReceiveStatus(FStatus);
     133  end;
    108134end;
    109135
     
    116142constructor TCommPin.Create;
    117143begin
    118   RemotePin := nil;
     144  FRemotePin := nil;
     145  FStatus := 0;
     146  ResetCounters;
    119147end;
    120148
Note: See TracChangeset for help on using the changeset viewer.