Changeset 413
- Timestamp:
- Aug 16, 2012, 12:59:53 PM (12 years ago)
- Files:
-
- 1 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
ISPProgrammer/Dallas/UDallasProgrammer.pas
r410 r413 8 8 Classes, SysUtils, USerialPort, UCommSerialPort, UCommPin, UCommMark, 9 9 UJobProgressView, SyncObjs, DateUtils, Dialogs, URegistry, 10 Forms, UISPProgrammer, Registry, UBinarySerializer, SpecializedList; 10 Forms, UISPProgrammer, Registry, UBinarySerializer, SpecializedList, 11 UCommTelnet; 11 12 12 13 const … … 135 136 136 137 procedure TDallasProgrammer.SetActive(AValue: Boolean); 138 var 139 SerialPort: TCommSerialPort; 140 Telnet: TCommTelnet; 137 141 begin 138 142 if Active = AValue then Exit; … … 144 148 HexData := TStringList.Create; 145 149 146 SerialPort.Active := False; 147 SerialPortBackup.Assign(SerialPort); 148 SerialPortBackupPin := SerialPort.Pin.RemotePin; 149 SerialPort.Pin.Disconnect; 150 151 //SerialPort.Name := SerialPort.Name; 152 SerialPort.FlowControl := fcNone; 153 SerialPort.BaudRate := BaudRate; 154 SerialPort.DTR := True; 155 SerialPort.Pin.Connect(CommMark.PinRaw); 156 SerialPort.Flush; 157 SerialPort.Purge; 158 SerialPort.Active := True; 159 if Assigned(FOnLogData) then 160 Pin.OnLogData := FOnLogData; 150 if ExtPin.Connected and (ExtPin.RemotePin.Node is TCommSerialPort) then begin 151 SerialPort := TCommSerialPort(ExtPin.RemotePin.Node); 152 SerialPort.Active := False; 153 SerialPortBackup.Assign(SerialPort); 154 SerialPortBackupPin := SerialPort.Pin.RemotePin; 155 SerialPort.Pin.Disconnect; 156 157 //SerialPort.Name := SerialPort.Name; 158 SerialPort.SerialPort.FlowControl := fcNone; 159 SerialPort.SerialPort.BaudRate := BaudRate; 160 SerialPort.SerialPort.DTR := True; 161 SerialPort.Pin.Connect(CommMark.PinRaw); 162 SerialPort.SerialPort.Flush; 163 SerialPort.SerialPort.Purge; 164 SerialPort.Active := True; 165 if Assigned(FOnLogData) then 166 Pin.OnLogData := FOnLogData; 167 end; 168 if ExtPin.Connected and (ExtPin.RemotePin.Node is TCommTelnet) then begin 169 Telnet := TCommTelnet(ExtPin.RemotePin.Node); 170 end; 161 171 ResponseClear; 162 172 CommMark.Active := True; 163 164 173 ReadIdentification; 165 174 end else begin 166 175 CommMark.Active := False; 167 SerialPort.Active := False; 168 SerialPort.Assign(SerialPortBackup); 169 SerialPort.Pin.Connect(SerialPortBackupPin); 170 SerialPort.Active := True; 176 if ExtPin.Connected and (ExtPin.RemotePin.Node is TCommSerialPort) then begin 177 SerialPort := TCommSerialPort(ExtPin.Node); 178 SerialPort.Active := False; 179 SerialPort.Assign(SerialPortBackup); 180 SerialPort.Pin.Connect(SerialPortBackupPin); 181 SerialPort.Active := True; 182 end; 183 if ExtPin.Connected and (ExtPin.RemotePin.Node is TCommTelnet) then begin 184 Telnet := TCommTelnet(ExtPin.RemotePin.Node); 185 end; 171 186 HexData.Free; 172 187 Request.Free; … … 359 374 Mark := TListByte.Create; 360 375 Mark.SetArray([13, 10]); 361 CommMark := TCommMark.Create ;376 CommMark := TCommMark.Create(nil); 362 377 CommMark.Mark.Assign(Mark); 363 378 CommMark.PinFrame.Connect(Pin); 364 379 BaudRate := 9600; 365 SerialPortBackup := TCommSerialPort.Create ;380 SerialPortBackup := TCommSerialPort.Create(nil); 366 381 end; 367 382 -
ISPProgrammer/UISPProgrammer.pas
r406 r413 6 6 7 7 uses 8 Classes, SysUtils, Registry, UIntelHexFile, UCommSerialPort,9 UCPUType, UJobProgressView ;8 Classes, SysUtils, Registry, UIntelHexFile, 9 UCPUType, UJobProgressView, UCommPin; 10 10 11 11 type … … 31 31 HexFile: TIntelHexFile; 32 32 FileName: string; 33 SerialPort: TCommSerialPort;34 33 Capabilities: TISPProgCapabilities; 34 ExtPin: TCommPin; 35 35 procedure Log(Text: string); 36 36 procedure LoadFromRegistry(Root: HKEY; Key: string); virtual; … … 130 130 constructor TISPProgrammer.Create; 131 131 begin 132 ExtPin := TCommPin.Create; 132 133 HexFile := TIntelHexFile.Create; 133 134 HexFile.BytePerLine := 20; 134 SerialPort := nil;135 135 end; 136 136 … … 138 138 begin 139 139 Active := False; 140 ExtPin.Free; 140 141 HexFile.Free; 141 142 inherited Destroy; -
PinConnection/PinConnection.lpk
r411 r413 21 21 <Description Value="System for class bidirectional communication interconnection."/> 22 22 <License Value="GNU/GPL"/> 23 <Version Minor=" 3"/>24 <Files Count="1 4">23 <Version Minor="4"/> 24 <Files Count="15"> 25 25 <Item1> 26 26 <Filename Value="USerialPort.pas"/> … … 79 79 <UnitName Value="UCommMark"/> 80 80 </Item14> 81 <Item15> 82 <Filename Value="UPinConnection.pas"/> 83 <HasRegisterProc Value="True"/> 84 <UnitName Value="UPinConnection"/> 85 </Item15> 81 86 </Files> 82 87 <i18n> -
PinConnection/PinConnection.pas
r411 r413 10 10 USerialPort, UPacketBurst, UCommFrame, UCommHub, UCommPin, UCommSerialPort, 11 11 UCommThread, UCommConcentrator, UCommDelay, UCommTCPClient, UCommTCPServer, 12 UCommTelnet, UCommTelnetComPortOption, UCommMark, LazarusPackageIntf; 12 UCommTelnet, UCommTelnetComPortOption, UCommMark, UPinConnection, 13 LazarusPackageIntf; 13 14 14 15 implementation … … 16 17 procedure Register; 17 18 begin 19 RegisterUnit('UPinConnection', @UPinConnection.Register); 18 20 end; 19 21 -
PinConnection/UCommConcentrator.pas
r407 r413 26 26 { TCommConcentrator } 27 27 28 TCommConcentrator = class 28 TCommConcentrator = class(TCommNode) 29 29 private 30 30 FActive: Boolean; … … 36 36 procedure SetStatus(Sender: TCommPin; Status: Integer); 37 37 public 38 constructor Create ;38 constructor Create(AOwner: TComponent); override; 39 39 destructor Destroy; override; 40 40 property Pins: TPinList read FPins write FPins; … … 57 57 begin 58 58 Result := TCommPin(Items[Add(TCommPin.Create)]); 59 Result.Node := Concentrator; 59 60 end; 60 61 … … 109 110 end; 110 111 111 constructor TCommConcentrator.Create ;112 constructor TCommConcentrator.Create(AOwner: TComponent); 112 113 begin 114 inherited; 113 115 FPins := TPinList.Create; 114 116 FPins.Concentrator := Self; -
PinConnection/UCommDelay.pas
r407 r413 33 33 { TCommDelay } 34 34 35 TCommDelay = class 35 TCommDelay = class(TCommNode) 36 36 private 37 37 FActive: Boolean; … … 49 49 Pin1: TCommPin; 50 50 Pin2: TCommPin; 51 constructor Create ;51 constructor Create(AOwner: TComponent); override; 52 52 destructor Destroy; override; 53 53 property Delay: TDateTime read FDelay write FDelay; … … 169 169 end; 170 170 171 constructor TCommDelay.Create ;171 constructor TCommDelay.Create(AOwner: TComponent); 172 172 begin 173 inherited; 173 174 Lock1 := TCriticalSection.Create; 174 175 Lock2 := TCriticalSection.Create; … … 177 178 Pin1 := TCommPin.Create; 178 179 Pin1.OnReceive := ReceiveData1; 180 Pin1.Node := Self; 179 181 Pin2 := TCommPin.Create; 180 182 Pin2.OnReceive := ReceiveData2; 183 Pin2.Node := Self; 181 184 end; 182 185 -
PinConnection/UCommFrame.pas
r411 r413 14 14 { TCommFrame } 15 15 16 TCommFrame = class 16 TCommFrame = class(TCommNode) 17 17 private 18 18 LastCharIsSpecialChar: Boolean; … … 35 35 ControlCodeSpecialChar: Byte; 36 36 function ComputeRawSize(DataStream: TListByte): Integer; 37 constructor Create ;37 constructor Create(AOwner: TComponent); override; 38 38 destructor Destroy; override; 39 39 property FrameErrorCount: Integer read FFrameErrorCount; … … 46 46 { TCommFrame } 47 47 48 constructor TCommFrame.Create; 49 begin 48 constructor TCommFrame.Create(AOwner: TComponent); 49 begin 50 inherited; 50 51 ReceiveBuffer := TBinarySerializer.Create; 51 52 ReceiveBuffer.List := TListByte.Create; … … 53 54 RawDataPin := TCommPin.Create; 54 55 RawDataPin.OnReceive := RawDataReceive; 56 RawDataPin.Node := Self; 55 57 FrameDataPin := TCommPin.Create; 56 58 FrameDataPin.OnReceive := FrameDataReceive; 59 FrameDataPin.Node := Self; 57 60 PacketLoss := 0; 58 61 SpecialChar := $fe; -
PinConnection/UCommHub.pas
r407 r413 23 23 { TCommHub } 24 24 25 TCommHub = class 25 TCommHub = class(TCommNode) 26 26 private 27 27 FActive: Boolean; … … 30 30 procedure SetStatus(Sender: TCommPin; Status: Integer); 31 31 public 32 constructor Create ;32 constructor Create(AOwner: TComponent); override; 33 33 destructor Destroy; override; 34 34 property Pins: TPinList read FPins write FPins; … … 50 50 begin 51 51 Result := TCommPin(Items[Add(TCommPin.Create)]); 52 Result.Node := Hub; 52 53 end; 53 54 … … 92 93 end; 93 94 94 constructor TCommHub.Create ;95 constructor TCommHub.Create(AOwner: TComponent); 95 96 begin 97 inherited; 96 98 FPins := TPinList.Create; 97 99 FPins.Hub := Self; -
PinConnection/UCommMark.pas
r410 r413 12 12 { TCommMark } 13 13 14 TCommMark = class 14 TCommMark = class(TCommNode) 15 15 private 16 16 FActive: Boolean; … … 27 27 Mark: TListByte; 28 28 procedure Reset; 29 constructor Create ;29 constructor Create(AOwner: TComponent); override; 30 30 destructor Destroy; override; 31 31 property Active: Boolean read FActive write SetActive; … … 88 88 end; 89 89 90 constructor TCommMark.Create ;90 constructor TCommMark.Create(AOwner: TComponent); 91 91 begin 92 inherited; 92 93 PinRaw := TCommPin.Create; 93 94 PinRaw.OnReceive := RawDataReceive; 94 95 PinRaw.OnSetSatus := RawSetStatus; 96 PinRaw.Node := Self; 95 97 PinFrame := TCommPin.Create; 96 98 PinFrame.OnReceive := FrameDataReceive; 97 99 PinFrame.OnSetSatus := FrameSetStatus; 100 PinFrame.Node := Self; 98 101 Mark := TListByte.Create; 99 102 FMarkIndex := 0; -
PinConnection/UCommPin.pas
r407 r413 10 10 type 11 11 TCommPin = class; 12 TCommNode = class; 12 13 13 14 TDataDiretion = (ddReceive, ddSend); … … 35 36 public 36 37 RemotePin: TCommPin; 38 Node: TCommNode; 37 39 constructor Create; 38 40 destructor Destroy; override; … … 52 54 end; 53 55 56 { TCommNode } 57 58 TCommNode = class(TComponent) 59 private 60 FActive: Boolean; 61 protected 62 procedure SetActive(AValue: Boolean); virtual; 63 public 64 property Active: Boolean read FActive write SetActive; 65 end; 66 54 67 55 68 implementation 69 70 { TCommNode } 71 72 procedure TCommNode.SetActive(AValue: Boolean); 73 begin 74 if FActive = AValue then Exit; 75 FActive := AValue; 76 end; 56 77 57 78 { TCommPin } -
PinConnection/UCommSerialPort.pas
r407 r413 13 13 { TCommSerialPort } 14 14 15 TCommSerialPort = class(T SerialPort)15 TCommSerialPort = class(TCommNode) 16 16 private 17 17 procedure Receive(Sender: TCommPin; Stream: TListByte); 18 18 procedure SetStatus(Sender: TCommPin; AValue: Integer); 19 19 procedure ReceiveData(Stream: TListByte); 20 protected 21 procedure SetActive(AValue: Boolean); override; 20 22 public 23 SerialPort: TSerialPort; 21 24 Lock: TCriticalSection; 22 25 Pin: TCommPin; 23 26 destructor Destroy; override; 24 constructor Create ;27 constructor Create(AOwner: TComponent); override; 25 28 end; 26 29 … … 33 36 procedure TCommSerialPort.ReceiveData(Stream: TListByte); 34 37 begin 35 if Active then Pin.Send(Stream); 38 if SerialPort.Active then Pin.Send(Stream); 39 end; 40 41 procedure TCommSerialPort.SetActive(AValue: Boolean); 42 begin 43 inherited SetActive(AValue); 44 SerialPort.Active := AValue; 36 45 end; 37 46 … … 40 49 try 41 50 Lock.Acquire; 42 if (AValue and 1) = 1 then Parity := paMark else Parity := paSpace; 51 if (AValue and 1) = 1 then SerialPort.Parity := paMark 52 else SerialPort.Parity := paSpace; 43 53 finally 44 54 Lock.Release; … … 46 56 end; 47 57 48 constructor TCommSerialPort.Create ;58 constructor TCommSerialPort.Create(AOwner: TComponent); 49 59 begin 50 60 inherited; 61 SerialPort := TSerialPort.Create; 62 SerialPort.OnReceiveData := ReceiveData; 51 63 Lock := TCriticalSection.Create; 52 64 Pin := TCommPin.Create; 53 65 Pin.OnReceive := Receive; 54 66 Pin.OnSetSatus := SetStatus; 55 OnReceiveData := ReceiveData;67 Pin.Node := Self; 56 68 end; 57 69 58 70 destructor TCommSerialPort.Destroy; 59 71 begin 60 OnReceiveData := nil;72 SerialPort.OnReceiveData := nil; 61 73 Pin.Free; 62 74 Lock.Free; 75 SerialPort.Free; 63 76 inherited; 64 77 end; … … 71 84 S := TMemoryStream.Create; 72 85 Stream.WriteToStream(S); 73 if Active then begin86 if SerialPort.Active then begin 74 87 S.Position := 0; 75 88 repeat 76 89 try 77 90 Lock.Acquire; 78 if CanWrite(0) then79 Se ndStreamRaw(S);91 if SerialPort.CanWrite(0) then 92 SerialPort.SendStreamRaw(S); 80 93 finally 81 94 Lock.Release; -
PinConnection/UCommTCPClient.pas
r411 r413 28 28 { TCommTCPClient } 29 29 30 TCommTCPClient = class 30 TCommTCPClient = class(TCommNode) 31 31 private 32 32 FActive: Boolean; … … 41 41 Port: Word; 42 42 property Active: Boolean read FActive write SetActive; 43 constructor Create ;43 constructor Create(AOwner: TComponent); override; 44 44 destructor Destroy; override; 45 45 end; … … 93 93 end; 94 94 95 constructor TCommTCPClient.Create ;95 constructor TCommTCPClient.Create(AOwner: TComponent); 96 96 begin 97 inherited Create;97 inherited; 98 98 Socket := TTCPBlockSocket.Create; 99 99 Pin := TCommPin.Create; 100 100 Pin.OnReceive := ReceiveData; 101 Pin.Node := Self; 101 102 end; 102 103 -
PinConnection/UCommTCPServer.pas
r407 r413 43 43 { TCommTCPServer } 44 44 45 TCommTCPServer = class 45 TCommTCPServer = class(TCommNode) 46 46 private 47 47 FActive: Boolean; … … 59 59 property OnConnect: TSocketConnectEvent read FOnConnect write FOnConnect; 60 60 property OnDisconnect: TSocketConnectEvent read FOnDisconnect write FOnDisconnect; 61 constructor Create ;61 constructor Create(AOwner: TComponent); override; 62 62 destructor Destroy; override; 63 63 end; … … 85 85 Pin := TCommPin.Create; 86 86 Pin.OnReceive := ReceiveData; 87 Pin.Node := Server; 87 88 end; 88 89 … … 187 188 end; 188 189 189 constructor TCommTCPServer.Create ;190 begin 191 inherited Create;190 constructor TCommTCPServer.Create(AOwner: TComponent); 191 begin 192 inherited; 192 193 Sessions := TListObject.Create; 193 194 Socket := TTCPBlockSocket.Create; -
PinConnection/UCommTelnet.pas
r412 r413 67 67 { TCommTelnet } 68 68 69 TCommTelnet = class 69 TCommTelnet = class(TCommNode) 70 70 private 71 71 FResponses: TListObject; // TListObject<TListByte> … … 92 92 procedure SendSubCommand(OptionCode: TTelnetCommand; Request, Response: TListByte); 93 93 procedure SendCommand(Code: TTelnetCode; Request, Response: TListByte); 94 constructor Create ;94 constructor Create(AOwner: TComponent); override; 95 95 destructor Destroy; override; 96 96 property Active: Boolean read FActive write SetActive; … … 399 399 end; 400 400 401 constructor TCommTelnet.Create; 402 begin 401 constructor TCommTelnet.Create(AOwner: TComponent); 402 begin 403 inherited; 403 404 FResponses := TListObject.Create; 404 405 FCommandData := TBinarySerializer.Create; … … 407 408 TelnetPin := TCommPin.Create; 408 409 TelnetPin.OnReceive := TelnetDataReceive; 410 TelnetPin.Node := Self; 409 411 RawPin := TCommPin.Create; 410 412 RawPin.OnReceive := RawDataReceive; 413 RawPin.Node := Self; 411 414 Options := TListObject.Create; 412 415 Options.OwnsObjects := False; -
PinConnection/UCommThread.pas
r407 r413 28 28 { TCommThread } 29 29 30 TCommThread = class 30 TCommThread = class(TCommNode) 31 31 private 32 32 FActive: Boolean; … … 47 47 Pin: TCommPin; 48 48 property Active: Boolean read FActive write SetActive; 49 constructor Create ;49 constructor Create(AOwner: TComponent); override; 50 50 destructor Destroy; override; 51 51 end; … … 103 103 end; 104 104 105 constructor TCommThread.Create ;105 constructor TCommThread.Create(AOwner: TComponent); 106 106 begin 107 inherited Create;107 inherited; 108 108 FInputBuffer := TBinarySerializer.Create; 109 109 FInputBuffer.List := TListByte.Create; … … 113 113 Ext.OnReceive := ExtReceiveData; 114 114 Ext.OnSetSatus := ExtSetStatus; 115 Ext.Node := Self; 115 116 Pin := TCommPin.Create; 116 117 Pin.OnReceive := PinReceiveData; 117 118 Pin.OnSetSatus := PinSetStatus; 119 Pin.Node := Self; 118 120 FDataAvailable := TSimpleEvent.Create; 119 121 FStatusEvent := TSimpleEvent.Create; -
PinConnection/UPacketBurst.pas
r407 r413 19 19 { TPacketBurst } 20 20 21 TPacketBurst = class 21 TPacketBurst = class(TCommNode) 22 22 private 23 23 FActive: Boolean; … … 36 36 PacketBurstPin: TCommPin; 37 37 destructor Destroy; override; 38 constructor Create ;38 constructor Create(AOwner: TComponent); override; 39 39 property Active: Boolean read FActive write SetActive; 40 40 end; … … 44 44 { TSerialPort } 45 45 46 constructor TPacketBurst.Create ;46 constructor TPacketBurst.Create(AOwner: TComponent); 47 47 begin 48 inherited; 48 49 PacketSinglePin := TCommPin.Create; 49 50 PacketSinglePin.OnReceive := PacketSingleReceive; 51 PacketSinglePin.Node := Self; 50 52 PacketBurstPin := TCommPin.Create; 51 53 PacketBurstPin.OnReceive := PacketBurstReceive; 54 PacketBurstPin.Node := Self; 52 55 SendThreadEvent := TSimpleEvent.Create; 53 56 SendPeriod := 1;
Note:
See TracChangeset
for help on using the changeset viewer.