@@ -184,6 +184,10 @@ public class ConfigName { | |||
//endregion | |||
//region PlC连接参数 | |||
/** | |||
* Plc是否连接 | |||
*/ | |||
public boolean IsShow = false; | |||
/** | |||
* Plc是否连接 | |||
*/ | |||
@@ -66,6 +66,7 @@ public class BottomNavigation2Activity extends BaseActivity { | |||
@Override | |||
protected void onDestroy() { | |||
ConfigData.getInstance().ColsePLC(); | |||
ConfigName.getInstance().IsShow=false; | |||
//AliyunIOTManager.getInstance().CloseDev(); | |||
super.onDestroy(); | |||
} | |||
@@ -182,51 +183,55 @@ public class BottomNavigation2Activity extends BaseActivity { | |||
*/ | |||
public void ReconnectModbus() { | |||
try { | |||
ConfigName.getInstance().IsShow=true; | |||
ThreadManager.Get().StartLong("PLC断线重连线程", true, new IThread() { | |||
@Override | |||
public void Run() throws InterruptedException { | |||
try { | |||
if (ConfigName.getInstance().PlcIsConnect) { | |||
//ping 不通 | |||
boolean status = ModbusTcpServer.ping2(ConfigName.getInstance().Address, 1, 1); | |||
if (!status) //ping 不通 连接 | |||
{ | |||
MessageLog.ShowInfo("PLC状态断开,尝试连接..."); | |||
ConfigName.getInstance().PlcIsConnect = false; | |||
} | |||
} else { | |||
boolean status = ModbusTcpServer.ping2(ConfigName.getInstance().Address, 1, 1); | |||
if (status) { | |||
MessageLog.ShowInfo("设备 " + ConfigName.getInstance().Address + " PLC通讯正常,准备连接!"); | |||
ModbusTcpServer.ConnectPLC(); | |||
} else { | |||
MessageLog.ShowInfo("PLC状态断开,尝试连接..."); | |||
ConfigName.getInstance().PlcIsConnect = false; | |||
} | |||
} | |||
if(ConfigName.getInstance().versionSelectionEnum.contains("一拖")) | |||
if(ConfigName.getInstance().IsShow) | |||
{ | |||
if (ConfigName.getInstance().PlcMainIsConnect) { | |||
if (ConfigName.getInstance().PlcIsConnect) { | |||
//ping 不通 | |||
boolean status = ModbusTcpMainServer.ping2(ConfigName.getInstance().MainAddress, 1, 1); | |||
boolean status = ModbusTcpServer.ping2(ConfigName.getInstance().Address, 1, 1); | |||
if (!status) //ping 不通 连接 | |||
{ | |||
MessageLog.ShowInfo("主控PLC状态断开,尝试连接..."); | |||
ConfigName.getInstance().PlcMainIsConnect = false; | |||
MessageLog.ShowInfo("PLC状态断开,尝试连接..."); | |||
ConfigName.getInstance().PlcIsConnect = false; | |||
} | |||
} else { | |||
boolean status = ModbusTcpMainServer.ping2(ConfigName.getInstance().MainAddress, 1, 1); | |||
boolean status = ModbusTcpServer.ping2(ConfigName.getInstance().Address, 1, 1); | |||
if (status) { | |||
MessageLog.ShowInfo("设备 " + ConfigName.getInstance().MainAddress + " 主控PLC通讯正常,准备连接!"); | |||
ModbusTcpMainServer.ConnectPLC(); | |||
MessageLog.ShowInfo("设备 " + ConfigName.getInstance().Address + " PLC通讯正常,准备连接!"); | |||
ModbusTcpServer.ConnectPLC(); | |||
} else { | |||
MessageLog.ShowInfo("主控PLC状态断开,尝试连接..."); | |||
ConfigName.getInstance().PlcMainIsConnect = false; | |||
MessageLog.ShowInfo("PLC状态断开,尝试连接..."); | |||
ConfigName.getInstance().PlcIsConnect = false; | |||
} | |||
} | |||
if(ConfigName.getInstance().versionSelectionEnum.contains("一拖")) | |||
{ | |||
if (ConfigName.getInstance().PlcMainIsConnect) { | |||
//ping 不通 | |||
boolean status = ModbusTcpMainServer.ping2(ConfigName.getInstance().MainAddress, 1, 1); | |||
if (!status) //ping 不通 连接 | |||
{ | |||
MessageLog.ShowInfo("主控PLC状态断开,尝试连接..."); | |||
ConfigName.getInstance().PlcMainIsConnect = false; | |||
} | |||
} else { | |||
boolean status = ModbusTcpMainServer.ping2(ConfigName.getInstance().MainAddress, 1, 1); | |||
if (status) { | |||
MessageLog.ShowInfo("设备 " + ConfigName.getInstance().MainAddress + " 主控PLC通讯正常,准备连接!"); | |||
ModbusTcpMainServer.ConnectPLC(); | |||
} else { | |||
MessageLog.ShowInfo("主控PLC状态断开,尝试连接..."); | |||
ConfigName.getInstance().PlcMainIsConnect = false; | |||
} | |||
} | |||
} | |||
} | |||
Thread.sleep(3000); | |||
} catch (Exception e) { | |||
Log.i("PLC", "PLC重连接失败!" + e.getMessage()); | |||
@@ -282,46 +282,49 @@ public class BottomNavigationNewActivity extends BaseActivity { | |||
*/ | |||
public void ReconnectModbus() { | |||
try { | |||
ThreadManager.Get().StartLong("PLC断线重连线程", true, new IThread() { | |||
ThreadManager.Get().StartLong("PLC断线重连线程-2", true, new IThread() { | |||
@Override | |||
public void Run() throws InterruptedException { | |||
try { | |||
if (ConfigName.getInstance().PlcIsConnect) { | |||
//ping 不通 | |||
boolean status = ModbusTcpServer.ping2(ConfigName.getInstance().Address, 1, 1); | |||
if (!status) //ping 不通 连接 | |||
{ | |||
MessageLog.ShowInfo("PLC状态断开,尝试连接..."); | |||
ConfigName.getInstance().PlcIsConnect = false; | |||
} | |||
} else { | |||
boolean status = ModbusTcpServer.ping2(ConfigName.getInstance().Address, 1, 1); | |||
if (status) { | |||
MessageLog.ShowInfo("设备 " + ConfigName.getInstance().Address + " PLC通讯正常,准备连接!"); | |||
ModbusTcpServer.ConnectPLC(); | |||
} else { | |||
MessageLog.ShowInfo("PLC状态断开,尝试连接..."); | |||
ConfigName.getInstance().PlcIsConnect = false; | |||
} | |||
} | |||
if (ConfigName.getInstance().versionSelectionEnum.contains("一拖")) { | |||
if (ConfigName.getInstance().PlcMainIsConnect) { | |||
if(IsRunThread) | |||
{ | |||
if (ConfigName.getInstance().PlcIsConnect) { | |||
//ping 不通 | |||
boolean status = ModbusTcpMainServer.ping2(ConfigName.getInstance().MainAddress, 1, 1); | |||
boolean status = ModbusTcpServer.ping2(ConfigName.getInstance().Address, 1, 1); | |||
if (!status) //ping 不通 连接 | |||
{ | |||
MessageLog.ShowInfo("主控PLC状态断开,尝试连接..."); | |||
ConfigName.getInstance().PlcMainIsConnect = false; | |||
MessageLog.ShowInfo("PLC状态断开,尝试连接..."); | |||
ConfigName.getInstance().PlcIsConnect = false; | |||
} | |||
} else { | |||
boolean status = ModbusTcpMainServer.ping2(ConfigName.getInstance().MainAddress, 1, 1); | |||
boolean status = ModbusTcpServer.ping2(ConfigName.getInstance().Address, 1, 1); | |||
if (status) { | |||
MessageLog.ShowInfo("设备 " + ConfigName.getInstance().MainAddress + " 主控PLC通讯正常,准备连接!"); | |||
ModbusTcpMainServer.ConnectPLC(); | |||
MessageLog.ShowInfo("设备 " + ConfigName.getInstance().Address + " PLC通讯正常,准备连接!"); | |||
ModbusTcpServer.ConnectPLC(); | |||
} else { | |||
MessageLog.ShowInfo("主控PLC状态断开,尝试连接..."); | |||
ConfigName.getInstance().PlcMainIsConnect = false; | |||
MessageLog.ShowInfo("PLC状态断开,尝试连接..."); | |||
ConfigName.getInstance().PlcIsConnect = false; | |||
} | |||
} | |||
if (ConfigName.getInstance().versionSelectionEnum.contains("一拖")) { | |||
if (ConfigName.getInstance().PlcMainIsConnect) { | |||
//ping 不通 | |||
boolean status = ModbusTcpMainServer.ping2(ConfigName.getInstance().MainAddress, 1, 1); | |||
if (!status) //ping 不通 连接 | |||
{ | |||
MessageLog.ShowInfo("主控PLC状态断开,尝试连接..."); | |||
ConfigName.getInstance().PlcMainIsConnect = false; | |||
} | |||
} else { | |||
boolean status = ModbusTcpMainServer.ping2(ConfigName.getInstance().MainAddress, 1, 1); | |||
if (status) { | |||
MessageLog.ShowInfo("设备 " + ConfigName.getInstance().MainAddress + " 主控PLC通讯正常,准备连接!"); | |||
ModbusTcpMainServer.ConnectPLC(); | |||
} else { | |||
MessageLog.ShowInfo("主控PLC状态断开,尝试连接..."); | |||
ConfigName.getInstance().PlcMainIsConnect = false; | |||
} | |||
} | |||
} | |||
} | |||
@@ -550,7 +550,7 @@ public class DiyActivity extends BaseActivity { | |||
*/ | |||
public boolean IsHotJ() | |||
{ | |||
int index=0; | |||
int index=1; | |||
int k=0;int j=0; | |||
for(BPA_GOODSRECIPE item:bpa_goodsrecipes) | |||
{ | |||
@@ -566,7 +566,7 @@ public class DiyActivity extends BaseActivity { | |||
index++; | |||
} | |||
if(j<=k) | |||
if(j<k) | |||
{ | |||
return false; | |||
}else | |||
@@ -583,7 +583,7 @@ public class DiyUpdate1Activity extends BaseActivity { | |||
*/ | |||
public boolean IsHotJ() | |||
{ | |||
int index=0; | |||
int index=1; | |||
int k=0;int j=0; | |||
for(BPA_GOODSRECIPE item:bpa_goodsrecipes) | |||
{ | |||
@@ -599,7 +599,7 @@ public class DiyUpdate1Activity extends BaseActivity { | |||
index++; | |||
} | |||
if(j<=k) | |||
if(j<k) | |||
{ | |||
return false; | |||
}else | |||
@@ -661,7 +661,7 @@ public class DiyUpdateActivity extends BaseActivity { | |||
*/ | |||
public boolean IsHotJ() | |||
{ | |||
int index=0; | |||
int index=1; | |||
int k=0;int j=0; | |||
for(BPA_GOODSRECIPE item:bpa_goodsrecipes) | |||
{ | |||
@@ -677,7 +677,7 @@ public class DiyUpdateActivity extends BaseActivity { | |||
index++; | |||
} | |||
if(j<=k) | |||
if(j<k) | |||
{ | |||
return false; | |||
}else | |||