Changeset 289 for PinConnection
- Timestamp:
- Nov 1, 2011, 10:32:54 AM (13 years ago)
- Location:
- PinConnection
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
PinConnection/PinConnection.lpk
r268 r289 12 12 <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> 13 13 </SearchPaths> 14 <Linking> 15 <Debugging> 16 <GenerateDebugInfo Value="True"/> 17 <DebugInfoType Value="dsAuto"/> 18 </Debugging> 19 </Linking> 14 20 <Other> 15 21 <CompilerMessages> … … 21 27 <Description Value="System for class bidirectional communication interconnection."/> 22 28 <License Value="GNU/GPL"/> 23 <Version Minor=" 2"/>24 <Files Count=" 9">29 <Version Minor="3"/> 30 <Files Count="10"> 25 31 <Item1> 26 32 <Filename Value="UCommFrame.pas"/> … … 59 65 <UnitName Value="USerialPort"/> 60 66 </Item9> 67 <Item10> 68 <Filename Value="UCommConcentrator.pas"/> 69 <UnitName Value="UCommConcentrator"/> 70 </Item10> 61 71 </Files> 62 72 <i18n> -
PinConnection/PinConnection.pas
r119 r289 8 8 9 9 uses 10 UCommFrame, UCommHub, UCommPin, UCommProtocol, UCommSerialPort,11 UComm Socket, UCommThread, UPacketBurst, USerialPort, LazarusPackageIntf;10 UCommFrame, UCommHub, UCommPin, UCommProtocol, UCommSerialPort, UCommSocket, 11 UCommThread, UPacketBurst, USerialPort, UCommConcentrator, LazarusPackageIntf; 12 12 13 13 implementation -
PinConnection/UCommHub.pas
r288 r289 9 9 10 10 type 11 TCommHub = class; 12 13 { TPinList } 14 15 TPinList = class(TObjectList) 16 Hub: TCommHub; 17 function Add(AObject: TObject): Integer; 18 function AddNew: TCommPin; 19 function Extract(Item: TObject): TObject; 20 procedure Insert(Index: Integer; AObject: TObject); 21 end; 11 22 12 23 { TCommHub } … … 15 26 private 16 27 FActive: Boolean; 17 FPins: TObjectList; 18 function GetPin(Index: Integer): TCommPin; 28 FPins: TPinList; 19 29 procedure Receive(Sender: TCommPin; Stream: TStream); 20 30 procedure SetStatus(Sender: TCommPin; Status: Integer); … … 22 32 constructor Create; 23 33 destructor Destroy; override; 24 function Add(Pin: TCommPin): Integer; 25 function Extract(Pin: TCommPin): TCommPin; 26 function Remove(Pin: TCommPin): Integer; 27 function IndexOf(Pin: TCommPin): Integer; 28 Procedure Insert(Index: Integer; Pin: TCommPin); 29 function First: TCommPin; 30 Function Last: TCommPin; 31 function AddNew: TCommPin; 32 property Pins[Index: Integer]: TCommPin read GetPin; 34 property Pins: TPinList read FPins write FPins; 33 35 property Active: Boolean read FActive write FActive; 34 36 end; … … 36 38 implementation 37 39 40 { TPinList } 41 42 function TPinList.Add(AObject: TObject): Integer; 43 begin 44 Result := inherited Add(AObject); 45 TCommPin(AObject).OnReceive := Hub.Receive; 46 TCommPin(AObject).OnSetSatus := Hub.SetStatus; 47 end; 48 49 function TPinList.AddNew: TCommPin; 50 begin 51 Result := TCommPin(Items[Add(TCommPin.Create)]); 52 end; 53 54 function TPinList.Extract(Item: TObject): TObject; 55 begin 56 TCommPin(Item).OnReceive := nil; 57 TCommPin(Item).OnSetSatus := nil; 58 Result := inherited Extract(Item); 59 end; 60 61 procedure TPinList.Insert(Index: Integer; AObject: TObject); 62 begin 63 inherited Insert(Index, AObject); 64 TCommPin(AObject).OnReceive := Hub.Receive; 65 TCommPin(AObject).OnSetSatus := Hub.SetStatus; 66 end; 67 38 68 { TCommHub } 39 40 function TCommHub.GetPin(Index: Integer): TCommPin;41 begin42 Result := TCommPin(FPins[Index]);43 end;44 69 45 70 procedure TCommHub.Receive(Sender: TCommPin; Stream: TStream); … … 69 94 constructor TCommHub.Create; 70 95 begin 71 FPins := TObjectList.Create; 96 FPins := TPinList.Create; 97 FPins.Hub := Self; 72 98 end; 73 99 74 100 destructor TCommHub.Destroy; 75 101 begin 102 Active := False; 76 103 FPins.Free; 77 104 inherited Destroy; 78 105 end; 79 106 80 function TCommHub.Add(Pin: TCommPin): Integer;81 begin82 Pin.OnReceive := Receive;83 Pin.OnSetSatus := SetStatus;84 Result := FPins.Add(Pin);85 end;86 87 function TCommHub.Extract(Pin: TCommPin): TCommPin;88 begin89 Pin.OnReceive := nil;90 Pin.OnSetSatus := nil;91 Result := TCommPin(FPins.Extract(Pin));92 end;93 94 function TCommHub.Remove(Pin: TCommPin): Integer;95 begin96 Result := FPins.Remove(Pin);97 end;98 99 function TCommHub.IndexOf(Pin: TCommPin): Integer;100 begin101 Result := FPins.IndexOf(Pin);102 end;103 104 procedure TCommHub.Insert(Index: Integer; Pin: TCommPin);105 begin106 Pin.OnReceive := Receive;107 Pin.OnSetSatus := SetStatus;108 FPins.Insert(Index, Pin);109 end;110 111 function TCommHub.First: TCommPin;112 begin113 Result := TCommPin(FPins.First);114 end;115 116 function TCommHub.Last: TCommPin;117 begin118 Result := TCommPin(FPins.Last);119 end;120 121 function TCommHub.AddNew: TCommPin;122 begin123 Result := TCommPin.Create;124 Result.OnReceive := Receive;125 Result.OnSetSatus := SetStatus;126 FPins.Add(Result);127 end;128 129 107 end. 130 108
Note:
See TracChangeset
for help on using the changeset viewer.