public void Remove(ICommStream streamMember) { lock (_lock) { _streams.Remove(streamMember); } }
public void Add(ICommStream streamMember) { lock (_lock) { _streams.Add(streamMember); streamMember.ReadTimeout = _readTimeout; streamMember.WriteTimeout = _writeTimeout; } }
private int Read(ICommStream stream, byte[] buffer, int offset, int length, int timeout) { _stopwatch.Restart(); int totalReceivedBytes = 0; do { int receivedBytes = stream.Read(buffer, offset + totalReceivedBytes, length - totalReceivedBytes); totalReceivedBytes += receivedBytes; if (totalReceivedBytes >= length) { break; } while ((stream.Available < 1) && (timeout > _stopwatch.ElapsedMilliseconds)) { Thread.Sleep(1); } } while (timeout > _stopwatch.ElapsedMilliseconds); _stopwatch.Stop(); return(totalReceivedBytes); }
public ModbusProtocolImpl(ICommStream stream) { this._stream = stream; }
public StreamExceptionArgs(ICommStream stream, Exception exception) { this.Stream = stream; this.Exception = exception; }