|
|
@@ -201,7 +201,7 @@ public class ModbusTcpServer { |
|
|
|
.setRetries(0) |
|
|
|
.setEncapsulated(false) |
|
|
|
.setKeepAlive(true); |
|
|
|
ConnectPLC(); |
|
|
|
//ConnectPLC(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@@ -257,11 +257,15 @@ public class ModbusTcpServer { |
|
|
|
@Override |
|
|
|
public void Run() throws InterruptedException { |
|
|
|
try { |
|
|
|
ModbusMaster master= ModbusTcpHelper.get().getModbusMaster(); |
|
|
|
if (master==null || master.isConnected() == false) { |
|
|
|
ConnectPLC(); |
|
|
|
boolean status =ping2(ConfigName.getInstance().Address,1,1); |
|
|
|
if(status) |
|
|
|
{ |
|
|
|
ModbusMaster master= ModbusTcpHelper.get().getModbusMaster(); |
|
|
|
if (master==null || master.isConnected() == false) { |
|
|
|
ConnectPLC(); |
|
|
|
} |
|
|
|
Thread.sleep(20000); |
|
|
|
} |
|
|
|
Thread.sleep(20000); |
|
|
|
} catch (Exception e) { |
|
|
|
Log.i("PLC", "PLC重连接失败!"+e.getMessage()); |
|
|
|
} |
|
|
|