Browse Source

set default of timeout

pull/15/head
Gavin 9 years ago
parent
commit
dc91bcd821
  1. 3
      SCADA/Program/ModbusDriver/ModbusRTUDriver.cs
  2. 3
      SCADA/Program/ModbusDriver/ModbusTCPDriver.cs
  3. 2
      SCADA/Program/SiemensPLCDriver/SiemensPLCDriver.cs
  4. BIN
      SCADA/dll/ModbusDriver.dll
  5. BIN
      SCADA/dll/SiemensPLCDriver.dll

3
SCADA/Program/ModbusDriver/ModbusRTUDriver.cs

@ -47,7 +47,7 @@ namespace ModbusDriver
} }
} }
private int _timeOut; private int _timeOut = 1000;
public int TimeOut public int TimeOut
{ {
get { return _timeOut; } get { return _timeOut; }
@ -79,6 +79,7 @@ namespace ModbusDriver
{ {
if (_serialPort == null) if (_serialPort == null)
_serialPort = new SerialPort(_port); _serialPort = new SerialPort(_port);
if (_timeOut <= 0) _timeOut = 1000;
_serialPort.ReadTimeout = _timeOut; _serialPort.ReadTimeout = _timeOut;
_serialPort.WriteTimeout = _timeOut; _serialPort.WriteTimeout = _timeOut;
_serialPort.BaudRate = _baudRate; _serialPort.BaudRate = _baudRate;

3
SCADA/Program/ModbusDriver/ModbusTCPDriver.cs

@ -107,7 +107,7 @@ namespace ModbusDriver
} }
#endregion #endregion
private int _timeout; private int _timeout = 1000;
private Socket tcpSynCl; private Socket tcpSynCl;
private byte[] tcpSynClBuffer = new byte[0xFF]; private byte[] tcpSynClBuffer = new byte[0xFF];
@ -180,6 +180,7 @@ namespace ModbusDriver
//IPAddress ip = IPAddress.Parse(_ip); //IPAddress ip = IPAddress.Parse(_ip);
// ---------------------------------------------------------------- // ----------------------------------------------------------------
// Connect synchronous client // Connect synchronous client
if (_timeout <= 0) _timeout = 1000;
tcpSynCl = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); tcpSynCl = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
tcpSynCl.SendTimeout = _timeout; tcpSynCl.SendTimeout = _timeout;
tcpSynCl.ReceiveTimeout = _timeout; tcpSynCl.ReceiveTimeout = _timeout;

2
SCADA/Program/SiemensPLCDriver/SiemensPLCDriver.cs

@ -45,7 +45,7 @@ namespace SiemensPLCDriver
} }
} }
int _timeOut; int _timeOut = 1000;
public int TimeOut public int TimeOut
{ {
get get

BIN
SCADA/dll/ModbusDriver.dll

Binary file not shown.

BIN
SCADA/dll/SiemensPLCDriver.dll

Binary file not shown.
Loading…
Cancel
Save