Browse Source

修改心跳问题

炒锅机器人_一拖多
liup 4 months ago
parent
commit
58aaa7cb6e
1 changed files with 61 additions and 45 deletions
  1. +61
    -45
      app/src/main/java/com/bonait/bnframework/modbus/ModbusCenter.java

+ 61
- 45
app/src/main/java/com/bonait/bnframework/modbus/ModbusCenter.java View File

@@ -80,7 +80,7 @@ public class ModbusCenter {

public static void Listening() {

ThreadManager.get().StartLong("炒锅PLC设备数据监听", true, () -> {
ThreadManager.get().StartLong("炒锅1PLC设备数据监听", true, () -> {
try {
long a = System.currentTimeMillis();
long b = System.currentTimeMillis();
@@ -90,11 +90,6 @@ public class ModbusCenter {
TempControl(1);
ReadPLCStatus(1);
}
if (Wok2ModbusTcpServer.get().plcIsConnect) {
WritePlc(2,"心跳位", 0, null);
TempControl(2);
ReadPLCStatus(2);
}
try{
if(WokModbusTcpServer.get().plcIsConnect){
for (Res_PLCADDRESS item : ConfigName.getInstance().PlcAddress_Wok) {
@@ -102,29 +97,24 @@ public class ModbusCenter {
if (item.isread == 1) {
if(WokModbusTcpServer.get().plcIsConnect){
Object val = wokReadPlc(1,item.name);
if(ConfigName.LOG_TEST){
LogUtils.d("机炒锅PLC设备数据监听 ovenReadPlc item="+item.name+" val="+val+" plcaddress.address="+item.address);
}
if(item.name.equals("原点位反馈")||item.name.equals("投料位反馈")){
if(RobotModbusTcpServer.get().plcIsConnect){
if((boolean)val){
ModbusCenter.robotWritePlc(false,"1号炒锅允许倒料",true,null);
}
}
}
Object hotError = ModbusCenter.wokReadPlc(1,"异常加热故障信息");
if((Boolean) hotError){
NewToastUtil.getInstance().showToastError("1号炒锅硬件加热异常,请联系海科人员");
}

if(ConfigName.LOG_TEST){
LogUtils.d("炒锅PLC设备数据监听 name="+item.name+" plcaddress.address="+item.address +" ;val="+val);
}
WokModbusTcpServer.get().listeningValue.put(item.name, val);
}
}
}
}

Object object1 = WokModbusTcpServer.get().listeningValue.get("原点位反馈");
Object object2 = WokModbusTcpServer.get().listeningValue.get("投料位反馈");
if(object1 instanceof Boolean){
if((Boolean) object2 || (Boolean)object1){
ModbusCenter.robotWritePlc(false,"1号炒锅允许倒料",true,null);
}
}

Object hotError = ModbusCenter.wokReadPlc(1,"异常加热故障信息");
if((Boolean) hotError){
NewToastUtil.getInstance().showToastError("1号炒锅硬件加热异常,请联系海科人员");
}
}else {
WokModbusTcpServer.get().ReConnect("Connection refused");
}
@@ -135,6 +125,42 @@ public class ModbusCenter {
TempControl(1);
ReadPLCStatus(1);
}
}catch (Exception ex){
LogUtils.d("异常信息:" + ex.getMessage());
}
b = System.currentTimeMillis();
LogUtils.d("//////////time 3"+(b-a));
if (WokModbusTcpServer.get().plcIsConnect) {
WritePlc(1,"心跳位", 0, null);
TempControl(1);
ReadPLCStatus(1);
}
if (Wok2ModbusTcpServer.get().plcIsConnect) {
WritePlc(2,"心跳位", 0, null);
TempControl(2);
ReadPLCStatus(2);
}
b = System.currentTimeMillis();
LogUtils.d("//////////time 4"+(b-a));
} catch (Exception ex) {
LogUtils.d("异常信息:" + ex.getMessage());
}
Thread.sleep(50);

});
ThreadManager.get().StartLong("炒锅2PLC设备数据监听", true, () -> {
try {
if (Wok2ModbusTcpServer.get().plcIsConnect) {
WritePlc(2,"心跳位", 0, null);
TempControl(2);
ReadPLCStatus(2);
}
try{
if (WokModbusTcpServer.get().plcIsConnect) {
WritePlc(1,"心跳位", 0, null);
TempControl(1);
ReadPLCStatus(1);
}
if (Wok2ModbusTcpServer.get().plcIsConnect) {
WritePlc(2,"心跳位", 0, null);
TempControl(2);
@@ -146,9 +172,6 @@ public class ModbusCenter {
if (item.isread == 1) {
if(Wok2ModbusTcpServer.get().plcIsConnect){
Object val = wokReadPlc(2,item.name);
if(ConfigName.LOG_TEST){
LogUtils.d("机炒锅PLC设备数据监听 ovenReadPlc item="+item.name+" val="+val+" plcaddress.address="+item.address);
}
if(item.name.equals("原点位反馈")||item.name.equals("投料位反馈")){
if(RobotModbusTcpServer.get().plcIsConnect){
if((boolean)val){
@@ -156,40 +179,33 @@ public class ModbusCenter {
}
}
}
Object hotError = ModbusCenter.wokReadPlc(1,"异常加热故障信息");
if((Boolean) hotError){
NewToastUtil.getInstance().showToastError("1号炒锅硬件加热异常,请联系海科人员");
}
if(ConfigName.LOG_TEST){
LogUtils.d("炒锅PLC设备数据监听 name="+item.name+" plcaddress.address="+item.address +" ;val="+val);
}
Wok2ModbusTcpServer.get().listeningValue.put(item.name, val);
}
}
}
}
Object object1 = Wok2ModbusTcpServer.get().listeningValue.get("原点位反馈");
Object object2 = Wok2ModbusTcpServer.get().listeningValue.get("投料位反馈");
if(object1 instanceof Boolean){
if((Boolean) object2 || (Boolean)object1){
ModbusCenter.robotWritePlc(false,"1号炒锅允许倒料",true,null);
}
}
Object hotError = ModbusCenter.wokReadPlc(1,"异常加热故障信息");
if((Boolean) hotError){
NewToastUtil.getInstance().showToastError("1号炒锅硬件加热异常,请联系海科人员");
}
}else {
Wok2ModbusTcpServer.get().ReConnect("Connection refused");
}


}catch (Exception ex){
LogUtils.d("异常信息:" + ex.getMessage());
}
b = System.currentTimeMillis();
LogUtils.d("//////////time 3"+(b-a));
if (WokModbusTcpServer.get().plcIsConnect) {
WritePlc(1,"心跳位", 0, null);
TempControl(1);
ReadPLCStatus(1);
}
if (Wok2ModbusTcpServer.get().plcIsConnect) {
WritePlc(2,"心跳位", 0, null);
TempControl(2);
ReadPLCStatus(2);
}
b = System.currentTimeMillis();
LogUtils.d("//////////time 4"+(b-a));
} catch (Exception ex) {
LogUtils.d("异常信息:" + ex.getMessage());
}


Loading…
Cancel
Save