Skip to content

Commit

Permalink
set default of timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
GavinYellow committed Dec 26, 2017
1 parent 246bddb commit dc91bcd
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion SCADA/Program/ModbusDriver/ModbusRTUDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public bool IsClosed
}
}

private int _timeOut;
private int _timeOut = 1000;
public int TimeOut
{
get { return _timeOut; }
Expand Down Expand Up @@ -79,6 +79,7 @@ public bool Connect()
{
if (_serialPort == null)
_serialPort = new SerialPort(_port);
if (_timeOut <= 0) _timeOut = 1000;
_serialPort.ReadTimeout = _timeOut;
_serialPort.WriteTimeout = _timeOut;
_serialPort.BaudRate = _baudRate;
Expand Down
3 changes: 2 additions & 1 deletion SCADA/Program/ModbusDriver/ModbusTCPDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public string GetAddress(DeviceAddress address)
}

#endregion
private int _timeout;
private int _timeout = 1000;

private Socket tcpSynCl;
private byte[] tcpSynClBuffer = new byte[0xFF];
Expand Down Expand Up @@ -180,6 +180,7 @@ public bool Connect()
//IPAddress ip = IPAddress.Parse(_ip);
// ----------------------------------------------------------------
// Connect synchronous client
if (_timeout <= 0) _timeout = 1000;
tcpSynCl = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
tcpSynCl.SendTimeout = _timeout;
tcpSynCl.ReceiveTimeout = _timeout;
Expand Down
2 changes: 1 addition & 1 deletion SCADA/Program/SiemensPLCDriver/SiemensPLCDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public int PDU
}
}

int _timeOut;
int _timeOut = 1000;
public int TimeOut
{
get
Expand Down
Binary file modified SCADA/dll/ModbusDriver.dll
Binary file not shown.
Binary file modified SCADA/dll/SiemensPLCDriver.dll
Binary file not shown.

0 comments on commit dc91bcd

Please sign in to comment.