Kaynağa Gözat

现场改动12

调味吧台(白底)
fyf 1 yıl önce
ebeveyn
işleme
5778d4d3d2
2 değiştirilmiş dosya ile 12 ekleme ve 13 silme
  1. +1
    -1
      app/src/main/java/com/example/bpa/MainActivity.java
  2. +11
    -12
      app/src/main/java/com/example/bpa/helper/ModbusTcpServer.java

+ 1
- 1
app/src/main/java/com/example/bpa/MainActivity.java Dosyayı Görüntüle

@@ -163,7 +163,7 @@ public class MainActivity extends FragmentActivity implements View.OnClickListen
}
}
}).start();
//ModbusTcpServer.get().ReconnectModbus();
ModbusTcpServer.get().ReconnectModbus();
//MQTT数据监听
OrderServer.Get().MqttInit();
//消息中心


+ 11
- 12
app/src/main/java/com/example/bpa/helper/ModbusTcpServer.java Dosyayı Görüntüle

@@ -4,6 +4,7 @@ package com.example.bpa.helper;
import android.util.Log;

import com.example.bpa.Model.IReadCallBack;
import com.example.bpa.Model.IThread;
import com.example.bpa.Model.IWriteCallBack;
import com.example.bpa.config.ConfigName;
import com.example.bpa.service.BusinessServer;
@@ -252,25 +253,23 @@ public class ModbusTcpServer {
{
try {

//断线重新连接
// 必须开启新的线程执行
new Thread(new Runnable() {
ThreadManager.Get().StartLong("PLC断线重连线程", true, new IThread() {
@Override
public void run() {
public void Run() throws InterruptedException {
try {
while (true)
{
ModbusMaster master= ModbusTcpHelper.get().getModbusMaster();
if (master==null || master.isConnected() == false) {
ConnectPLC();
}
Thread.sleep(20000);
ModbusMaster master= ModbusTcpHelper.get().getModbusMaster();
if (master==null || master.isConnected() == false) {
ConnectPLC();
}
Thread.sleep(20000);
} catch (Exception e) {
Log.i("PLC", "PLC重连接失败!"+e.getMessage());
}
}
}).start();
@Override
public void RunComplete() throws InterruptedException {
}
});
}catch (Exception e) {
MessageLog.ShowInfo("重新连接Modbus异常," +e.getMessage());
}


Yükleniyor…
İptal
Kaydet