Changeset 272
- Timestamp:
- Aug 30, 2011, 3:50:15 PM (13 years ago)
- Location:
- PinConnection
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
PinConnection/Languages/UCommProtocol.cs.po
r268 r272 18 18 msgstr "Chyba dekódování dat" 19 19 20 #: ucommprotocol.sprotocolnotactive 21 msgid "Device protocol not active" 22 msgstr "" 23 20 24 #: ucommprotocol.sresponseerror 21 25 #| msgid "Command %s response error %s" -
PinConnection/Languages/UCommProtocol.po
r268 r272 8 8 #: ucommprotocol.sprotocoldecodeerror 9 9 msgid "Data decode error" 10 msgstr "" 11 12 #: ucommprotocol.sprotocolnotactive 13 msgid "Device protocol not active" 10 14 msgstr "" 11 15 -
PinConnection/UCommHub.pas
r119 r272 14 14 TCommHub = class 15 15 private 16 FActive: Boolean; 16 17 FPins: TObjectList; 17 18 function GetPin(Index: Integer): TCommPin; … … 29 30 function AddNew: TCommPin; 30 31 property Pins[Index: Integer]: TCommPin read GetPin; 32 property Active: Boolean read FActive write FActive; 31 33 end; 32 34 … … 44 46 I: Integer; 45 47 begin 46 // Broadcast received packet to all other pins 47 for I := 0 to FPins.Count - 1 do 48 if Sender <> FPins[I] then 49 TCommPin(FPins[I]).Send(Stream); 48 if FActive then begin 49 // Broadcast received packet to all other pins 50 for I := 0 to FPins.Count - 1 do 51 if Sender <> FPins[I] then 52 TCommPin(FPins[I]).Send(Stream); 53 end; 50 54 end; 51 55 -
PinConnection/UCommProtocol.pas
r268 r272 14 14 ECommTimeout = class(Exception); 15 15 ECommError = class(Exception); 16 ENotActive = class(Exception); 16 17 17 18 TResponseError = (rcNone, rcCommandNotSupported, rcSequenceOutOfRange, … … 118 119 SDeviceProtocol = 'Device protocol'; 119 120 SProtocolDecodeError = 'Data decode error'; 121 SProtocolNotActive = 'Device protocol not active'; 120 122 121 123 procedure TCommProtocol.DataReceive(Sender: TCommPin; Stream: TStream); … … 133 135 with Request do 134 136 try 137 Stream.Position := 0; 135 138 ReadFromStream(Stream); 136 139 if TestIndex(0) then … … 273 276 NewRequest: TVarBlockIndexed; 274 277 begin 278 if FActive then begin 275 279 try 276 280 Session := TDeviceProtocolSession.Create; … … 337 341 NewRequest.Free; 338 342 end; 343 end else raise ENotActive.Create(SProtocolNotActive); 339 344 end; 340 345 -
PinConnection/UCommSerialPort.pas
r258 r272 29 29 procedure TCommSerialPort.ReceiveData(Stream: TMemoryStream); 30 30 begin 31 Pin.Send(Stream);31 if Active then Pin.Send(Stream); 32 32 end; 33 33 … … 51 51 procedure TCommSerialPort.Receive(Sender: TCommPin; Stream: TStream); 52 52 begin 53 Stream.Position := 0; 54 repeat 55 try 56 Lock.Acquire; 57 if CanWrite(0) then 58 SendStreamRaw(Stream); 59 finally 60 Lock.Release; 61 end; 62 if Stream.Position <> Stream.Size then 63 Sleep(1); 64 until Stream.Position = Stream.Size; 53 if Active then begin 54 Stream.Position := 0; 55 repeat 56 try 57 Lock.Acquire; 58 if CanWrite(0) then 59 SendStreamRaw(Stream); 60 finally 61 Lock.Release; 62 end; 63 if Stream.Position <> Stream.Size then 64 Sleep(1); 65 until Stream.Position = Stream.Size; 66 end; 65 67 end; 66 68 -
PinConnection/UCommSocket.pas
r231 r272 49 49 procedure TCommSocket.ReceiveData(Sender: TCommPin; Stream:TStream); 50 50 begin 51 Socket.SendStreamRaw(Stream);51 if FActive then Socket.SendStreamRaw(Stream); 52 52 end; 53 53 -
PinConnection/UCommThread.pas
r231 r272 19 19 public 20 20 Parent: TCommThread; 21 Stream: T MemoryStream;21 Stream: TStreamHelper; 22 22 procedure Execute; override; 23 23 constructor Create(CreateSuspended: Boolean; … … 53 53 procedure TCommThread.ReceiveData(Sender: TCommPin; Stream:TStream); 54 54 begin 55 Ext.Send(Stream);55 if FActive then Ext.Send(Stream); 56 56 end; 57 57 … … 115 115 116 116 procedure TCommThreadReceiveThread.Execute; 117 var118 StreamHelper: TStreamHelper;119 117 begin 120 118 try 121 StreamHelper := TStreamHelper.Create(Stream);122 119 with Parent do 123 120 repeat 124 if FDataAvailable.WaitFor(1) = wrSignaled then begin121 if FDataAvailable.WaitFor(1) = wrSignaled then 125 122 try 126 123 FInputBufferLock.Acquire; 127 124 Stream.Size := 0; 128 Stream Helper.WriteStream(FInputBuffer, FInputBuffer.Size);125 Stream.WriteStream(FInputBuffer, FInputBuffer.Size); 129 126 Pin.Send(Stream); 127 finally 128 FDataAvailable.ResetEvent; 130 129 FInputBuffer.Clear; 131 finally132 130 FInputBufferLock.Release; 133 end;134 131 end; // else Yield; 135 132 until Terminated; 136 133 finally 137 StreamHelper.Free;138 134 end; 139 135 end; … … 143 139 begin 144 140 inherited; 145 Stream := T MemoryStream.Create;141 Stream := TStreamHelper.Create; 146 142 end; 147 143
Note:
See TracChangeset
for help on using the changeset viewer.