Changeset 576 for PinConnection/CommPin.pas
- Timestamp:
- Jun 25, 2024, 12:00:00 PM (4 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
PinConnection/CommPin.pas
r575 r576 26 26 FFrameRxCount: Integer; 27 27 FOnSetStatus: TOnSetStatus; 28 FRemotePin: TCommPin; 28 29 FStatus: Integer; 29 30 function GetConnected: Boolean; 31 procedure SetRemotePin(AValue: TCommPin); 30 32 procedure SetStatus(AValue: Integer); 31 33 protected … … 33 35 procedure ReceiveStatus(AValue: Integer); 34 36 public 35 RemotePin: TCommPin;36 37 Node: TCommNode; 37 38 constructor Create; … … 41 42 procedure Send(Stream: TListByte); 42 43 procedure ResetCounters; 44 property RemotePin: TCommPin read FRemotePin write SetRemotePin; 43 45 property Connected: Boolean read GetConnected; 44 46 property OnLogData: TOnLogDataEvent read FOnLogData write FOnLogData; … … 63 65 end; 64 66 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 65 76 66 77 implementation 78 79 { TCommNodeSimple } 80 81 constructor TCommNodeSimple.Create(AOwner: TComponent); 82 begin 83 inherited; 84 Pin := TCommPin.Create; 85 end; 86 87 destructor TCommNodeSimple.Destroy; 88 begin 89 Pin.Free; 90 inherited; 91 end; 67 92 68 93 { TCommNode } … … 78 103 procedure TCommPin.Connect(Pin: TCommPin); 79 104 begin 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; 89 106 end; 90 107 … … 97 114 procedure TCommPin.Disconnect; 98 115 begin 99 if Assigned(RemotePin) then begin 100 RemotePin.RemotePin := nil; 101 RemotePin := nil; 102 end; 116 RemotePin := nil; 103 117 end; 104 118 … … 106 120 begin 107 121 Result := Assigned(RemotePin); 122 end; 123 124 procedure TCommPin.SetRemotePin(AValue: TCommPin); 125 begin 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; 108 134 end; 109 135 … … 116 142 constructor TCommPin.Create; 117 143 begin 118 RemotePin := nil; 144 FRemotePin := nil; 145 FStatus := 0; 146 ResetCounters; 119 147 end; 120 148
Note:
See TracChangeset
for help on using the changeset viewer.