Esempio n. 1
0
 public void Remove(ICommStream streamMember)
 {
     lock (_lock)
     {
         _streams.Remove(streamMember);
     }
 }
Esempio n. 2
0
 public void Add(ICommStream streamMember)
 {
     lock (_lock)
     {
         _streams.Add(streamMember);
         streamMember.ReadTimeout  = _readTimeout;
         streamMember.WriteTimeout = _writeTimeout;
     }
 }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
 public ModbusProtocolImpl(ICommStream stream)
 {
     this._stream = stream;
 }
Esempio n. 5
0
 public StreamExceptionArgs(ICommStream stream, Exception exception)
 {
     this.Stream    = stream;
     this.Exception = exception;
 }